Пример #1
0
  protected WebXmlParser getWebXmlParser(ReadableArchive archive)
      throws XMLStreamException, IOException {

    WebXmlParser webXmlParser = null;
    boolean hasWSLDD = archive.exists(WEBLOGIC_XML);
    File runtimeAltDDFile =
        archive.getArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, File.class);
    if (runtimeAltDDFile != null
        && "glassfish-web.xml".equals(runtimeAltDDFile.getPath())
        && runtimeAltDDFile.isFile()) {
      webXmlParser = new GlassFishWebXmlParser(archive);
    } else if (!gfDDOverWLSDD && !ignoreWLSDD && hasWSLDD) {
      webXmlParser = new WeblogicXmlParser(archive);
    } else if (archive.exists(GLASSFISH_WEB_XML)) {
      webXmlParser = new GlassFishWebXmlParser(archive);
    } else if (archive.exists(SUN_WEB_XML)) {
      webXmlParser = new SunWebXmlParser(archive);
    } else if (gfDDOverWLSDD && !ignoreWLSDD && hasWSLDD) {
      webXmlParser = new WeblogicXmlParser(archive);
    } else { // default
      if (gfDDOverWLSDD || ignoreWLSDD) {
        webXmlParser = new GlassFishWebXmlParser(archive);
      } else {
        webXmlParser = new WeblogicXmlParser(archive);
      }
    }
    return webXmlParser;
  }
Пример #2
0
  @Override
  public String toString() {
    String lineSep = System.getProperty("line.separator");
    StringBuilder result = new StringBuilder();
    result.append(this.getClass().getName() + ": " + lineSep);
    result.append("  isJWS: " + isJWS);
    result.append("  archive file: " + appClientArchive.getURI().toASCIIString() + lineSep);
    result.append("  archive type: " + appClientArchive.getClass().getName() + lineSep);
    result.append("  archivist type: " + appClientArchivist.getClass().getName() + lineSep);
    result.append("  main class to be run: " + mainClassNameToRun + lineSep);
    result.append("  temporary archive directory: " + appClientArchive.getURI() + lineSep);
    result.append("  class loader type: " + getClassLoader().getClass().getName() + lineSep);

    return result.toString();
  }
Пример #3
0
 /**
  * If WEB-INF/sun-jaxws.xml exists and is not processed in EJB context , then it returns true.
  *
  * @param annInfo
  * @return
  */
 private boolean isJaxwsRIDeployment(AnnotationInfo annInfo) {
   boolean riDeployment = false;
   AnnotatedElementHandler annCtx = annInfo.getProcessingContext().getHandler();
   try {
     ReadableArchive moduleArchive = annInfo.getProcessingContext().getArchive();
     if (moduleArchive != null
         && moduleArchive.exists("WEB-INF/sun-jaxws.xml")
         && !((Class) annInfo.getAnnotatedElement()).isInterface()
         && ((annCtx instanceof WebBundleContext) || (annCtx instanceof WebComponentContext))) {
       riDeployment = true;
     }
   } catch (Exception e) {
     // continue, processing
   }
   return riDeployment;
 }
Пример #4
0
    WebXmlParser(ReadableArchive archive) throws XMLStreamException, IOException {

      if (archive.exists(getXmlFileName())) {
        try (InputStream is = archive.getEntry(getXmlFileName())) {
          init(is);
        } catch (Throwable t) {
          String msg =
              localStrings.getLocalString(
                  "web.deployment.exception_parsing_webxml",
                  "Error in parsing {0} for archive [{1}]: {2}",
                  getXmlFileName(),
                  archive.getURI(),
                  t.getMessage());
          throw new RuntimeException(msg);
        }
      }
    }
