protected PersistenceUnitsDescriptor readPersistenceDeploymentDescriptor(Archivist main, ReadableArchive subArchive, String puRoot, RootDeploymentDescriptor descriptor) throws IOException, SAXException { final String subArchiveURI = subArchive.getURI().getSchemeSpecificPart(); if (deplLogger.isLoggable(Level.FINE)) { deplLogger.logp(Level.FINE, "Archivist", "readPersistenceDeploymentDescriptor", "PURoot = [{0}] subArchive = {1}", new Object[]{puRoot, subArchiveURI}); } if (descriptor.getExtensionsDescriptors(PersistenceUnitsDescriptor.class, puRoot) != null) { if (deplLogger.isLoggable(Level.FINE)) { deplLogger.logp(Level.FINE, "Archivist", "readPersistenceDeploymentDescriptor", "PU has been already read for = {0}", subArchiveURI); } return null; } PersistenceUnitsDescriptor persistenceUnitsDescriptor = PersistenceUnitsDescriptor.class.cast(super.open(main, subArchive, descriptor)); if (persistenceUnitsDescriptor!=null) { persistenceUnitsDescriptor.setParent(descriptor); persistenceUnitsDescriptor.setPuRoot(puRoot); descriptor.addExtensionDescriptor(PersistenceUnitsDescriptor.class,persistenceUnitsDescriptor, puRoot); } return persistenceUnitsDescriptor; }
/** * Iterate through all the PersistenceUnitDescriptors for the given context (and hence corresponding bundle) and call visitPUD for each of them * @param context */ void iteratePUDs(DeploymentContext context) { RootDeploymentDescriptor currentBundle = DOLUtils.getCurrentBundleForContext(context); if (currentBundle != null) { // it can be null for non-JavaEE type of application deployment. e.g., issue 15869 Collection<PersistenceUnitsDescriptor> pusDescriptorForThisBundle = currentBundle.getExtensionsDescriptors(PersistenceUnitsDescriptor.class); for (PersistenceUnitsDescriptor persistenceUnitsDescriptor : pusDescriptorForThisBundle) { for (PersistenceUnitDescriptor pud : persistenceUnitsDescriptor.getPersistenceUnitDescriptors()) { visitPUD(pud, context); } } } }
/** * Obtain a full set of bundle descriptors for a particular type * * @param type the bundle descriptor type requested * @return the set of bundle descriptors */ public <T extends BundleDescriptor> Set<T> getBundleDescriptors(Class<T> type) { if (type == null) { return null; } Set<T> bundleSet = new OrderedSet<T>(); for (ModuleDescriptor aModule : getModules()) { try { T descriptor = type.cast(aModule.getDescriptor()); bundleSet.add(descriptor); } catch(ClassCastException e) { // ignore } // any children, this need to happen outside of the casting as the parent // type has nothing to do with the children extensions. if (aModule.getDescriptor() != null) { bundleSet.addAll(aModule.getDescriptor().getExtensionsDescriptors(type)); } } 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; }
/** * Obtain a full set of bundle descriptors for a particular type * * @param bundleType the bundle descriptor type requested * @return the set of bundle descriptors */ public Set<BundleDescriptor> getBundleDescriptorsOfType(ArchiveType bundleType) { if (bundleType == null) { return Collections.emptySet(); } Set<BundleDescriptor> bundleSet = new OrderedSet<BundleDescriptor>(); for (ModuleDescriptor aModule : getModules()) { if (aModule.getDescriptor().getModuleType()== bundleType) { bundleSet.add((BundleDescriptor)aModule.getDescriptor()); } for (RootDeploymentDescriptor rd : aModule.getDescriptor().getExtensionsDescriptors()) { if (rd instanceof BundleDescriptor) { if (((BundleDescriptor)rd).getModuleType()== bundleType){ bundleSet.add((BundleDescriptor)rd); } } } } return bundleSet; }
getModuleDescriptor().getDescriptor().getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) { for (PersistenceUnitDescriptor pu : pus.getPersistenceUnitDescriptors()) {
moduleDesc.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);
int totalNumberOfPUInBundle = 0; for (PersistenceUnitsDescriptor nextPUs : getModuleDescriptor().getDescriptor().getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) { for (PersistenceUnitDescriptor nextPU : nextPUs.getPersistenceUnitDescriptors()) {