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; }
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); } }
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));
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); } }
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);
@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; } } }
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 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 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)); for (final VirtualFile root : testRoots) { VirtualFile child = root.getChild(tld.getTaglibLocation()); if (child.exists()) { if (isTldFile(child)) { TldMetaData value = processTld(deploymentRoot, child, tlds, uniqueTlds); 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)) {
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) { final VirtualFile moduleFile = virtualFile.getChild(module.getFileName()); if (!moduleFile.exists()) { throw EeLogger.ROOT_LOGGER.cannotProcessEarModule(virtualFile, module.getFileName()); if (alternativeDD != null && alternativeDD.trim().length() > 0) { final VirtualFile alternateDeploymentDescriptor = deploymentRoot.getRoot().getChild(alternativeDD); if (!alternateDeploymentDescriptor.exists()) { throw EeLogger.ROOT_LOGGER.alternateDeploymentDescriptor(alternateDeploymentDescriptor, moduleFile);
private JBossAppMetaData handleJbossMetadata(VirtualFile deploymentFile, final PropertyReplacer propertyReplacer, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final VirtualFile applicationXmlFile = deploymentFile.getChild(JBOSS_APP_XML); if (!applicationXmlFile.exists()) { //may have been in jboss-all.xml return deploymentUnit.getAttachment(AppJBossAllParser.ATTACHMENT_KEY); } InputStream inputStream = null; try { inputStream = applicationXmlFile.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(inputStream); return JBossAppMetaDataParser.INSTANCE.parse(xmlReader, propertyReplacer); } catch (Exception e) { throw EeLogger.ROOT_LOGGER.failedToParse(e, applicationXmlFile); } finally { VFSUtils.safeClose(inputStream); } }
public static IronJacamarXmlDescriptor process(VirtualFile deploymentRoot, boolean resolveProperties) throws DeploymentUnitProcessingException { IronJacamarXmlDescriptor xmlDescriptor = null; if (deploymentRoot == null || !deploymentRoot.exists()) return null; final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); VirtualFile serviceXmlFile = null; if (deploymentRootName.endsWith(".rar")) { serviceXmlFile = deploymentRoot.getChild("/META-INF/ironjacamar.xml"); } if (serviceXmlFile == null || !serviceXmlFile.exists()) return null; InputStream xmlStream = null; Activation result = null; try { xmlStream = serviceXmlFile.openStream(); IronJacamarParser ironJacamarParser = new IronJacamarParser(); ironJacamarParser.setSystemPropertiesResolved(resolveProperties); result = ironJacamarParser.parse(xmlStream); if (result != null) { xmlDescriptor = new IronJacamarXmlDescriptor(result); } else throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream); } return xmlDescriptor; }
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); }
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; } final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (ResourceRoot resourceRoot : resourceRoots) { final VirtualFile rootFile = resourceRoot.getRoot(); if (!SubDeploymentMarker.isSubDeployment(resourceRoot)) { final VirtualFile sarDescriptor = rootFile .getChild(ServiceDeploymentParsingProcessor.SERVICE_DESCRIPTOR_PATH); if (sarDescriptor.exists()) { SubDeploymentMarker.mark(resourceRoot); ModuleRootMarker.mark(resourceRoot); } } } }
@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 static ConnectorXmlDescriptor process(boolean resolveProperties, VirtualFile file, VirtualFile alternateDescriptor, String deploymentName) throws DeploymentUnitProcessingException { // Locate the descriptor final VirtualFile serviceXmlFile; if (alternateDescriptor != null) { serviceXmlFile = alternateDescriptor; } else { serviceXmlFile = file.getChild("/META-INF/ra.xml"); } InputStream xmlStream = null; Connector result = null; try { if (serviceXmlFile != null && serviceXmlFile.exists()) { xmlStream = serviceXmlFile.openStream(); RaParser raParser = new RaParser(); raParser.setSystemPropertiesResolved(resolveProperties); result = raParser.parse(xmlStream); if (result == null) throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile); } File root = file.getPhysicalFile(); URL url = root.toURI().toURL(); return new ConnectorXmlDescriptor(result, root, url, deploymentName); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream); } }
VirtualFile appclientClientXml = resourceRoot.getRoot().getChild(META_INF_APPLICATION_CLIENT_XML); if (appclientClientXml.exists()) { SubDeploymentMarker.mark(resourceRoot); ModuleRootMarker.mark(resourceRoot); VirtualFile appclientClientXml = root.getRoot().getChild(META_INF_APPLICATION_CLIENT_XML); if (appclientClientXml.exists()) { DeploymentTypeMarker.setType(DeploymentType.APPLICATION_CLIENT, deploymentUnit); } else {