Search in sources :

Example 6 with StandaloneCommandBuilder

use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.

the class StartMojo method createStandaloneCommandBuilder.

private CommandBuilder createStandaloneCommandBuilder(final Path jbossHome) throws MojoExecutionException {
    final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(jbossHome).setJavaHome(javaHome).addModuleDirs(modulesPath.getModulePaths());
    // Set the JVM options
    if (Utils.isNotNullOrEmpty(javaOpts)) {
        commandBuilder.setJavaOptions(javaOpts);
    }
    if (serverConfig != null) {
        commandBuilder.setServerConfiguration(serverConfig);
    }
    if (propertiesFile != null) {
        commandBuilder.setPropertiesFile(propertiesFile);
    }
    if (serverArgs != null) {
        commandBuilder.addServerArguments(serverArgs);
    }
    final Path javaHomePath = (this.javaHome == null ? Paths.get(System.getProperty("java.home")) : Paths.get(this.javaHome));
    if (Environment.isModularJvm(javaHomePath)) {
        commandBuilder.addJavaOptions(Environment.getModularJvmArguments());
    }
    // Print some server information
    final Log log = getLog();
    log.info("JAVA_HOME : " + commandBuilder.getJavaHome());
    log.info("JBOSS_HOME: " + commandBuilder.getWildFlyHome());
    log.info("JAVA_OPTS : " + Utils.toString(commandBuilder.getJavaOptions(), " "));
    try {
        addUsers(commandBuilder.getWildFlyHome(), commandBuilder.getJavaHome());
    } catch (IOException e) {
        throw new MojoExecutionException("Failed to add users", e);
    }
    return commandBuilder;
}
Also used : Path(java.nio.file.Path) StandaloneCommandBuilder(org.wildfly.core.launcher.StandaloneCommandBuilder) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Log(org.apache.maven.plugin.logging.Log) IOException(java.io.IOException)

Example 7 with StandaloneCommandBuilder

use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.

the class StandaloneDeploymentManagerIT method startServer.

@BeforeClass
public static void startServer() throws Exception {
    boolean ok = false;
    try {
        client = Environment.createClient();
        if (ServerHelper.isDomainRunning(client) || ServerHelper.isStandaloneRunning(client)) {
            Assert.fail("A WildFly server is already running: " + ServerHelper.getContainerDescription(client));
        }
        final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(Environment.WILDFLY_HOME);
        process = Launcher.of(commandBuilder).launch();
        consoleConsomer = ConsoleConsumer.start(process, System.out);
        ServerHelper.waitForStandalone(client, Environment.TIMEOUT);
        ok = true;
    } finally {
        if (!ok) {
            final Process p = process;
            final ModelControllerClient c = client;
            process = null;
            client = null;
            try {
                ProcessHelper.destroyProcess(p);
            } finally {
                safeClose(c);
            }
        }
    }
}
Also used : StandaloneCommandBuilder(org.wildfly.core.launcher.StandaloneCommandBuilder) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) BeforeClass(org.junit.BeforeClass)

Example 8 with StandaloneCommandBuilder

use of org.wildfly.core.launcher.StandaloneCommandBuilder in project wildfly-maven-plugin by wildfly.

the class StandaloneTestServer method start.

@Override
public void start() {
    if (STARTED.compareAndSet(false, true)) {
        try {
            final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(TestEnvironment.WILDFLY_HOME).setBindAddressHint("management", TestEnvironment.HOSTNAME).addJavaOption("-Djboss.management.http.port=" + TestEnvironment.PORT);
            final Process process = Launcher.of(commandBuilder).setRedirectErrorStream(true).launch();
            consoleConsumer = ConsoleConsumer.start(process, System.out);
            shutdownThread = ProcessHelper.addShutdownHook(process);
            client = ModelControllerClient.Factory.create(TestEnvironment.HOSTNAME, TestEnvironment.PORT);
            currentProcess = process;
            ServerHelper.waitForStandalone(process, client, TestEnvironment.TIMEOUT);
            deploymentManager = DeploymentManager.Factory.create(client);
        } catch (Throwable t) {
            try {
                throw new RuntimeException("Failed to start server", t);
            } finally {
                STARTED.set(false);
                cleanUp();
            }
        }
    }
}
Also used : StandaloneCommandBuilder(org.wildfly.core.launcher.StandaloneCommandBuilder)

Aggregations

StandaloneCommandBuilder (org.wildfly.core.launcher.StandaloneCommandBuilder)8 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 Log (org.apache.maven.plugin.logging.Log)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 SocketException (java.net.SocketException)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 JsonObject (javax.json.JsonObject)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 CompositeOperationBuilder (org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder)1 ModelNode (org.jboss.dmr.ModelNode)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 MavenArtifactRepositoryManager (org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager)1 BeforeClass (org.junit.BeforeClass)1