org.jboss.msc.service.ServiceActivator Java Examples

The following examples show how to use org.jboss.msc.service.ServiceActivator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SuspendResumeTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
public static void deploy() throws Exception {
    //ServerDeploymentHelper helper = new ServerDeploymentHelper(managementClient.getControllerClient());
    JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    war.addPackage(SuspendResumeHandler.class.getPackage());
    war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
        new RuntimePermission("createXnioWorker"),
        new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
        new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    //helper.deploy(WEB_SUSPEND_JAR, war.as(ZipExporter.class).exportAsInputStream());
    serverController.deploy(war, WEB_SUSPEND_JAR);

}
 
Example #2
Source File: ServiceActivatorDeploymentUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static JavaArchive createServiceActivatorDeploymentArchive(String name, Properties properties) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.trivial.prop", "write"),
            new PropertyPermission("service", "write")
    ), "permissions.xml");
    if (properties != null && properties.size() > 0) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<Object, Object> prop : properties.entrySet()) {
            sb.append(prop.getKey());
            sb.append('=');
            sb.append(prop.getValue());
            sb.append("\n");
        }
        archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
        archive.addAsResource(new StringAsset(sb.toString()), ServiceActivatorDeployment.PROPERTIES_RESOURCE);
    }
    return archive;
}
 
Example #3
Source File: ServiceActivatorDeploymentUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static JavaArchive createServiceActivatorDeploymentArchive(String name, Map<String, String> properties) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.trivial.prop", "write"),
            new PropertyPermission("service", "write"),
            new PropertyPermission("rbac", "write")
    ), "permissions.xml");
    if (properties != null && properties.size() > 0) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> prop : properties.entrySet()) {
            sb.append(prop.getKey());
            sb.append('=');
            sb.append(prop.getValue());
            sb.append("\n");
        }
        archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
        archive.addAsResource(new StringAsset(sb.toString()), ServiceActivatorDeployment.PROPERTIES_RESOURCE);
    }
    return archive;
}
 
Example #4
Source File: StartSuspendedTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void startContainer() throws Exception {
    // Start the server
    container.startSuspended();
    managementClient = container.getClient();

    //ServerDeploymentHelper helper = new ServerDeploymentHelper(managementClient.getControllerClient());
    JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    war.addPackage(SuspendResumeHandler.class.getPackage());
    war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
        new RuntimePermission("createXnioWorker"),
        new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
        new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    //helper.deploy(WEB_SUSPEND_JAR, war.as(ZipExporter.class).exportAsInputStream());
    serverController.deploy(war, WEB_SUSPEND_JAR);
}
 
Example #5
Source File: DeploymentScenario.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void deployToAffectedServerGroup(DomainClient masterClient, Class<? extends ServiceActivator> clazz,
                                         String qualifier) throws Exception {
    File deployment = createDeployment(clazz, qualifier);

    ModelNode composite = createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    ModelNode steps = composite.get(STEPS);
    ModelNode step1 = steps.add();
    step1.set(createAddOperation(PathAddress.pathAddress(DEPLOYMENT, deployment.getName())));
    String url = deployment.toURI().toURL().toString();
    ModelNode content = new ModelNode();
    content.get("url").set(url);
    step1.get(CONTENT).add(content);
    ModelNode sg = steps.add();
    sg.set(createAddOperation(
            PathAddress.pathAddress(SERVER_GROUP, "deployment-group-affected").append(DEPLOYMENT, deployment.getName())));
    sg.get(ENABLED).set(true);
    DomainTestUtils.executeForResult(composite, masterClient);
    deployed.add(qualifier);
}
 
