use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class EjbJarDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
//cause this could come from a jboss-app.xml instead
if (deploymentRoot.getRoot().getChild("META-INF/application.xml").exists()) {
//if we have an application.xml we don't scan
return;
}
// TODO: deal with application clients, we need the manifest information
List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot resourceRoot : potentialSubDeployments) {
if (ModuleRootMarker.isModuleRoot(resourceRoot)) {
// module roots cannot be ejb jars
continue;
}
VirtualFile ejbJarFile = resourceRoot.getRoot().getChild("META-INF/ejb-jar.xml");
if (ejbJarFile.exists()) {
SubDeploymentMarker.mark(resourceRoot);
ModuleRootMarker.mark(resourceRoot);
} else {
final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
if (index != null) {
if (!index.getAnnotations(STATEFUL).isEmpty() || !index.getAnnotations(STATELESS).isEmpty() || !index.getAnnotations(MESSAGE_DRIVEN).isEmpty() || !index.getAnnotations(SINGLETON).isEmpty()) {
//this is an EJB deployment
//TODO: we need to mark EJB sub deployments so the sub deployers know they are EJB deployments
SubDeploymentMarker.mark(resourceRoot);
ModuleRootMarker.mark(resourceRoot);
}
}
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class GlobalModuleDependencyProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final List<GlobalModule> globalMods = this.globalModules;
for (final GlobalModule module : globalMods) {
final ModuleDependency dependency = new ModuleDependency(Module.getBootModuleLoader(), module.getModuleIdentifier(), false, false, module.isServices(), false);
if (module.isMetaInf()) {
dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
}
if (module.isAnnotations()) {
deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, module.getModuleIdentifier());
}
moduleSpecification.addSystemDependency(dependency);
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class EEJndiViewExtension method execute.
public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
final ModelNode applicationsNode = context.getResult().get("applications");
final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
for (final Resource.ResourceEntry entry : deploymentResource) {
final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
if (deploymentUnitServiceController != null) {
final ModelNode deploymentNode = applicationsNode.get(entry.getName());
final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
final String appName = cleanName(deploymentUnit.getName());
final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
if (appContextController != null) {
final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
try {
context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
}
}
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
if (roots != null)
for (ResourceRoot root : roots) {
if (SubDeploymentMarker.isSubDeployment(root)) {
final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
if (subDeploymentController != null) {
final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
} else {
handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class JaxrsScanningProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
return;
}
final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final Map<ModuleIdentifier, ResteasyDeploymentData> deploymentData;
if (deploymentUnit.getParent() == null) {
deploymentData = Collections.synchronizedMap(new HashMap<ModuleIdentifier, ResteasyDeploymentData>());
deploymentUnit.putAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA, deploymentData);
} else {
deploymentData = parent.getAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA);
}
final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
ResteasyDeploymentData resteasyDeploymentData = new ResteasyDeploymentData();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
try {
if (warMetaData == null) {
resteasyDeploymentData.setScanAll(true);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
deploymentData.put(moduleIdentifier, resteasyDeploymentData);
} else {
scanWebDeployment(deploymentUnit, warMetaData.getMergedJBossWebMetaData(), module.getClassLoader(), resteasyDeploymentData);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
}
deploymentUnit.putAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA, resteasyDeploymentData);
List<String> rootRestClasses = new ArrayList<>(resteasyDeploymentData.getScannedResourceClasses());
Collections.sort(rootRestClasses);
for (String cls : rootRestClasses) {
addManagement(deploymentUnit, cls);
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
}
use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.
the class JaxrsSpringProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
return;
}
final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
deploymentUnits.add(deploymentUnit);
deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
boolean found = false;
for (DeploymentUnit unit : deploymentUnits) {
WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
continue;
}
JBossWebMetaData md = warMetaData.getMergedJBossWebMetaData();
if (md == null) {
continue;
}
if (md.getContextParams() != null) {
boolean skip = false;
for (ParamValueMetaData prop : md.getContextParams()) {
if (prop.getParamName().equals(ENABLE_PROPERTY)) {
boolean explicitEnable = Boolean.parseBoolean(prop.getParamValue());
if (explicitEnable) {
found = true;
} else {
skip = true;
}
break;
} else if (prop.getParamName().equals(DISABLE_PROPERTY) && "true".equals(prop.getParamValue())) {
skip = true;
JaxrsLogger.JAXRS_LOGGER.disablePropertyDeprecated();
break;
}
}
if (skip) {
continue;
}
}
if (md.getListeners() != null) {
for (ListenerMetaData listener : md.getListeners()) {
if (SPRING_LISTENER.equals(listener.getListenerClass())) {
found = true;
break;
}
}
}
if (md.getServlets() != null) {
for (JBossServletMetaData servlet : md.getServlets()) {
if (SPRING_SERVLET.equals(servlet.getServletClass())) {
found = true;
break;
}
}
}
if (found) {
try {
// actual close is done by the MSC service above
MountHandle mh = new MountHandle(null);
ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh);
ModuleRootMarker.mark(resourceRoot);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot);
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
return;
}
}
}
Aggregations