/** * This method returns one extension of the passed type in the scope with the right index * @param type requested extension type * @param index is the instance index * @return an unmodifiable collection of extensions or empty collection if none. */ public <T extends RootDeploymentDescriptor> T getExtensionsDescriptors(Class<? extends RootDeploymentDescriptor> type, String index) { for (T extension : (Collection<T>) getExtensionsDescriptors(type)) { String extensionIndex = ((RootDeploymentDescriptor)extension).index; if (index==null) { if (extensionIndex==null) { return extension; } } else { if (index.equals(extensionIndex)) { return extension; } } } return null; }
protected PersistenceUnitsDescriptor readPersistenceDeploymentDescriptor(Archivist main, ReadableArchive subArchive, String puRoot, RootDeploymentDescriptor descriptor) throws IOException, SAXParseException { final String subArchiveURI = subArchive.getURI().getSchemeSpecificPart(); if (logger.isLoggable(Level.FINE)) { logger.logp(Level.FINE, "Archivist", "readPersistenceDeploymentDescriptor", "PURoot = [{0}] subArchive = {1}", new Object[]{puRoot, subArchiveURI}); } if (descriptor.getExtensionsDescriptors(PersistenceUnitsDescriptor.class, puRoot) != null) { if (logger.isLoggable(Level.FINE)) { logger.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; }
/** * 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; }
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()) {