Пример #5
0
 /**
  * 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;
 }
Пример #6
0
  /**
   * This scanner will scan the archiveFile for annotation processing.
   *
   * @param readableArchive the archive to process
   * @param webBundleDesc existing bundle descriptor to add to
   * @param classLoader classloader to load archive classes with.
   */
  @Override
  public void process(
      ReadableArchive readableArchive,
      WebBundleDescriptor webBundleDesc,
      ClassLoader classLoader,
      Parser parser)
      throws IOException {

    this.archiveFile = new File(readableArchive.getURI());
    this.classLoader = classLoader;
    setParser(parser);

    if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) {
      AnnotationUtils.getLogger().fine("archiveFile is " + archiveFile);
      AnnotationUtils.getLogger().fine("webBundle is " + webBundleDesc);
      AnnotationUtils.getLogger().fine("classLoader is " + classLoader);
    }

    if (!archiveFile.isDirectory()) {
      // on client side
      return;
    }

    if (isScanOtherLibraries()) {
      addLibraryJars(webBundleDesc, readableArchive);
      calculateResults();
      return;
    }

    File webinf = new File(archiveFile, "WEB-INF");

    if (webBundleDesc instanceof WebFragmentDescriptor) {
      WebFragmentDescriptor webFragmentDesc = (WebFragmentDescriptor) webBundleDesc;
      File lib = new File(webinf, "lib");
      if (lib.exists()) {
        File jarFile = new File(lib, webFragmentDesc.getJarName());
        if (jarFile.exists()) {
          // support exploded jar file
          if (jarFile.isDirectory()) {
            addScanDirectory(jarFile);
          } else {
            addScanJar(jarFile);
          }
        }
      }
    } else {
      File classes = new File(webinf, "classes");
      if (classes.exists()) {
        addScanDirectory(classes);
      }
      scanXmlDefinedClassesIfNecessary(webBundleDesc);
    }
    calculateResults();
  }
Пример #7
0
 public void postConstruct() {
   Archivist archivist =
       archivistFactory.getArchivist(ModuleType.CAR.toString(), getClassLoader());
   if (!(archivist instanceof AppClientArchivist)) {
     throw new IllegalArgumentException(
         "expected an app client module but "
             + appClientArchive.getURI().toASCIIString()
             + " was recognized by "
             + archivist.getClass().getName());
   }
   appClientArchivist = (AppClientArchivist) archivist;
   setDescriptor(appClientArchivist.getDescriptor());
 }
Пример #8
0
 /**
  * Closes the instance of AppClientInfo, deleting any temporary directory created and closing the
  * archive.
  *
  * @throws IOException in case of error closing the archive
  */
 @Override
 protected void close() throws IOException {
   try {
     // XXX Mitesh helping to update this
     //            if (puAppInfo != null) {
     //                new PersistenceUnitLoaderImpl().unload(puAppInfo);
     //                puAppInfo = null;
     //            }
     if (appClientArchive != null) {
       appClientArchive.close();
     }
     ClassLoader classLoader = getClassLoader();
     if (classLoader != null && classLoader instanceof ASURLClassLoader) {
       ((ASURLClassLoader) classLoader).done();
     }
   } finally {
     if (deleteAppClientDir()) {
       if (appClientArchive != null) {
         appClientArchive.delete();
       }
     }
     appClientArchive = null;
   }
 }
Пример #9
0
  /**
   * Reads persistence.xml from spec defined pu roots of an ear. Spec defined pu roots are - (1)Non
   * component jars in root of ear (2)jars in lib of ear
   */
  @Override
  public Object open(
      Archivist main, ReadableArchive earArchive, final RootDeploymentDescriptor descriptor)
      throws IOException, SAXParseException {

    if (deplLogger.isLoggable(Level.FINE)) {
      deplLogger.logp(
          Level.FINE,
          "EarArchivist",
          "readPersistenceDeploymentDescriptors",
          "archive = {0}",
          earArchive.getURI());
    }

    Map<String, ReadableArchive> probablePersitenceArchives =
        new HashMap<String, ReadableArchive>();
    try {
      if (!(descriptor instanceof Application)) {
        return null;
      }
      final Application app = Application.class.cast(descriptor);

      // TODO: need to compute includeRoot, not hard-code it, in the next invocation. The flag
      // should be set to true if operating in v2 compatibility mode false otherwise.
      // Check with Hong how to get hold of the flag here?
      EARBasedPersistenceHelper.addLibraryAndTopLevelCandidates(
          earArchive, app, true /* includeRoot */, probablePersitenceArchives);

      for (Map.Entry<String, ReadableArchive> pathToArchiveEntry :
          probablePersitenceArchives.entrySet()) {
        readPersistenceDeploymentDescriptor(
            main, pathToArchiveEntry.getValue(), pathToArchiveEntry.getKey(), descriptor);
      }
    } finally {
      for (Archive subArchive : probablePersitenceArchives.values()) {
        subArchive.close();
      }
    }
    return null;
  }