Example #6
Source File: DeploymentScenario.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private File createDeployment(Class<? extends ServiceActivator> clazz, String qualifier) throws Exception{
    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    File tmpDir = new File(tmpRoot, this.getClass().getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    tmpDirs.add(tmpDir);
    String deploymentName = getDeploymentName(qualifier);
    File deployment = new File(tmpDir, deploymentName);
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, deploymentName);
    archive.addClasses(clazz, ServiceActivatorBaseDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, clazz);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.broken.fail", "read"),
            new PropertyPermission("test.deployment.prop.one", "write"),
            new PropertyPermission("test.deployment.prop.two", "write"),
            new PropertyPermission("test.deployment.prop.three", "write"),
            new PropertyPermission("test.deployment.prop.four", "write")
    ), "permissions.xml");
    archive.as(ZipExporter.class).exportTo(deployment);
    return deployment;
}
 
Example #7
Source File: DeploymentOverlayScenario.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void deployToAffectedServerGroup(DomainClient masterClient, Class<? extends ServiceActivator> clazz) throws Exception {
    File deployment = createDeployment(clazz);

    ModelNode composite = createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    ModelNode steps = composite.get(STEPS);
    ModelNode step1 = steps.add();
    step1.set(createAddOperation(PathAddress.pathAddress(DEPLOYMENT, deployment.getName())));
    String url = deployment.toURI().toURL().toString();
    ModelNode content = new ModelNode();
    content.get("url").set(url);
    step1.get(CONTENT).add(content);
    ModelNode sg = steps.add();
    sg.set(createAddOperation(
            PathAddress.pathAddress(SERVER_GROUP, "overlay-group-affected").append(DEPLOYMENT, deployment.getName())));
    sg.get(ENABLED).set(true);
    DomainTestUtils.executeForResult(composite, masterClient);
    deployed = true;
}
 
Example #8
Source File: DeploymentOverlayScenario.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private File createDeployment(Class<? extends ServiceActivator> clazz) throws Exception{
    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    File tmpDir = new File(tmpRoot, this.getClass().getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    tmpDirs.add(tmpDir);
    String deploymentName = DEPLOYMENT_NAME;
    File deployment = new File(tmpDir, deploymentName);
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, deploymentName);
    archive.addClasses(clazz, ServiceActivatorBaseDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, clazz);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.broken.fail", "read"),
            new PropertyPermission("test.deployment.prop.one", "write"),
            new PropertyPermission("test.deployment.prop.two", "write"),
            new PropertyPermission("test.deployment.prop.three", "write"),
            new PropertyPermission("test.deployment.prop.four", "write"),
            new PropertyPermission("test.overlay.prop.one", "write"),
            new PropertyPermission("test.overlay.prop.two", "write"),
            new PropertyPermission("test.overlay.prop.three", "write"),
            new PropertyPermission("test.overlay.prop.four", "write")
    ), "permissions.xml");
    archive.as(ZipExporter.class).exportTo(deployment);
    return deployment;
}
 
Example #9
Source File: ServiceActivatorDeploymentUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void createServiceActivatorDeployment(File destination, String objectName, Class mbeanClass) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addClass(mbeanClass);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    StringBuilder sb = new StringBuilder();
    sb.append(ServiceActivatorDeployment.MBEAN_CLASS_NAME);
    sb.append('=');
    sb.append(mbeanClass.getName());
    sb.append("\n");
    sb.append(ServiceActivatorDeployment.MBEAN_OBJECT_NAME);
    sb.append('=');
    sb.append(objectName);
    sb.append("\n");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            getMBeanPermission(mbeanClass, objectName, "registerMBean"),
            getMBeanPermission(mbeanClass, objectName, "unregisterMBean"),
            new MBeanTrustPermission("register")),
            "permissions.xml");
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc,org.jboss.as.jmx,org.jboss.as.server,org.jboss.as.controller\n"), "MANIFEST.MF");
    archive.addAsResource(new StringAsset(sb.toString()), ServiceActivatorDeployment.PROPERTIES_RESOURCE);
    archive.as(ZipExporter.class).exportTo(destination);
}
 
Example #10
Source File: DeploymentRolloutFailureTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@BeforeClass
public static void setupDomain() throws Exception {
    testSupport = DomainTestSuite.createSupport(DeploymentRolloutFailureTestCase.class.getSimpleName());
    masterClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();

    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    tmpDir = new File(tmpRoot, DeploymentRolloutFailureTestCase.class.getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    deployment = new File(tmpDir, BROKEN_DEPLOYMENT);
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, BROKEN_DEPLOYMENT);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.broken.fail", "read")),
            "permissions.xml");
    archive.as(ZipExporter.class).exportTo(deployment);
}
 
