/** * Add all the deployment information about the given application to me. */ public void addApplication(Application application) { for (ModuleDescriptor md : application.getModules()) { addModule(md); } }
/** * Add all the deployment information about the given application to me. */ public void addApplication(Application application) { for (ModuleDescriptor md : application.getModules()) { addModule(md); } }
/** * Lookup module by uri. * * @param uri the module path in the application archive * @return a bundle descriptor in this application identified by uri * or null if not found. */ public ModuleDescriptor<BundleDescriptor> getModuleDescriptorByUri(String uri) { for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { if (aModule.getArchiveUri().equals(uri)) { return aModule; } } return null; }
/** * Lookup module by uri. * * @param uri the module path in the application archive * @return a bundle descriptor in this application identified by uri * or null if not found. */ public ModuleDescriptor<BundleDescriptor> getModuleDescriptorByUri(String uri) { for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { if (aModule.getArchiveUri().equals(uri)) { return aModule; } } return null; }
/** * if this application object is virtual, return the standalone * bundle descriptor it is wrapping otherwise return null * * @return the wrapped standalone bundle descriptor */ public BundleDescriptor getStandaloneBundleDescriptor() { if (isVirtual()) { if (getModules().size()>1) { // this is an error, the application is virtual, // which mean a wrapper for a standalone module and // it seems I have more than one module in my list... throw new IllegalStateException("Virtual application contains more than one module"); } return getModules().iterator().next().getDescriptor(); } else { return null; } }
/** * if this application object is virtual, return the standalone * bundle descriptor it is wrapping otherwise return null * * @return the wrapped standalone bundle descriptor */ public BundleDescriptor getStandaloneBundleDescriptor() { if (isVirtual()) { if (getModules().size()>1) { // this is an error, the application is virtual, // which mean a wrapper for a standalone module and // it seems I have more than one module in my list... throw new IllegalStateException("Virtual application contains more than one module"); } return getModules().iterator().next().getDescriptor(); } else { return null; } }
private String getModuleName(BundleDescriptor bundleDesc, Application app) { Set<ModuleDescriptor<BundleDescriptor>> moduleDescriptors = app.getModules(); if(moduleDescriptors != null){ for(ModuleDescriptor moduleDesc : moduleDescriptors){ if(bundleDesc.equals(moduleDesc.getDescriptor())){ return moduleDesc.getModuleName(); } } } return null; }
/** * Lookup module by uri. * * @return a bundle descriptor in this application identified by uri * or null if not found. */ public Collection<ModuleDescriptor<BundleDescriptor>> getModuleDescriptorsByType(ArchiveType type) { if (type==null) { throw new IllegalArgumentException("type cannot be null"); } LinkedList<ModuleDescriptor<BundleDescriptor>> results = new LinkedList<ModuleDescriptor<BundleDescriptor>>(); for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { if (type.equals(aModule.getModuleType())) { results.add(aModule); } } return results; }
@Override public boolean isProbablePuRootJar(String jarName) { return super.isProbablePuRootJar(jarName) && // component roots are not scanned while scanning ear. They will be handled // while scanning the component. !isComponentJar(jarName,(app.getModules())); } }
@Override public boolean isProbablePuRootJar(String jarName) { return super.isProbablePuRootJar(jarName) && // component roots are not scanned while scanning ear. They will be handled // while scanning the component. !isComponentJar(jarName,(app.getModules())); } }
/** * Lookup module by uri. * * @param uri the module path in the application archive * @return a bundle descriptor in this application identified by uri * or null if not found. */ public Collection<ModuleDescriptor<BundleDescriptor>> getModuleDescriptorsByType(XModuleType type) { if (type==null) { throw new IllegalArgumentException("type cannot be null"); } LinkedList<ModuleDescriptor<BundleDescriptor>> results = new LinkedList<ModuleDescriptor<BundleDescriptor>>(); for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { if (type.equals(aModule.getModuleType())) { results.add(aModule); } } return results; }
/** * A formatted String representing my state. */ public void print(StringBuffer toStringBuffer) { toStringBuffer.append("Application"); toStringBuffer.append("\n"); super.print(toStringBuffer); toStringBuffer.append("\n smallIcon ").append(super.getSmallIconUri()); for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { toStringBuffer.append("\n Module : "); aModule.print(toStringBuffer); } toStringBuffer.append("\n Bundles: \n"); printDescriptorSet(this.getBundleDescriptors(), toStringBuffer); toStringBuffer.append("\n roles ").append(getRoles()); toStringBuffer.append("\n RoleMapper ").append(this.getRoleMapper()); toStringBuffer.append("\n Realm ").append(realm); }
/** * @param type the module type * @param uri the module path in the application archive * @return a bundle descriptor in this application identified by * its type and uri */ public <T extends BundleDescriptor> T getModuleByTypeAndUri(Class<T> type, String uri) { for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { try { T descriptor = type.cast(aModule.getDescriptor()); if (descriptor.getModuleDescriptor().getArchiveUri().equals(uri)) { return descriptor; } } catch(ClassCastException e) { // ignore } } return null; }
/** * @param type the module type * @param uri the module path in the application archive * @return a bundle descriptor in this application identified by * its type and uri */ public <T extends BundleDescriptor> T getModuleByTypeAndUri(Class<T> type, String uri) { for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { try { T descriptor = type.cast(aModule.getDescriptor()); if (descriptor.getModuleDescriptor().getArchiveUri().equals(uri)) { return descriptor; } } catch(ClassCastException e) { // ignore } } return null; }
/** * Obtain a set of all bundle descriptors, regardless of type * * @return the set of bundle descriptors */ public Set<BundleDescriptor> getBundleDescriptors() { Set<BundleDescriptor> bundleSet = new OrderedSet<BundleDescriptor>(); for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { BundleDescriptor bundleDesc = aModule.getDescriptor(); if (bundleDesc != null) { bundleSet.add(bundleDesc); for (RootDeploymentDescriptor rd : bundleDesc.getExtensionsDescriptors()) { if (rd instanceof BundleDescriptor) { bundleSet.add((BundleDescriptor)rd); } } } else { DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri()); } } return bundleSet; }
/** * Obtain a set of all bundle descriptors, regardless of type * * @return the set of bundle descriptors */ public Set<BundleDescriptor> getBundleDescriptors() { Set<BundleDescriptor> bundleSet = new OrderedSet<BundleDescriptor>(); for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) { if (aModule.getDescriptor() != null) { bundleSet.add(aModule.getDescriptor()); } else { DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri()); } } return bundleSet; }
private Collection<ModuleDescriptor<BundleDescriptor>> getSubModuleListForEar(com.sun.enterprise.deployment.Application application, String type) { Collection<ModuleDescriptor<BundleDescriptor>> modules = new ArrayList<ModuleDescriptor<BundleDescriptor>>(); if (type == null) { modules = application.getModules(); } else if (type.equals("servlets")) { modules = application.getModuleDescriptorsByType( DOLUtils.warType()); } else if (type.equals("ejbs")) { modules = application.getModuleDescriptorsByType( DOLUtils.ejbType()); // ejb in war case Collection<ModuleDescriptor<BundleDescriptor>> webModules = application.getModuleDescriptorsByType(DOLUtils.warType()); for (ModuleDescriptor webModule : webModules) { if (webModule.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class).size() > 0) { modules.add(webModule); } } } return modules; }
/** * Perform Optional packages dependencies checking on an archive */ @Override public boolean performOptionalPkgDependenciesCheck(ReadableArchive archive) throws IOException { if (!super.performOptionalPkgDependenciesCheck(archive)) return false; // now check sub modules if (descriptor==null) { throw new IOException("Application object not set on archivist"); } boolean returnValue = true; for (ModuleDescriptor md : descriptor.getModules()) { ReadableArchive sub = archive.getSubArchive(md.getArchiveUri()); if (sub!=null) { Archivist subArchivist = archivistFactory.get().getArchivist(md.getModuleType()); if (!subArchivist.performOptionalPkgDependenciesCheck(sub)) returnValue = false; } } return returnValue; }
/** * writes an application deployment descriptors * @param the application object * @param the abstract archive */ public void write(Application application, ReadableArchive in, WritableArchive out) throws IOException { if (application.isVirtual()) { ModuleDescriptor aModule = (ModuleDescriptor) application.getModules().iterator().next(); Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType()); write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, in, out); } else { // this is a real application. // let's start by writing out all submodules deployment descriptors for (ModuleDescriptor aModule : application.getModules()) { Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType()); WritableArchive moduleArchive = out.createSubArchive(aModule.getArchiveUri()); ReadableArchive moduleArchive2 = in.getSubArchive(aModule.getArchiveUri()); write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, moduleArchive2, moduleArchive); } // now let's write the application descriptor ApplicationArchivist archivist = archivistProvider.get(); archivist.setDescriptor(application); archivist.writeDeploymentDescriptors(in, out); } }
/** * Perform Optional packages dependencies checking on an archive */ @Override public boolean performOptionalPkgDependenciesCheck(ReadableArchive archive) throws IOException { if (!super.performOptionalPkgDependenciesCheck(archive)) return false; // now check sub modules if (descriptor==null) { throw new IOException("Application object not set on archivist"); } boolean returnValue = true; for (ModuleDescriptor md : descriptor.getModules()) { ReadableArchive sub = archive.getSubArchive(md.getArchiveUri()); if (sub!=null) { Archivist subArchivist = archivistFactory.get().getPrivateArchivistFor(md.getModuleType()); if (!subArchivist.performOptionalPkgDependenciesCheck(sub)) returnValue = false; } } return returnValue; }