use of org.wildfly.extension.camel.service.CamelContextActivationService 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();
}
Aggregations