private String getModuleID(RootDeploymentDescriptor rdd) { //V3: Can we use this : return rdd.getModuleID(); /*V3:Comment if (rdd instanceof Application) { return TOP_LEVEL; } else if (rdd instanceof BundleDescriptor) { return ((BundleDescriptor) rdd).getModuleDescriptor().getArchiveUri(); } else { // cannot happen unless glassfish code is changed throw new AssertionError(rdd.getClass() + " is not a known descriptor type"); }*/ if (rdd.isApplication()) { return TOP_LEVEL; } else if (rdd.getModuleDescriptor() != null) { return rdd.getModuleDescriptor().getArchiveUri(); } else { // cannot happen unless glassfish code is changed throw new AssertionError(rdd.getClass() + " is not a known descriptor type"); } }
/** * Add the extension descriptor to the main descriptor * * @param root the main descriptor * @param extension the extension descriptor * @return the main descriptor with the extensions */ public <T extends RootDeploymentDescriptor> void addExtension(RootDeploymentDescriptor root, RootDeploymentDescriptor extension) { root.addExtensionDescriptor(extension.getClass(), extension, null); extension.setModuleDescriptor(root.getModuleDescriptor()); }
public ClassLoader getClassLoader() { return parent.getClassLoader(); }
/** * 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); } } } }
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; }
/** * 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; }
@Override public void registerEMF(String unitName, String persistenceRootUri, RootDeploymentDescriptor containingBundle, EntityManagerFactory emf) { // We register the EMF into the bundle that declared the corresponding PU. This limits visibility of the emf // to containing module. // See EMFWrapper.lookupEntityManagerFactory() for corresponding look up logic if (containingBundle.isApplication()) { // ear level pu assert containingBundle instanceof Application; Application.class.cast(containingBundle).addEntityManagerFactory( unitName, persistenceRootUri, emf); } else { assert containingBundle instanceof BundleDescriptor; BundleDescriptor.class.cast(containingBundle).addEntityManagerFactory( unitName, emf); } }
"enterprise.deployment.oldDDwithAnnotation", "{0} in archive {1} is of version {2}, which cannot support annotations in an application. Please upgrade the deployment descriptor to be a version supported by Java EE 5.0 (or later).", new Object[]{ddName, archiveName, bundleDesc.getSpecVersion()})); originalBundleClassLoader = bundleDesc.getClassLoader(); } catch (Exception e) { bundleDesc.setClassLoader(classLoader); } finally { if (originalBundleClassLoader == null) { bundleDesc.setClassLoader(null);
/** * Gives the text value to be used for the top-level element in the descriptor * corresponding to this bundle node type. * * @param descriptor descriptor data structure for the current node * @return */ protected String topLevelTagValue(T descriptor) { return descriptor.getModuleDescriptor().getModuleName(); }
@Override protected void addBundleNodeAttributes(Element bundleNode, RootDeploymentDescriptor descriptor) { String schemaLocation; // the latest connector schema still use j2ee namespace bundleNode.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", WLDescriptorConstants.WL_WEBSERVICES_XML_NS); bundleNode.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:j2ee", TagNames.J2EE_NAMESPACE); schemaLocation = WLDescriptorConstants.WL_WEBSERVICES_XML_NS + " " + getSchemaURL(); schemaLocation = schemaLocation+ " "+ TagNames.J2EE_NAMESPACE + " " + "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; bundleNode.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xsi", W3C_XML_SCHEMA_INSTANCE); // add all custom global namespaces addNamespaceDeclaration(bundleNode, descriptor); String clientSchemaLocation = descriptor.getSchemaLocation(); if (clientSchemaLocation != null) { schemaLocation = schemaLocation + " " + clientSchemaLocation; } bundleNode.setAttributeNS(W3C_XML_SCHEMA_INSTANCE, SCHEMA_LOCATION_TAG, schemaLocation); bundleNode.setAttribute(TagNames.VERSION, getSpecVersion()); }
/** * 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; }
/** * This is a utility method which calculates the absolute path of the * root of a PU. Absolute path is not the path with regards to * root of file system. It is the path from the root of the Java EE * application this persistence unit belongs to. * Like {@link #getPuRoot()} returned path always uses '/' as path separator. * @return the absolute path of the root of this persistence unit * @see #getPuRoot() */ public String getAbsolutePuRoot() { RootDeploymentDescriptor rootDD = getParent(); if(rootDD.isApplication()){ return getPuRoot(); } else { ModuleDescriptor module = BundleDescriptor.class.cast(rootDD). getModuleDescriptor(); if(module.isStandalone()) { return getPuRoot(); } else { final String moduleLocation = module.getArchiveUri(); return moduleLocation + '/' + getPuRoot(); // see we always '/' } } }
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; }
/** * This method calculates the absolute path of the root of a PU. * Absolute path is not the path with regards to root of file system. * It is the path from the root of the Java EE application this * persistence unit belongs to. * Returned path always uses '/' as path separator. * @return the absolute path of the root of this persistence unit */ private String getAbsolutePuRootWithinApplication() { // TODO shift this into PersistenceUnitDescriptor to better encapsulate RootDeploymentDescriptor rootDD = persistenceUnitDescriptor.getParent(). getParent(); String puRoot = persistenceUnitDescriptor.getPuRoot(); if(rootDD.isApplication()){ return puRoot; } else { ModuleDescriptor module = BundleDescriptor.class.cast(rootDD). getModuleDescriptor(); if(module.isStandalone()) { return puRoot; } else { // The module is embedded in an ear (an ejb jar or war) final String moduleLocation = // Would point to the directory where module is expanded. For example myejb_jar DeploymentUtils.getRelativeEmbeddedModulePath( providerContainerContractInfo.getApplicationLocation(), module.getArchiveUri()); return moduleLocation + '/' + puRoot; // see we always '/' } } }
@Override public ClassLoader getClassLoader() { if (parent == null) return null; return parent.getClassLoader(); }
getModuleDescriptor().getDescriptor().getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) { for (PersistenceUnitDescriptor pu : pus.getPersistenceUnitDescriptors()) {
/** * receives notiification of the value for a particular tag * * @param element the xml element * @param value it's associated value */ public void setElementValue(XMLElement element, String value) { PrincipalNameDescriptor principal = (PrincipalNameDescriptor) getDescriptor(); if (RuntimeTagNames.PRINCIPAL_NAME.equals(element.getQName())) { principal.setName(value); Object rootDesc = getParentNode().getParentNode().getDescriptor(); if (rootDesc instanceof RootDeploymentDescriptor) { principal.setClassLoader(((RootDeploymentDescriptor)rootDesc).getClassLoader()); } } else super.setElementValue(element, value); }
moduleDesc.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);
int totalNumberOfPUInBundle = 0; for (PersistenceUnitsDescriptor nextPUs : getModuleDescriptor().getDescriptor().getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) { for (PersistenceUnitDescriptor nextPU : nextPUs.getPersistenceUnitDescriptors()) {