Example #11
Source File: ModuleResourceRootPathsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void deployTestWar() throws Exception {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test-archive.war");
    archive.addClasses(ModulesServiceActivator.DEPENDENCIES);
    archive.addAsServiceProviderAndClasses(ServiceActivator.class, ModulesServiceActivator.class)
            .addAsManifestResource(new StringAsset("Dependencies: io.undertow.core," + MODULE_RESOURCE_MODULE_NAME
                    + "," + ABSOLUTE_RESOURCE_MODULE_NAME + "\n"), "MANIFEST.MF");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(ModulesServiceActivator.DEFAULT_PERMISSIONS), "permissions.xml");
    final ServerDeploymentHelper helper = new ServerDeploymentHelper(client.getControllerClient());
    helper.deploy("test-archive.war", archive.as(ZipExporter.class).exportAsInputStream());
}
 
Example #12
Source File: ServiceActivatorArchiveImpl.java    From thorntail with Apache License 2.0 5 votes vote down vote up
private String path() {
    if (getArchive().getName().endsWith(".war")) {
        return "WEB-INF/classes/META-INF/services/" + ServiceActivator.class.getName();
    }

    return "META-INF/services/" + ServiceActivator.class.getName();
}
 
Example #13
Source File: InterdependentDeploymentTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JavaArchive getDependentDeployment(String name, Class clazz, String... dependencies) {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name);
    archive.addClass(clazz);
    archive.addAsServiceProvider(ServiceActivator.class, clazz);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");

    String propFileContent = "interrelated-" + name + ".jar=" + name + '\n';
    archive.addAsResource(new StringAsset(propFileContent), name + ".properties");
    archive.addAsResource(new StringAsset(getJBossDeploymentStructure(dependencies)), "META-INF/jboss-deployment-structure.xml");

    return archive;
}
 
Example #14
Source File: AbstractLoggingTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static JavaArchive createDeployment(final Class<? extends ServiceActivator> serviceActivator,
                                    final Map<String, String> manifestEntries, final Class<?>... classes) {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, DEPLOYMENT_NAME);
    archive.addClasses(classes);
    archive.addAsServiceProviderAndClasses(ServiceActivator.class, serviceActivator);
    boolean addDeps = true;
    final StringBuilder manifest = new StringBuilder();
    for (String key : manifestEntries.keySet()) {
        if ("Dependencies".equals(key)) {
            addDeps = false;
            manifest.append(key)
                    .append(": ")
                    .append("io.undertow.core,")
                    .append(manifestEntries.get(key))
                    .append('\n');
        } else {
            manifest.append(key)
                    .append(": ")
                    .append(manifestEntries.get(key))
                    .append('\n');
        }
    }
    if (addDeps) {
        manifest.append("Dependencies: io.undertow.core");
    }
    archive.addAsResource(new StringAsset(manifest.toString()), "META-INF/MANIFEST.MF");
    return addPermissions(archive,
            new SocketPermission(TestSuiteEnvironment.getHttpAddress()+ ":0", "listen,resolve"));
}
 
Example #15
Source File: SuspendOnSoftKillTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startContainer(int suspendTimeout) throws Exception {

        suspendTimeout = suspendTimeout < 1 ? suspendTimeout : TimeoutUtil.adjust(suspendTimeout);

        jbossArgs = System.getProperty("jboss.args");
        String newArgs = jbossArgs == null ? "" : jbossArgs;
        newArgs += " -D[Standalone] -Dorg.wildfly.sigterm.suspend.timeout=" + suspendTimeout;
        System.setProperty("jboss.args", newArgs);

        if (File.pathSeparatorChar == ':'){
            processUtil = new UnixProcessUtil();
        } else {
            processUtil = new WindowsProcessUtil();
        }

        // Start the server
        serverController.start();

        // If there's already the deployment there from a previous test, remove it
        try {
            serverController.undeploy(WEB_SUSPEND_JAR);
        } catch (Exception ignored) {
            // assume it wasn't deployed. if it was we'll fail below
        }

        JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
        war.addPackage(SuspendResumeHandler.class.getPackage());
        war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
        war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
        war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                new RuntimePermission("createXnioWorker"),
                new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                new SocketPermission("*", "accept,resolve")
        ), "permissions.xml");
        serverController.deploy(war, WEB_SUSPEND_JAR);
    }
 
