use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class JaccEarDeploymentProcessor method deploy.
/**
* {@inheritDoc}
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
AbstractSecurityDeployer<?> deployer = null;
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
deployer = new EarSecurityDeployer();
JaccService<?> service = deployer.deploy(deploymentUnit);
if (service != null) {
final ServiceName jaccServiceName = deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
ServiceBuilder<?> builder = serviceTarget.addService(jaccServiceName, service);
if (deploymentUnit.getParent() != null) {
// add dependency to parent policy
final DeploymentUnit parentDU = deploymentUnit.getParent();
builder.addDependency(parentDU.getServiceName().append(JaccService.SERVICE_NAME), PolicyConfiguration.class, service.getParentPolicyInjector());
}
builder.setInitialMode(Mode.ACTIVE).install();
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnit 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.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.
the class CamelContextDescriptorsProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
final String runtimeName = depUnit.getName();
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
if (depSettings.isDisabledByJbossAll() || !depSettings.isDeploymentValid() || runtimeName.endsWith(".ear")) {
return;
}
try {
if (runtimeName.endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX)) {
URL fileURL = depUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS).asFileURL();
addConditionally(depUnit, fileURL);
} else {
VirtualFileFilter filter = new VirtualFileFilter() {
public boolean accepts(VirtualFile child) {
return child.isFile() && child.getName().endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX);
}
};
VirtualFile rootFile = depUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
for (VirtualFile vfile : rootFile.getChildrenRecursively(filter)) {
addConditionally(depUnit, vfile.asFileURL());
}
}
if (!depSettings.getCamelContextUrls().isEmpty()) {
LOGGER.info("Camel context descriptors found");
}
} catch (IOException ex) {
throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.
the class CDIBeanArchiveProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
List<DeploymentUnit> subDeployments = depUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
// Return if camel disabled or not a CDI deployment
if (!depSettings.isEnabled() || !WeldDeploymentMarker.isPartOfWeldDeployment(depUnit)) {
return;
}
// Return if we're not an EAR deployment with 1 or more sub-deployments
if (depUnit.getName().endsWith(".ear") && subDeployments.isEmpty()) {
return;
}
// Make sure external bean archives from the camel-cdi module are visible to sub deployments
List<BeanDeploymentArchiveImpl> deploymentArchives = depUnit.getAttachmentList(WeldAttachments.ADDITIONAL_BEAN_DEPLOYMENT_MODULES);
BeanDeploymentArchiveImpl rootArchive = depUnit.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);
for (BeanDeploymentArchiveImpl bda : deploymentArchives) {
if (bda.getBeanArchiveType().equals(BeanDeploymentArchiveImpl.BeanArchiveType.EXTERNAL)) {
for (BeanDeploymentArchive topLevelBda : rootArchive.getBeanDeploymentArchives()) {
bda.addBeanDeploymentArchive(topLevelBda);
}
}
for (DeploymentUnit subDepUnit : subDeployments) {
BeanDeploymentArchive subBda = subDepUnit.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);
bda.addBeanDeploymentArchive(subBda);
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.
the class CamelDeploymentSettingsProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
if (depSettings == null) {
depSettings = new CamelDeploymentSettings();
depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, depSettings);
} else {
if (depSettings.isDisabledByJbossAll()) {
// Camel is explicitly disabled in jboss-all.xml
return;
}
}
depSettings.setDeploymentValid(isDeploymentValid(depUnit));
depSettings.setCamelAnnotationPresent(hasCamelActivationAnnotations(depUnit));
synchronized (deploymentSettingsMap) {
deploymentSettingsMap.put(getDeploymentName(depUnit), depSettings);
}
final DeploymentUnit parent = depUnit.getParent();
if (parent != null) {
final String parentDeploymentName = getDeploymentName(parent);
CamelDeploymentSettings parentDepSettings = getDeploymentSettings(parentDeploymentName);
if (parentDepSettings != null) {
parentDepSettings.addChild(depSettings);
}
}
}
Aggregations