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());
}
}
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));
}
}
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);
}
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));
}
Aggregations