use of org.wildfly.extension.camel.SpringCamelContextBootstrap in project wildfly-camel by wildfly-extras.
the class CamelContextActivationProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
if (!depSettings.isEnabled()) {
return;
}
String runtimeName = depUnit.getName();
ServiceTarget serviceTarget = phaseContext.getServiceTarget();
ServiceName camelActivationServiceName = depUnit.getServiceName().append(CAMEL_CONTEXT_ACTIVATION_SERVICE_NAME.append(runtimeName));
List<SpringCamelContextBootstrap> camelctxBootstrapList = depUnit.getAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY);
CamelContextActivationService activationService = new CamelContextActivationService(camelctxBootstrapList, runtimeName);
ServiceBuilder builder = serviceTarget.addService(camelActivationServiceName, activationService);
// Ensure all camel contexts in the deployment are started before constructing servlets etc
depUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, camelActivationServiceName);
// Add JNDI binding dependencies to CamelContextActivationService
for (SpringCamelContextBootstrap bootstrap : camelctxBootstrapList) {
for (String jndiName : bootstrap.getJndiNames()) {
if (jndiName.startsWith("${")) {
// Don't add the binding if it appears to be a Spring property placeholder value
// these can't be resolved before refresh() has been called on the ApplicationContext
LOGGER.warn("Skipping JNDI binding dependency for property placeholder value: {}", jndiName);
} else {
LOGGER.debug("Add CamelContextActivationService JNDI binding dependency for {}", jndiName);
installBindingDependency(builder, jndiName);
}
}
}
builder.install();
}
use of org.wildfly.extension.camel.SpringCamelContextBootstrap in project wildfly-camel by wildfly-extras.
the class SpringContextBindingDependenciesTest method testJndiBindingDiscovery.
@Test
public void testJndiBindingDiscovery() {
URL resourceUrl = getClass().getResource("/jndi-bindings-camel-context.xml");
SpringCamelContextBootstrap bootstrap = new SpringCamelContextBootstrap(resourceUrl, SpringContextBindingDependenciesTest.class.getClassLoader());
String[] bindings = { "java:jboss/datasources/ExampleDS", "java:/jboss/UserTransaction", "java:/spring/binding/test", "java:/TransactionManager" };
Assert.assertEquals(Arrays.asList(bindings), bootstrap.getJndiNames());
}
use of org.wildfly.extension.camel.SpringCamelContextBootstrap in project wildfly-camel by wildfly-extras.
the class CamelContextBootstrapProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
final Module module = depUnit.getAttachment(Attachments.MODULE);
final String runtimeName = depUnit.getName();
// Add the camel context bootstraps to the deployment
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
for (URL contextURL : depSettings.getCamelContextUrls()) {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(module.getClassLoader());
SpringCamelContextBootstrap bootstrap = new SpringCamelContextBootstrap(contextURL, module.getClassLoader());
depUnit.addToAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY, bootstrap);
} catch (Exception ex) {
throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
}
Aggregations