Example #16
Source File: SuspendOnShutdownTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void deployApplication() throws Exception {
    final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR)
            .addPackage(SuspendResumeHandler.class.getPackage())
            .addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class)
            .addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF")
            .addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                    new RuntimePermission("createXnioWorker"),
                    new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                    new SocketPermission("*", "accept,resolve")
            ), "permissions.xml");

    serverController.deploy(jar, WEB_SUSPEND_JAR);
    managementClient = serverController.getClient();
}
 
Example #17
Source File: DeploymentRollbackFailureTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@BeforeClass
public static void setupDomain() throws Exception {
    testSupport = DomainTestSuite.createSupport(DeploymentRollbackFailureTestCase.class.getSimpleName());
    masterClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();

    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    tmpDir = new File(tmpRoot, DeploymentRollbackFailureTestCase.class.getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    deployment = new File(tmpDir, BROKEN_DEPLOYMENT);
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, BROKEN_DEPLOYMENT);
    archive.addClass(ServiceActivatorDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, ServiceActivatorDeployment.class);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
    archive.as(ZipExporter.class).exportTo(deployment);
}
 
Example #18
Source File: CompositeOperationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void createDeployment() throws Exception {
    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    tmpDir = new File(tmpRoot, CompositeOperationTestCase.class.getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    deployment = new File(tmpDir, DEPLOYMENT_NAME);

    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, DEPLOYMENT_NAME)
            .addClasses(SlowServiceActivator.class, TimeoutUtil.class)
            .addAsManifestResource(new StringAsset("Dependencies: org.wildfly.security.elytron-private\n"), "MANIFEST.MF")
            .addAsServiceProvider(ServiceActivator.class, SlowServiceActivator.class)
            .addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "permissions.xml");

    archive.as(ZipExporter.class).exportTo(deployment);
}
 
Example #19
Source File: HostSuspendResumeTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR)
            .addPackage(SuspendResumeHandler.class.getPackage())
            .addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class)
            .addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"),
                    "META-INF/MANIFEST.MF")
            .addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
                    new ReflectPermission("suppressAccessChecks"),
                    new RuntimePermission("createXnioWorker"),
                    new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
                    new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
}
 
Example #20
Source File: DomainSuspendResumeTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static JavaArchive createDeployment() throws Exception {
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    jar.addPackage(SuspendResumeHandler.class.getPackage());
    jar.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    jar.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    jar.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new ReflectPermission("suppressAccessChecks"),
            new RuntimePermission("createXnioWorker"),
            new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
            new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    return jar;
}
 
Example #21
Source File: DomainGracefulShutdownTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static JavaArchive createDeployment() throws Exception {
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    jar.addPackage(SuspendResumeHandler.class.getPackage());
    jar.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    jar.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    jar.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new ReflectPermission("suppressAccessChecks"),
            new RuntimePermission("createXnioWorker"),
            new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
            new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    return jar;
}
 
Example #22
Source File: ServiceActivatorDependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add the dependencies if the deployment contains a service activator loader entry.
 * @param phaseContext the deployment unit context
 * @throws DeploymentUnitProcessingException
 */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final ResourceRoot deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT);
    final ModuleSpecification moduleSpecification = phaseContext.getDeploymentUnit().getAttachment(
            Attachments.MODULE_SPECIFICATION);
    if(deploymentRoot == null)
        return;
    final ServicesAttachment servicesAttachments = phaseContext.getDeploymentUnit().getAttachment(Attachments.SERVICES);
    if(servicesAttachments != null && !servicesAttachments.getServiceImplementations(ServiceActivator.class.getName()).isEmpty()) {
        moduleSpecification.addSystemDependency(MSC_DEP);
    }
}
 
