All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.swarm.drools.server.runtime.DroolsDeploymentProducer Maven / Gradle / Ivy

There is a newer version: 2.7.0.Final
Show newest version
package org.wildfly.swarm.drools.server.runtime;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.wildfly.swarm.bootstrap.util.TempFileManager;
import org.wildfly.swarm.jaxrs.JAXRSArchive;

/**
 * @author Ken Finnigan
 */
@ApplicationScoped
public class DroolsDeploymentProducer {

    private static String configFolder = System.getProperty("org.drools.server.swarm.web.conf");

    @Produces
    public Archive droolsWar() throws Exception {
        if (System.getProperty("org.drools.server.swarm.web.conf") == null) {
            //Path dir = Files.createTempDirectory("swarm-keycloak-config");
            File dir = TempFileManager.INSTANCE.newTempDirectory("swarm-drools-web-config", ".d");
            System.setProperty("org.drools.server.swarm.conf", dir.getAbsolutePath());
            Files.copy(getClass().getClassLoader().getResourceAsStream("config/web/web.xml"),
                    dir.toPath().resolve("web.xml"),
                    StandardCopyOption.REPLACE_EXISTING);
            Files.copy(getClass().getClassLoader().getResourceAsStream("config/web/jboss-web.xml"),
                    dir.toPath().resolve("jboss-web.xml"),
                    StandardCopyOption.REPLACE_EXISTING);
            configFolder = dir.toPath().toString();
        }

        DroolsMessages.MESSAGES.configurationDirectory(configFolder);

        JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "drools-server.war");
        deployment.addAllDependencies();

        deployment.addAsWebInfResource(new File(configFolder + "/web.xml"), "web.xml");
        deployment.addAsWebInfResource(new File(configFolder + "/jboss-web.xml"), "jboss-web.xml");

        return deployment;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy