Search in sources :

Example 1 with ContextCreateHandlerRegistry

use of org.wildfly.extension.camel.ContextCreateHandlerRegistry in project wildfly-camel by wildfly-extras.

the class PackageScanResolverProcessor method undeploy.

public void undeploy(DeploymentUnit depUnit) {
    ContextCreateHandlerRegistry createHandlerRegistry = depUnit.getAttachment(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_KEY);
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    if (createHandlerRegistry != null) {
        ModuleClassLoader classLoader = depUnit.getAttachment(Attachments.MODULE).getClassLoader();
        createHandlerRegistry.removeContextCreateHandler(classLoader, depSettings.getClassResolverAssociationHandler());
    }
}
Also used : ContextCreateHandlerRegistry(org.wildfly.extension.camel.ContextCreateHandlerRegistry) ModuleClassLoader(org.jboss.modules.ModuleClassLoader)

Example 2 with ContextCreateHandlerRegistry

use of org.wildfly.extension.camel.ContextCreateHandlerRegistry in project wildfly-camel by wildfly-extras.

the class CamelContextRegistryService method start.

@Override
public void start(StartContext startContext) throws StartException {
    ContextCreateHandlerRegistry handlerRegistry = injectedHandlerRegistry.getValue();
    ServiceRegistry serviceRegistry = startContext.getController().getServiceContainer();
    contextRegistry = new CamelContextRegistryImpl(handlerRegistry, serviceRegistry, startContext.getChildTarget());
    // Register the service with gravia
    Runtime runtime = injectedRuntime.getValue();
    ModuleContext syscontext = runtime.getModuleContext();
    registration = syscontext.registerService(CamelContextRegistry.class, contextRegistry, null);
    for (final String name : subsystemState.getContextDefinitionNames()) {
        createCamelContext(name, subsystemState.getContextDefinition(name));
    }
}
Also used : Runtime(org.jboss.gravia.runtime.Runtime) ContextCreateHandlerRegistry(org.wildfly.extension.camel.ContextCreateHandlerRegistry) ModuleContext(org.jboss.gravia.runtime.ModuleContext) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) CamelContextRegistry(org.wildfly.extension.camel.CamelContextRegistry) MutableCamelContextRegistry(org.wildfly.extension.camel.service.CamelContextRegistryService.MutableCamelContextRegistry)

Example 3 with ContextCreateHandlerRegistry

use of org.wildfly.extension.camel.ContextCreateHandlerRegistry in project wildfly-camel by wildfly-extras.

the class PackageScanResolverProcessor method deploy.

public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    // Camel disabled
    if (!depSettings.isEnabled()) {
        return;
    }
    ContextCreateHandlerRegistry createHandlerRegistry = depUnit.getAttachment(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_KEY);
    ModuleClassLoader moduleClassLoader = depUnit.getAttachment(Attachments.MODULE).getClassLoader();
    ContextCreateHandler contextCreateHandler = new PackageScanClassResolverAssociationHandler(moduleClassLoader);
    depSettings.setClassResolverAssociationHandler(contextCreateHandler);
    createHandlerRegistry.addContextCreateHandler(moduleClassLoader, contextCreateHandler);
}
Also used : PackageScanClassResolverAssociationHandler(org.wildfly.extension.camel.handler.PackageScanClassResolverAssociationHandler) ContextCreateHandlerRegistry(org.wildfly.extension.camel.ContextCreateHandlerRegistry) ContextCreateHandler(org.wildfly.extension.camel.ContextCreateHandler) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 4 with ContextCreateHandlerRegistry

use of org.wildfly.extension.camel.ContextCreateHandlerRegistry in project wildfly-camel by wildfly-extras.

the class ContextCreateHandlerRegistryIntegrationTest method testHandlerRegistry.

@Test
public void testHandlerRegistry() throws Exception {
    ContextCreateHandlerRegistry handlerRegistry = ServiceLocator.getRequiredService(ContextCreateHandlerRegistry.class);
    ModuleLoader moduleLoader = Module.getCallerModuleLoader();
    deployer.deploy(CAMEL_TEST_JAR);
    Module module = moduleLoader.loadModule(ModuleIdentifier.create("deployment.camel-test.jar"));
    ClassLoader classLoader = module.getClassLoader();
    // Registry should have classloader key after deploy
    Assert.assertTrue(handlerRegistry.containsKey(classLoader));
    deployer.undeploy(CAMEL_TEST_JAR);
    // Registry should have removed classloader key after undeploy
    Assert.assertFalse("Expected registry to not contain key: " + classLoader, handlerRegistry.containsKey(classLoader));
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ContextCreateHandlerRegistry(org.wildfly.extension.camel.ContextCreateHandlerRegistry) Module(org.jboss.modules.Module) Test(org.junit.Test)

Aggregations

ContextCreateHandlerRegistry (org.wildfly.extension.camel.ContextCreateHandlerRegistry)4 ModuleClassLoader (org.jboss.modules.ModuleClassLoader)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ModuleContext (org.jboss.gravia.runtime.ModuleContext)1 Runtime (org.jboss.gravia.runtime.Runtime)1 Module (org.jboss.modules.Module)1 ModuleLoader (org.jboss.modules.ModuleLoader)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 Test (org.junit.Test)1 CamelContextRegistry (org.wildfly.extension.camel.CamelContextRegistry)1 ContextCreateHandler (org.wildfly.extension.camel.ContextCreateHandler)1 PackageScanClassResolverAssociationHandler (org.wildfly.extension.camel.handler.PackageScanClassResolverAssociationHandler)1 MutableCamelContextRegistry (org.wildfly.extension.camel.service.CamelContextRegistryService.MutableCamelContextRegistry)1