Example #23
Source File: ApplicationServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
ApplicationServerService(final List<ServiceActivator> extraServices, final Bootstrap.Configuration configuration,
                         final ControlledProcessState processState, final SuspendController suspendController) {
    this.extraServices = extraServices;
    this.configuration = configuration;
    runningModeControl = configuration.getRunningModeControl();
    startTime = configuration.getStartTime();
    standalone = configuration.getServerEnvironment().isStandalone();
    selfContained = configuration.getServerEnvironment().isSelfContained();
    this.processState = processState;
    this.suspendController = suspendController;
}
 
Example #24
Source File: ServerStartTask.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ServerStartTask(final String hostControllerName, final String serverName, final int portOffset, final int initialOperationID,
                       final List<ServiceActivator> startServices, final List<ModelNode> updates, final Map<String, String> launchProperties,
                       boolean suspend) {
    assert serverName != null && serverName.length() > 0  : "Server name \"" + serverName + "\" is invalid; cannot be null or blank";
    assert hostControllerName != null && hostControllerName.length() > 0 : "Host Controller name \"" + hostControllerName + "\" is invalid; cannot be null or blank";

    this.serverName = serverName;
    this.portOffset = portOffset;
    this.startServices = startServices;
    this.updates = updates;
    this.initialOperationID = initialOperationID;
    this.hostControllerName = hostControllerName;
    this.suspend = suspend;

    this.home = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", null);
    String serverBaseDir = WildFlySecurityManager.getPropertyPrivileged("jboss.domain.servers.dir", null) + File.separatorChar + serverName;
    properties.setProperty(ServerEnvironment.SERVER_NAME, serverName);
    properties.setProperty(ServerEnvironment.HOME_DIR, home);
    properties.setProperty(ServerEnvironment.SERVER_BASE_DIR, serverBaseDir);
    properties.setProperty(ServerEnvironment.CONTROLLER_TEMP_DIR, WildFlySecurityManager.getPropertyPrivileged("jboss.domain.temp.dir", null));
    properties.setProperty(ServerEnvironment.DOMAIN_BASE_DIR, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.DOMAIN_BASE_DIR, null));
    properties.setProperty(ServerEnvironment.DOMAIN_CONFIG_DIR, WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.DOMAIN_CONFIG_DIR, null));

    // Provide any other properties that standalone Main.determineEnvironment() would read
    // from system properties and pass in to ServerEnvironment
    setPropertyIfFound(launchProperties, ServerEnvironment.JAVA_EXT_DIRS, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.QUALIFIED_HOST_NAME, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.HOST_NAME, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.NODE_NAME, properties);
    @SuppressWarnings("deprecation")
    String deprecated = ServerEnvironment.MODULES_DIR;
    setPropertyIfFound(launchProperties, deprecated, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.BUNDLES_DIR, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.SERVER_DATA_DIR, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.SERVER_CONTENT_DIR, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.SERVER_LOG_DIR, properties);
    setPropertyIfFound(launchProperties, ServerEnvironment.SERVER_TEMP_DIR, properties);
}
 
Example #25
Source File: Main.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * The main method.
 *
 * @param args the command-line arguments
 */
