示例#1
0
  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.
        }
      }
    }
  }
示例#2
0
 @Override
 public String getVersionIdentifier(ReadableArchive archive) {
   String versionIdentifierValue = null;
   try {
     WebXmlParser webXmlParser = getWebXmlParser(archive);
     versionIdentifierValue = webXmlParser.getVersionIdentifier();
   } catch (XMLStreamException e) {
     logger.log(Level.SEVERE, e.getMessage());
   } catch (IOException e) {
     logger.log(Level.SEVERE, e.getMessage());
   }
   return versionIdentifierValue;
 }
示例#3
0
  protected void configureLoaderAttributes(
      WebappClassLoader cloader, WebXmlParser webXmlParser, File base) {

    boolean delegate = webXmlParser.isDelegate();
    cloader.setDelegate(delegate);
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("WebModule[" + base + "]: Setting delegate to " + delegate);
    }

    String extraClassPath = webXmlParser.getExtraClassPath();
    if (extraClassPath != null) {
      // Parse the extra classpath into its ':' and ';' separated
      // components. Ignore ':' as a separator if it is preceded by
      // '\'
      String[] pathElements = extraClassPath.split(";|((?<!\\\\):)");
      for (String path : pathElements) {
        path = path.replace("\\:", ":");
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("WarHandler[" + base + "]: Adding " + path + " to the classpath");
        }

        try {
          URL url = new URL(path);
          cloader.addRepository(path);
        } catch (MalformedURLException mue1) {
          // Not a URL, interpret as file
          File file = new File(path);
          // START GlassFish 904
          if (!file.isAbsolute()) {
            // Resolve relative extra class path to the
            // context's docroot
            file = new File(base.getPath(), path);
          }
          // END GlassFish 904

          try {
            URL url = file.toURI().toURL();
            cloader.addRepository(url.toString());
          } catch (MalformedURLException mue2) {
            String msg = rb.getString(CLASSPATH_ERROR);
            Object[] params = {path};
            msg = MessageFormat.format(msg, params);
            logger.log(Level.SEVERE, msg, mue2);
          }
        }
      }
    }
  }