<commit_before>package org.wildfly.swarm.msc;

import java.util.ArrayList;
import java.util.List;

import org.jboss.msc.service.ServiceActivator;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.container.Deployment;

/**
 * @author <NAME>
 */
public class ServiceActivatorDeployment implements Deployment {

    private final JavaArchive archive;

    private final List<Class<? extends ServiceActivator>> activators = new ArrayList<>();

    public ServiceActivatorDeployment(Container container) {
        this.archive = container.create("services.jar", JavaArchive.class);
    }

    public void addServiceActivator(Class<? extends ServiceActivator> activator) {
        this.archive.addClass(activator);
        this.activators.add(activator);
    }

    public void addClass(Class cls) {
        this.archive.addClass(cls);
    }

    @Override
    public JavaArchive getArchive() {
        return getArchive(false);
    }

    public JavaArchive getArchive(boolean finalize) {
        if (finalize) {
            this.archive.addAsServiceProvider(ServiceActivator.class, (Class[]) this.activators.toArray(new Class[]{}));
            addJBossDeploymentStructure();
        }
        return this.archive;
    }<commit_msg>Add a unique name to service-activator deployments.<commit_after>package org.wildfly.swarm.msc;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.jboss.msc.service.ServiceActivator;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.container.Deployment;

/**
 * @author <NAME>
 */
public class ServiceActivatorDeployment implements Deployment {

    private static AtomicInteger COUNTER = new AtomicInteger();
    private final JavaArchive archive;

    private final List<Class<? extends ServiceActivator>> activators = new ArrayList<>();

    public ServiceActivatorDeployment(Container container) {
        this.archive = container.create("services-" + COUNTER.incrementAndGet() + ".jar", JavaArchive.class);
    }

    public void addServiceActivator(Class<? extends ServiceActivator> activator) {
        this.archive.addClass(activator);
        this.activators.add(activator);
    }

    public void addClass(Class cls) {
        this.archive.addClass(cls);
    }

    @Override
    public JavaArchive getArchive() {
        return getArchive(false);
    }

    public JavaArchive getArchive(boolean finalize) {
        if (finalize) {
            this.archive.addAsServiceProvider(ServiceActivator.class, (Class[]) this.activators.toArray(new Class[]{}));
            addJBossDeploymentStructure();
        }
        return this.archive;
    }
{'fraction_non_alphanumeric': 0.10560941828254848, 'fraction_numerical': 0.0, 'mean_word_length': 3.736065573770492, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378011', 'n_tokens_mistral': 852, 'n_tokens_neox': 797, 'n_words': 162}