public static void main(String[] args) {
    try {
        if (java.util.logging.LogManager.getLogManager().getClass().getName().equals("org.jboss.logmanager.LogManager")) {
            // Make sure our original stdio is properly captured.
            try {
                Class.forName(org.jboss.logmanager.handlers.ConsoleHandler.class.getName(), true, org.jboss.logmanager.handlers.ConsoleHandler.class.getClassLoader());
            } catch (Throwable ignored) {
            }
            // Install JBoss Stdio to avoid any nasty crosstalk, after command line arguments are processed.
            StdioContext.install();
            final StdioContext context = StdioContext.create(
                    new NullInputStream(),
                    new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stdout"), org.jboss.logmanager.Level.INFO),
                    new LoggingOutputStream(org.jboss.logmanager.Logger.getLogger("stderr"), org.jboss.logmanager.Level.ERROR)
            );
            StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(context));
        }

        Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule("org.jboss.vfs"));
        ServerEnvironmentWrapper serverEnvironmentWrapper = determineEnvironment(args, WildFlySecurityManager.getSystemPropertiesPrivileged(),
                WildFlySecurityManager.getSystemEnvironmentPrivileged(), ServerEnvironment.LaunchType.STANDALONE,
                Module.getStartTime());
        if (serverEnvironmentWrapper.getServerEnvironment() == null) {
            if (serverEnvironmentWrapper.getServerEnvironmentStatus() == ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR) {
                abort(null);
            } else {
                SystemExiter.safeAbort();
            }
        } else {
            final Bootstrap bootstrap = Bootstrap.Factory.newInstance();
            final Bootstrap.Configuration configuration = new Bootstrap.Configuration(serverEnvironmentWrapper.getServerEnvironment());
            configuration.setModuleLoader(Module.getBootModuleLoader());
            bootstrap.bootstrap(configuration, Collections.<ServiceActivator>emptyList()).get();
            return;
        }
    } catch (Throwable t) {
        abort(t);
    }
}
 
Example #26
Source File: BootstrapImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public AsyncFuture<ServiceContainer> bootstrap(final Configuration configuration, final List<ServiceActivator> extraServices) {
    assert !shutdownHook.down;
    try {
        return internalBootstrap(configuration, extraServices);
    } catch (RuntimeException | Error e) {
        // Clean up our container
        shutdownHook.shutdown(true);
        throw e;
    }
}
 
Example #27
Source File: BootstrapImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public AsyncFuture<ServiceContainer> startup(Configuration configuration, List<ServiceActivator> extraServices) {
    try {
        ServiceContainer container = bootstrap(configuration, extraServices).get();
        ServiceController<?> controller = container.getRequiredService(Services.JBOSS_AS);
        return (AsyncFuture<ServiceContainer>) controller.getValue();
    } catch (Exception ex) {
        shutdownHook.shutdown(true);
        throw ServerLogger.ROOT_LOGGER.cannotStartServer(ex);
    }
}
 
Example #28
Source File: AbstractLoggingProfilesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void deploy(final String name, final String profileName, final boolean useServiceActivator) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name);
    if (useServiceActivator) {
        archive.addClasses(LoggingServiceActivator.DEPENDENCIES);
        archive.addAsServiceProviderAndClasses(ServiceActivator.class, serviceActivator);
    }
    archive.addAsResource(new StringAsset("Dependencies: io.undertow.core\nLogging-Profile: " + profileName), "META-INF/MANIFEST.MF");
    addPermissions(archive);
    deploy(archive, name);
}
 
Example #29
Source File: InfinispanCustomizer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
private ServiceActivator createActivatorIfSatisfied(Instance instance, String cacheContainer, CacheActivator.Type type) {
    if (instance.isUnsatisfied()) {
        MESSAGES.skippingCacheActivation(cacheContainer);
        return null;
    } else {
        return new CacheActivator(cacheContainer, type);
    }
}
 
Example #30
Source File: WildFlySwarmDeploymentAppender.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
protected Archive<?> buildArchive() {
    return ShrinkWrap.create(JavaArchive.class)
            .addPackages(
                    true,
                    "org.wildfly.swarm.arquillian.adapter.resources")
            .addClass(WildFlySwarmRemoteExtension.class)
            .addClass(WildFlySwarmCommandService.class)
            .addClass(ServiceRegistryServiceActivator.class)
            .addAsServiceProvider(RemoteLoadableExtension.class, WildFlySwarmRemoteExtension.class)
            .addAsServiceProvider(ServiceActivator.class, ServiceRegistryServiceActivator.class)
            .addAsServiceProvider(ExtensionLoader.class, RemoteExtensionLoader.class);
}