Package com.sun.enterprise.deployment.util

Examples of com.sun.enterprise.deployment.util.ModuleDescriptor


                        || (directory &&
                            (name.endsWith("_war") ||
                             name.endsWith(".war"))) ) {
                    String contextRoot =
                    uri.substring(uri.lastIndexOf('/')+1, uri.lastIndexOf('.'));
                    ModuleDescriptor md = new ModuleDescriptor();
                    md.setArchiveUri(uri);
                    md.setModuleType(ModuleType.WAR);
                    md.setContextRoot(contextRoot);
                    app.addModule(md);
                }
                //Section EE.8.4.2.1.b
                else if ( (!directory && name.endsWith(".rar"))
                            || (directory &&
                                (name.endsWith("_rar") ||
                                 name.endsWith(".rar"))) ) {
                    ModuleDescriptor md = new ModuleDescriptor();
                    md.setArchiveUri(uri);
                    md.setModuleType(ModuleType.RAR);
                    app.addModule(md);
                }
                else if ( (!directory && name.endsWith(".jar"))
                            || (directory &&
                                (name.endsWith("_jar") ||
                                 name.endsWith(".jar"))) ) {
                    try {
                        //Section EE.8.4.2.1.d.i
                        AppClientArchivist acArchivist = new AppClientArchivist();
                        if (acArchivist.hasStandardDeploymentDescriptor(subArchive)
                            || acArchivist.hasRuntimeDeploymentDescriptor(subArchive)
                            || acArchivist.getMainClassName(subArchive.getManifest()) != null) {

                            ModuleDescriptor md = new ModuleDescriptor();
                            md.setArchiveUri(uri);
                            md.setModuleType(ModuleType.CAR);
                            md.setManifest(subArchive.getManifest());
                            app.addModule(md);
                            continue;
                        }

                        //Section EE.8.4.2.1.d.ii
                        EjbArchivist ejbArchivist  = new EjbArchivist();
                        if (ejbArchivist.hasStandardDeploymentDescriptor(subArchive)
                            || ejbArchivist.hasRuntimeDeploymentDescriptor(subArchive)) {

                            ModuleDescriptor md = new ModuleDescriptor();
                            md.setArchiveUri(uri);
                            md.setModuleType(ModuleType.EJB);
                            app.addModule(md);
                            continue;
                        }
                    } catch (IOException ex) {
                        _logger.log(Level.WARNING, ex.getMessage());
                    }

                    //Still could not decide between an ejb and a library
                    unknowns.add(subArchive);
                } else {
                    //ignored
                }
            } finally {
                if (subArchive != null) {
                    try {
                        subArchive.close();
                    } catch (IOException ioe) {
                        _logger.log(Level.WARNING, localStrings.getLocalString("enterprise.deployment.errorClosingSubArch", "Error closing subarchive {0}", new Object[] {subModule.getAbsolutePath()}), ioe);
                    }
                }
            }
        }

        if (unknowns.size() > 0) {
            EjbComponentAnnotationDetector detector =
                    new EjbComponentAnnotationDetector();
            for (int i = 0; i < unknowns.size(); i++) {
                File jarFile = new File(unknowns.get(i).getArchiveUri());
                try {
                    if (detector.hasAnnotationInArchive(unknowns.get(i))) {
                        String uri = deriveArchiveUri(appRoot, jarFile, directory);
                        //Section EE.8.4.2.1.d.ii, alas EJB
                        ModuleDescriptor md = new ModuleDescriptor();
                        md.setArchiveUri(uri);
                        md.setModuleType(ModuleType.EJB);
                        app.addModule(md);
                    }
                } catch (IOException ex) {
                    _logger.log(Level.WARNING, ex.getMessage());
                }
View Full Code Here


        if (type==null) {
            return null;
        }
        Set moduleSet = new OrderedSet();
        for (Iterator bundles = getModules();bundles.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
            if (type.equals(aModule.getModuleType())) {
    moduleSet.add(aModule);
      }
  }
  return moduleSet.iterator();
    }
View Full Code Here

     * or null if not found.
     *
     */
    public ModuleDescriptor getModuleDescriptorByUri(String uri) {
        for (Iterator itr = getModules();itr.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
            if (aModule.getArchiveUri().equals(uri)) {
                return aModule;
            }
        }
        return null;
    }   
View Full Code Here

     * @return a bundle descriptor in this application identified by uri
     * or null if not found.
     *
     */
    public Descriptor getModuleByUri(String uri) {
        ModuleDescriptor md = getModuleDescriptorByUri(uri);
        if (md!=null) {
            return md.getDescriptor();
        }
        return null;
    }
View Full Code Here

     * @param type the module type
     * @param uri the module path in the application archive
     */
    public Descriptor getModuleByTypeAndUri(ModuleType type, String uri) {
        for (Iterator itr = getModules();itr.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
            if (aModule.getModuleType().equals(type)) {
                if (aModule.getArchiveUri().equals(uri)) {
                    return aModule.getDescriptor();
                }
            }
        }
        return null;
    }
View Full Code Here

     * @return the set of BundleDescriptor objects for extension modules
     */
    public Set getExtnBundleDescriptors() {
        Set bundleSet = new OrderedSet();
        for (Iterator bundles = getModules();bundles.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
            if (XModuleType.isExtensionModule(aModule.getModuleType())) {
                if (aModule.getDescriptor()!=null) {
                    bundleSet.add(aModule.getDescriptor());                   
                } else {
                    DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
                }
            }
        }
        return bundleSet; 
    }
View Full Code Here

    // context-roots -- please note that node.getApplication(null) has
    // already done all the time-consuming work.  The getXXXX methods
    // simply return a reference.  So performance isn't an issue.
               
                for (Iterator modules = app.getModules(); modules.hasNext();) {
                    ModuleDescriptor md = (ModuleDescriptor) modules.next();
                    if (md.getModuleType().equals(ModuleType.EJB)) {
                        ejbModules.add(md.getArchiveUri());
                    } else
                    if (md.getModuleType().equals(ModuleType.WAR)) {
                        warModules.add(md.getArchiveUri());
                    } else
                    if (md.getModuleType().equals(ModuleType.CAR)) {
                        clientModules.add(md.getArchiveUri());
                    } else
                    if (md.getModuleType().equals(ModuleType.RAR)) {
                        rarModules.add(md.getArchiveUri());
                    }                         
                }

    setContextRoots(app);
            } finally {
View Full Code Here

           
            contextRoots = new HashSet();
           
            for(Iterator it = warModules.iterator(); it.hasNext(); ) {
               
                ModuleDescriptor md = app.getModuleDescriptorByUri((String) it.next());
                String cr = md.getContextRoot();               
               
                if(contextRoots.add(cr) == false) {
                    // this means that there is more than one web-module
                    // in the Application with the same context-root
                   
View Full Code Here

     *
     * @param the web bundle descriptor
     */
    public void accept(WebBundleDescriptor descriptor) {
        bundleDescriptor = descriptor;
        ModuleDescriptor md = bundleDescriptor.getModuleDescriptor( );
        // Fix for bug: 4837982
        String uri = md.getArchiveUri( );
        if( ( md.getContextRoot() == null )
         && ( ( uri != null ) && (uri.length() != 0) ) )
         {
            // Case 1: If there is a unix style file separator
            // Example a/b/xxx.war
            int beginIndex = uri.lastIndexOf( "/" );

            // Case 2: If there is a windows style file separator
            // Example a\b\xxx.war
            if( beginIndex < 0 ) {
                beginIndex = uri.lastIndexOf( File.separator );
            }

            // Case 3: No File separator
            // Example xxx.war
            if( beginIndex < 0 ) {
                beginIndex = 0;
            } else {
                // If there is a separator, we need to increment to get the
                // string past the last separator
                beginIndex++;
            }

            // If the context-root is not specified, AppServer will use
            // the file name with the extension removed as the context
            // root
           
            // NOTE: We can safely assume that the file extension is ".war"
            // So no need to do extra checks
            int endIndex = uri.lastIndexOf( ".war" );
            if (endIndex==-1) {
                return;
            }
            String warFileName = uri.substring( beginIndex, endIndex );
            md.setContextRoot( warFileName );
            if( DOLUtils.getDefaultLogger().isLoggable(Level.INFO) ) {
                DOLUtils.getDefaultLogger().info(
                    "Context Root is not provided by the user, Using ["
                    + warFileName + "] as Context Root" );
            }
View Full Code Here

  if (element.getQName().equals(RuntimeTagNames.WEB_URI)) {
      currentWebUri=value;
  } else
  if (element.getQName().equals(RuntimeTagNames.CONTEXT_ROOT)) {
      if (currentWebUri!=null) {
    ModuleDescriptor md = descriptor.getModuleDescriptorByUri(currentWebUri);
                if (md==null) {
                    throw new RuntimeException("No bundle in application with uri " + currentWebUri);
                }
    currentWebUri=null;
    if (md.getModuleType().equals(ModuleType.WAR)) {
        md.setContextRoot(value);
    } else {
        throw new RuntimeException(currentWebUri + " uri does not point to a web bundle");
    }
      } else {
    throw new RuntimeException("No uri provided for this context-root " + value);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.util.ModuleDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.