protected void configureLoaderProperties( WebappClassLoader cloader, WebXmlParser webXmlParser, File base) { cloader.setUseMyFaces(webXmlParser.isUseBundledJSF()); File libDir = new File(base, "WEB-INF/lib"); if (libDir.exists()) { int baseFileLen = base.getPath().length(); final boolean ignoreHiddenJarFiles = webXmlParser.isIgnoreHiddenJarFiles(); for (File file : libDir.listFiles( new FileFilter() { @Override public boolean accept(File pathname) { String fileName = pathname.getName(); return ((fileName.endsWith(".jar") || fileName.endsWith(".zip")) && (!ignoreHiddenJarFiles || !fileName.startsWith("."))); } })) { try { if (file.isDirectory()) { // support exploded jar file cloader.addRepository("WEB-INF/lib/" + file.getName() + "/", file); } else { cloader.addJar(file.getPath().substring(baseFileLen), new JarFile(file), file); cloader.closeJARs(true); } } catch (Exception e) { // Catch and ignore any exception in case the JAR file // is empty. } } } }
ContextXmlParser(File contextXmlFile) throws XMLStreamException, IOException { if (contextXmlFile.exists()) { try (InputStream is = new FileInputStream(contextXmlFile)) { init(is); } } }
/** * Returns the classpath URIs for this archive. * * @param archive file * @return classpath URIs for this archive */ @Override public List<URI> getClassPathURIs(ReadableArchive archive) { List<URI> uris = super.getClassPathURIs(archive); try { File archiveFile = new File(archive.getURI()); if (archiveFile.exists() && archiveFile.isDirectory()) { uris.add(new URI(archive.getURI().toString() + "WEB-INF/classes/")); File webInf = new File(archiveFile, "WEB-INF"); File webInfLib = new File(webInf, "lib"); if (webInfLib.exists()) { uris.addAll(ASClassLoaderUtil.getLibDirectoryJarURIs(webInfLib)); } } } catch (Exception e) { logger.log(Level.WARNING, e.getMessage(), e); } return uris; }
protected void configureContextXmlAttribute( WebappClassLoader cloader, File base, DeploymentContext dc) throws XMLStreamException, IOException { boolean consistent = true; Boolean value = null; File warContextXml = new File(base.getAbsolutePath(), WAR_CONTEXT_XML); if (warContextXml.exists()) { ContextXmlParser parser = new ContextXmlParser(warContextXml); value = parser.getClearReferencesStatic(); } if (value == null) { Boolean domainCRS = null; File defaultContextXml = new File(serverEnvironment.getInstanceRoot(), DEFAULT_CONTEXT_XML); if (defaultContextXml.exists()) { ContextXmlParser parser = new ContextXmlParser(defaultContextXml); domainCRS = parser.getClearReferencesStatic(); } List<Boolean> csrs = new ArrayList<Boolean>(); HttpService httpService = serverConfig.getHttpService(); DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class); String vsIDs = params.virtualservers; List<String> vsList = StringUtils.parseStringList(vsIDs, " ,"); if (httpService != null && vsList != null && !vsList.isEmpty()) { for (VirtualServer vsBean : httpService.getVirtualServer()) { if (vsList.contains(vsBean.getId())) { Boolean csr = null; Property prop = vsBean.getProperty("contextXmlDefault"); if (prop != null) { File contextXml = new File(serverEnvironment.getInstanceRoot(), prop.getValue()); if (contextXml.exists()) { // vs context.xml ContextXmlParser parser = new ContextXmlParser(contextXml); csr = parser.getClearReferencesStatic(); } } if (csr == null) { csr = domainCRS; } csrs.add(csr); } } // check that it is consistent for (Boolean b : csrs) { if (b != null) { if (value != null && !b.equals(value)) { consistent = false; break; } value = b; } } } } if (consistent) { if (value != null) { cloader.setClearReferencesStatic(value); } } else if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, INCONSISTENT_CLEAR_REFERENCE_STATIC); } }