Refine search
private static VirtualFile getDescriptor(final VirtualFile deploymentRoot, final String descriptorName) { // Locate the descriptor final VirtualFile descriptor; // EJB 3.1 FR 20.4 Enterprise Beans Packaged in a .war if (isWar(deploymentRoot)) { // it's a .war file, so look for the ejb-jar.xml in WEB-INF descriptor = deploymentRoot.getChild(WEB_INF + "/" + descriptorName); } else if (deploymentRoot.getName().toLowerCase(Locale.ENGLISH).endsWith(JAR_FILE_EXTENSION)) { descriptor = deploymentRoot.getChild(META_INF + "/" + descriptorName); } else { // neither a .jar nor a .war. Return return null; } if (descriptor == null || !descriptor.exists()) { // no descriptor found, nothing to do! return null; } return descriptor; }
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; }
if (root == null || root.exists() == false) return; try { VirtualFile metainf = root.getChild("META-INF"); if (metainf.exists()) beans.addAll(metainf.getChildren(filter)); VirtualFile webinf = root.getChild("WEB-INF"); if (webinf.exists()) { beans.addAll(webinf.getChildren(filter)); metainf = webinf.getChild("classes/META-INF"); if (metainf.exists()) beans.addAll(metainf.getChildren(filter));
@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; } } }
deploymentUnit.putAttachment(WeldAttachments.CLASSES_RESOURCE_ROOT, resourceRoot); } else { VirtualFile beansXml = resourceRoot.getRoot().getChild(META_INF_BEANS_XML); if (beansXml.exists() && beansXml.isFile()) { WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", beansXml.toString()); beanArchiveMetadata.put(resourceRoot, new ExplicitBeanArchiveMetadata(beansXml, resourceRoot, parseBeansXml(beansXml, parser, deploymentUnit), false)); final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild(WEB_INF_BEANS_XML); final boolean rootBeansXmlPresent = rootBeansXml.exists() && rootBeansXml.isFile(); beansXml = classesRoot.getRoot().getChild(META_INF_BEANS_XML); final boolean beansXmlPresent = beansXml != null && beansXml.exists() && beansXml.isFile(); final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild(META_INF_BEANS_XML); if (rootBeansXml.exists() && rootBeansXml.isFile()) { WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", rootBeansXml.toString());
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; }
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); } }
private void processExternalMounts(DeploymentUnit deploymentUnit, VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { VirtualFile mounts = deploymentRoot.getChild(WEB_INF_EXTERNAL_MOUNTS); if(!mounts.exists()) { return; } try (InputStream data = mounts.openStream()) { String contents = FileUtils.readFile(data); String[] lines = contents.split("\n"); for(String line : lines) { String trimmed = line; int commentIndex = trimmed.indexOf("#"); if(commentIndex > -1) { trimmed = trimmed.substring(0, commentIndex); } trimmed = trimmed.trim(); if(trimmed.isEmpty()) { continue; } File path = new File(trimmed); if(path.exists()) { deploymentUnit.addToAttachmentList(UndertowAttachments.EXTERNAL_RESOURCES, path); } else { throw UndertowLogger.ROOT_LOGGER.couldNotFindExternalPath(path); } } } catch (IOException e) { throw new RuntimeException(e); } }
final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit); for (final ResourceRoot resourceRoot : resourceRoots) { final VirtualFile webInfFacesConfig = resourceRoot.getRoot().getChild(WEB_INF_FACES_CONFIG); if (webInfFacesConfig.exists()) { ret.add(webInfFacesConfig); final VirtualFile metaInf = resourceRoot.getRoot().getChild("META-INF"); if (metaInf.exists() && metaInf.isDirectory()) { for (final VirtualFile file : metaInf.getChildren()) { if (file.getName().equals("faces-config.xml") || file.getName().endsWith(".faces-config.xml")) { if (deploymentRoot != null) { for (final String file : files) { final VirtualFile configFile = deploymentRoot.getRoot().getChild(file); if (configFile.exists()) { ret.add(configFile);
final List<ResourceRoot> entries = new ArrayList<ResourceRoot>(); final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES); if (webinfClasses.exists()) { final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null); ModuleRootMarker.mark(webInfClassesRoot); final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB); if (webinfLib.exists()) { final List<VirtualFile> archives = webinfLib.getChildren(DEFAULT_WEB_INF_LIB_FILTER); for (final VirtualFile archive : archives) {
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; }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_PROPERTIES)) { return; } final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentFile = deploymentRoot.getRoot(); final VirtualFile propertiesFile = deploymentFile.getChild(DEPLOYMENT_PROPERTIES); if (!propertiesFile.exists()) { return; } Properties properties = new Properties(); InputStream propertyFileStream = null; try { propertyFileStream = propertiesFile.openStream(); properties.load(propertyFileStream); } catch (IOException e) { throw EeLogger.ROOT_LOGGER.failedToLoadJbossProperties(e); } finally { VFSUtils.safeClose(propertyFileStream); } deploymentUnit.putAttachment(Attachments.DEPLOYMENT_PROPERTIES, properties); }
private EarMetaData handleSpecMetadata(VirtualFile deploymentFile, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException { final VirtualFile applicationXmlFile = deploymentFile.getChild(APPLICATION_XML); if (!applicationXmlFile.exists()) { return null; } InputStream inputStream = null; try { inputStream = applicationXmlFile.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(inputStream); return EarMetaDataParser.INSTANCE.parse(xmlReader, propertyReplacer); } catch (Exception e) { throw EeLogger.ROOT_LOGGER.failedToParse(e, applicationXmlFile); } finally { VFSUtils.safeClose(inputStream); } }
final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); final List<VirtualFile> testRoots = new ArrayList<VirtualFile>(); testRoots.add(deploymentRoot); testRoots.add(deploymentRoot.getChild(WEB_INF)); testRoots.add(deploymentRoot.getChild(META_INF)); for (ResourceRoot root : deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS)) { testRoots.add(root.getRoot()); testRoots.add(root.getRoot().getChild(META_INF)); testRoots.add(root.getRoot().getChild(META_INF).getChild(RESOURCES)); boolean found = false; for (final VirtualFile root : testRoots) { VirtualFile child = root.getChild(tld.getTaglibLocation()); if (child.exists()) { if (isTldFile(child)) { TldMetaData value = processTld(deploymentRoot, child, tlds, uniqueTlds); for (ResourceRoot resourceRoot : resourceRoots) { if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) { VirtualFile webFragment = resourceRoot.getRoot().getChild(META_INF); if (webFragment.exists() && webFragment.isDirectory()) { processTlds(deploymentRoot, webFragment.getChildren(), tlds, uniqueTlds); VirtualFile webInf = deploymentRoot.getChild(WEB_INF); if (webInf.exists() && webInf.isDirectory()) { for (VirtualFile file : webInf.getChildren()) { if (isTldFile(file)) {
/** * Construct a {@link VirtualJarInputStream} from a {@link VirtualFile} root * * @param root VirtualFile directory to use as the base of the virtual Jar. * @throws IOException */ public VirtualJarInputStream(VirtualFile root) throws IOException { super(VFSUtils.emptyStream()); this.root = root; final VirtualFile manifest = root.getChild(JarFile.MANIFEST_NAME); if (manifest.exists()) { entryItr.add(Collections.singleton(manifest).iterator()); this.manifest = VFSUtils.readManifest(manifest); } else { this.manifest = null; } entryItr.add(root.getChildren().iterator()); }
List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot resourceRoot : resourceRoots) { if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) { jarsSet.add(resourceRoot.getRootName()); VirtualFile overlay = resourceRoot.getRoot().getChild("META-INF/resources"); if (overlay.exists()) { overlays.add(overlay); VirtualFile sci = resourceRoot.getRoot().getChild("META-INF/services/javax.servlet.ServletContainerInitializer"); if (sci.exists()) { scis.put(resourceRoot.getRootName(), sci);
final VirtualFile virtualFile = deploymentRoot.getRoot(); final boolean appXmlPresent = deploymentRoot.getRoot().getChild("META-INF/application.xml").exists(); final EarMetaData earMetaData = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA); if (earMetaData != null) { libDir = virtualFile.getChild(libDirName); if (libDir.exists()) { List<VirtualFile> libArchives = libDir.getChildren(CHILD_ARCHIVE_FILTER); for (final VirtualFile child : libArchives) { String relativeName = child.getPathNameRelativeTo(deploymentRoot.getRoot()); MountedDeploymentOverlay overlay = overlays.get(relativeName); final MountHandle mountHandle; final VirtualFile moduleFile = virtualFile.getChild(module.getFileName()); if (!moduleFile.exists()) { throw EeLogger.ROOT_LOGGER.cannotProcessEarModule(virtualFile, module.getFileName()); final VirtualFile alternateDeploymentDescriptor = deploymentRoot.getRoot().getChild(alternativeDD); if (!alternateDeploymentDescriptor.exists()) { throw EeLogger.ROOT_LOGGER.alternateDeploymentDescriptor(alternateDeploymentDescriptor, moduleFile);