Search in sources :

Example 1 with CamelContextActivationService

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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) CamelContextActivationService(org.wildfly.extension.camel.service.CamelContextActivationService) SpringCamelContextBootstrap(org.wildfly.extension.camel.SpringCamelContextBootstrap) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 SpringCamelContextBootstrap (org.wildfly.extension.camel.SpringCamelContextBootstrap)1 CamelContextActivationService (org.wildfly.extension.camel.service.CamelContextActivationService)1