Search in sources :

Example 1 with JMXContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext in project camel by apache.

the class ManagedSEDeployableContainer method deploy.

@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    LOGGER.info("Deploying " + archive.getName());
    // First of all clear the list of previously materialized deployments - otherwise the class path would grow indefinitely
    materializedFiles.clear();
    // Create a new classpath
    classpathDependencies.clear();
    if (ClassPath.isRepresentedBy(archive)) {
        for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) {
            Asset asset = child.getAsset();
            if (asset instanceof ArchiveAsset) {
                Archive<?> assetArchive = ((ArchiveAsset) asset).getArchive();
                if (ClassPathDirectory.isRepresentedBy(assetArchive)) {
                    materializeDirectory(assetArchive);
                } else {
                    materializeArchive(assetArchive);
                }
            }
        }
    } else {
        materializeArchive(archive);
    }
    Properties systemProperties = getSystemProperties(archive);
    readJarFilesFromDirectory();
    addTestResourcesDirectory(systemProperties);
    List<String> processCommand = buildProcessCommand(systemProperties);
    logExecutedCommand(processCommand);
    // Launch the process
    final ProcessBuilder processBuilder = new ProcessBuilder(processCommand);
    String path = systemProperties.getProperty("container.user.dir");
    if (path != null) {
        processBuilder.directory(new File(path));
    }
    processBuilder.environment().put("JAVA_HOME", new File(System.getProperty(SYSPROP_KEY_JAVA_HOME)).getAbsolutePath());
    processBuilder.redirectErrorStream(true);
    processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
    processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
    try {
        process = processBuilder.start();
    } catch (final IOException e) {
        throw new DeploymentException("Could not start process", e);
    }
    int finalWaitTime = debugModeEnabled ? (3 * waitTime) : waitTime;
    // Wait for socket connection
    if (!isServerStarted(host, port, finalWaitTime)) {
        throw new DeploymentException("Child JVM process failed to start within " + finalWaitTime + " seconds.");
    }
    if (!isJMXTestRunnerMBeanRegistered(host, port, finalWaitTime)) {
        throw new DeploymentException("JMXTestRunnerMBean not registered within " + finalWaitTime + " seconds.");
    }
    ProtocolMetaData protocolMetaData = new ProtocolMetaData();
    protocolMetaData.addContext(new JMXContext(host, port));
    return protocolMetaData;
}
Also used : Node(org.jboss.shrinkwrap.api.Node) ArchiveAsset(org.jboss.shrinkwrap.api.asset.ArchiveAsset) IOException(java.io.IOException) Properties(java.util.Properties) ClassAsset(org.jboss.shrinkwrap.api.asset.ClassAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) ArchiveAsset(org.jboss.shrinkwrap.api.asset.ArchiveAsset) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData) File(java.io.File) JMXContext(org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)1 JMXContext (org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext)1 ProtocolMetaData (org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)1 Node (org.jboss.shrinkwrap.api.Node)1 ArchiveAsset (org.jboss.shrinkwrap.api.asset.ArchiveAsset)1 Asset (org.jboss.shrinkwrap.api.asset.Asset)1 ClassAsset (org.jboss.shrinkwrap.api.asset.ClassAsset)1