/** * Process a deployment for standard ra deployment files. Will parse the xml * file and attach a configuration discovered during processing. * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException */ @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final VirtualFile deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); process(deploymentRoot); }
private Set<ViewDescription> getViews() { final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final Set<ViewDescription> componentsForViewName; if (beanName != null) { componentsForViewName = applicationDescription.getComponents(beanName, typeName, deploymentRoot.getRoot()); } else { componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot()); } return componentsForViewName; }
/** * Process a deployment for jboss-beans.xml files. * Will parse the xml file and attach a configuration discovered during processing. * * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException * */ @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit unit = phaseContext.getDeploymentUnit(); final VirtualFile deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); parseDescriptors(unit, deploymentRoot); final List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot root : resourceRoots) parseDescriptors(unit, root.getRoot()); }
private void handleInfoFile(DeploymentUnit deploymentUnit, Module module) { final List<PredicatedHandler> handlerWrappers = new ArrayList<>(); ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); VirtualFile config = root.getRoot().getChild(WEB_INF); try { if (config.exists()) { handlerWrappers.addAll(PredicatedHandlersParser.parse(config.openStream(), module.getClassLoader())); } Enumeration<URL> paths = module.getClassLoader().getResources(META_INF); while (paths.hasMoreElements()) { URL path = paths.nextElement(); handlerWrappers.addAll(PredicatedHandlersParser.parse(path.openStream(), module.getClassLoader())); } } catch (IOException e) { throw new RuntimeException(e); } if (!handlerWrappers.isEmpty()) { deploymentUnit.putAttachment(PREDICATED_HANDLERS, handlerWrappers); } } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit); for (ResourceRoot resourceRoot : resourceRoots) { final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) { DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName()); break; } } }
private static WildFlyJobXmlResolver create(final ClassLoader classLoader, final List<ResourceRoot> resources) throws DeploymentUnitProcessingException { final Map<String, VirtualFile> foundJobXmlFiles = new LinkedHashMap<>(); for (ResourceRoot r : resources) { final VirtualFile root = r.getRoot(); try { addJobXmlFiles(foundJobXmlFiles, root.getChild(DEFAULT_PATH)); } catch (IOException e) { throw BatchLogger.LOGGER.errorProcessingBatchJobsDir(e); } } final WildFlyJobXmlResolver jobXmlResolver = new WildFlyJobXmlResolver(foundJobXmlFiles); // Initialize this instance jobXmlResolver.init(classLoader); return jobXmlResolver; }
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);
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories) throws DeploymentUnitProcessingException { try { final VirtualFile root = resource.getRoot(); if (resource.getExportFilters().isEmpty()) { specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()))); } else { final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true); for (final FilterSpecification filter : resource.getExportFilters()) { filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); } specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create())); } permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ))); } catch (IOException e) { throw ServerMessages.MESSAGES.failedToCreateVFSResourceLoader(resource.getRootName(), e); } }
private Set<VirtualFile> dataSources(final DeploymentUnit deploymentUnit) { final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); if (deploymentRoot == null || !deploymentRoot.exists()) { return Collections.emptySet(); } final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); if (deploymentRootName.endsWith("-ds.xml")) { return Collections.singleton(deploymentRoot); } final Set<VirtualFile> ret = new HashSet<VirtualFile>(); for (String location : LOCATIONS) { final VirtualFile loc = deploymentRoot.getChild(location); if (loc.exists()) { for (final VirtualFile file : loc.getChildren()) { if (file.getName().endsWith("-ds.xml")) { ret.add(file); } } } } return ret; }
public void resolve(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final Set<String> names = applicationDescription.resolveMessageDestination(messageDestinationName, deploymentRoot.getRoot()); if (names.isEmpty()) { error = EeLogger.ROOT_LOGGER.noMessageDestination(messageDestinationName, bindingName); return; } if (names.size() > 1) { error = EeLogger.ROOT_LOGGER.moreThanOneMessageDestination(messageDestinationName, bindingName, names); return; } resolvedLookupName = names.iterator().next(); }
private String createBeanArchiveId(ResourceRoot resourceRoot) { String beanArchiveId = getDeploymentUnitId(deploymentUnit); if (resourceRoot != null) { final VirtualFile deploymentRootResource = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); beanArchiveId += "/" + resourceRoot.getRoot().getPathNameRelativeTo(deploymentRootResource); } return beanArchiveId; } }
private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) { final AttachmentList<ResourceRoot> resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class); final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT); resourceRoots.add(root); final AttachmentList<ResourceRoot> otherResourceRoots = unit.getAttachment(RESOURCE_ROOTS); if (otherResourceRoots != null) { resourceRoots.addAll(otherResourceRoots); } for (final ResourceRoot resourceRoot : resourceRoots) { VirtualFile file = resourceRoot.getRoot().getChild(wsdlPath); if (file.exists()) return resourceRoot; } return null; }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit); for (ResourceRoot resourceRoot : resourceRoots) { final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) { DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName()); break; } } }
private URL getJBossWebServicesDescriptorURL(final ResourceRoot deploymentRoot) throws DeploymentUnitProcessingException { VirtualFile jwsdd = deploymentRoot.getRoot().getChild("WEB-INF/jboss-webservices.xml"); if (!jwsdd.exists()) { jwsdd = deploymentRoot.getRoot().getChild("META-INF/jboss-webservices.xml"); } try { return jwsdd.exists() ? jwsdd.toURL() : null; } catch (IOException e) { throw WSLogger.ROOT_LOGGER.cannotGetURLForDescriptor(e, jwsdd.getPathName()); } }
private void processDeployment(final WarMetaData warMetaData, final DeploymentUnit deploymentUnit, final ServiceTarget serviceTarget, final String deploymentName, final String hostName, final String serverInstanceName) throws DeploymentUnitProcessingException { ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot(); final Module module = deploymentUnit.getAttachment(Attachments.MODULE); if (module == null) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failedToResolveModule(deploymentUnit)); CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); ScisMetaData scisMetaData = deploymentUnit.getAttachment(ScisMetaData.ATTACHMENT_KEY);
@Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); if (!unit.hasAttachment(SingletonDeploymentDependencyProcessor.CONFIGURATION_KEY)) { VirtualFile file = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot().getChild(SINGLETON_DEPLOYMENT_DESCRIPTOR); if (file.exists()) { try { unit.putAttachment(SingletonDeploymentDependencyProcessor.CONFIGURATION_KEY, this.parse(unit, file.getPhysicalFile())); } catch (IOException e) { throw new DeploymentUnitProcessingException(e); } } } }
public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION); final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final Set<ViewDescription> componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot()); final Iterator<ViewDescription> iterator = componentsForViewName.iterator(); if (!iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.componentNotFound(typeName); } final ViewDescription description = iterator.next(); if (iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.multipleComponentsFound(typeName); } //TODO: should ComponentView also be a managed reference factory? serviceBuilder.addDependency(description.getServiceName(), ComponentView.class, new ViewManagedReferenceFactory.Injector(injector)); }
private static EjbJarMetaData parseJBossEjb3Xml(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); // Locate the descriptor final VirtualFile descriptor = getDescriptor(deploymentRoot, JBOSS_EJB3_XML); if (descriptor == null) { // no descriptor found //but there may have been an ejb-jar element in jboss-all.xml return deploymentUnit.getAttachment(EjbJarJBossAllParser.ATTACHMENT_KEY); } // get the XMLStreamReader and parse the descriptor MetaDataElementParser.DTDInfo dtdInfo = new MetaDataElementParser.DTDInfo(); InputStream stream = open(descriptor); try { XMLStreamReader reader = getXMLStreamReader(stream, descriptor, dtdInfo); final JBossEjb3MetaDataParser parser = new JBossEjb3MetaDataParser(createJbossEjbJarParsers()); final EjbJarMetaData ejbJarMetaData = parser.parse(reader, dtdInfo, JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit)); return ejbJarMetaData; } catch (XMLStreamException xmlse) { throw EjbLogger.ROOT_LOGGER.failedToParse(xmlse, JBOSS_EJB3_XML + ": " + descriptor.getPathName()); } finally { try { stream.close(); } catch (IOException ioe) { EjbLogger.DEPLOYMENT_LOGGER.failToCloseFile(ioe); } } }
private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) { final AttachmentList<ResourceRoot> resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class); final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT); resourceRoots.add(root); final AttachmentList<ResourceRoot> otherResourceRoots = unit.getAttachment(RESOURCE_ROOTS); if (otherResourceRoots != null) { resourceRoots.addAll(otherResourceRoots); } for (final ResourceRoot resourceRoot : resourceRoots) { VirtualFile file = resourceRoot.getRoot().getChild(wsdlPath); if (file.exists()) return resourceRoot; } return null; }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit); for (ResourceRoot resourceRoot : resourceRoots) { final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) { DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName()); break; } } }