/** * 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; }
public <T extends RootDeploymentDescriptor> void addExtension(RootDeploymentDescriptor root, RootDeploymentDescriptor extension) { root.addExtensionDescriptor(extension.getClass(), extension, null); extension.setModuleDescriptor(root.getModuleDescriptor()); }
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"); } }
/** * as of J2EE1.4, get/setName are deprecated, * people should use the set/getDisplayName or * the set/getModuleID. * note : backward compatibility */ public String getName() { if (getModuleID()!=null) { return getModuleID(); } else { return getDisplayName(); } }
/** * @return the main descriptor associated with it if it's * an extension descriptor, otherwise return itself */ public RootDeploymentDescriptor getMainDescriptor() { if (isExtensionDescriptor()) { return getModuleDescriptor().getDescriptor(); } else { return this; } }
o.setModuleDescriptor(descriptor.getModuleDescriptor()); if (o!=null && !o.isEmpty()) { extension.getKey().addExtension(descriptor, o); extensions.put(extension.getKey(), (RootDeploymentDescriptor) o);
if (bundleDesc.isDDWithNoAnnotationAllowed()) { "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);
/** * creates a new module descriptor for this archivist * * @return the new module descriptor */ public ModuleDescriptor createModuleDescriptor(T descriptor) { ModuleDescriptor newModule = descriptor.getModuleDescriptor(); setDescriptor(descriptor); return newModule; }
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; }
/** * 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 '/' } } }
public ClassLoader getClassLoader() { return parent.getClassLoader(); }
public String getSchemaLocation() { return (String) getExtraAttribute("schema-location"); }
public void setSchemaLocation(String schemaLocation) { addExtraAttribute("schema-location", schemaLocation); }
/** * @return the specification version of the deployment descriptor * loaded by this descriptor */ public String getSpecVersion() { if (specVersion == null) { specVersion = getDefaultSpecVersion(); } try { Double.parseDouble(specVersion); } catch (NumberFormatException nfe) { DOLUtils.getDefaultLogger().log(Level.WARNING, "invalidSpecVersion", new Object[] {specVersion, getDefaultSpecVersion()}); specVersion = getDefaultSpecVersion(); } return specVersion; }
/** * @return whether this descriptor is an extension descriptor * of a main descriptor, e.g. the EjbBundleDescriptor for * ejb in war case should return true. */ public boolean isExtensionDescriptor() { if (getModuleDescriptor().getDescriptor() != this) { return true; } return false; }
/** * 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); }
/** * 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; }
descriptor.getModuleDescriptor().setArchiveUri( aModule.getArchiveUri()); aModule.setModuleName( descriptor.getModuleDescriptor().getModuleName()); aModule.setDescriptor((BundleDescriptor) descriptor); ((BundleDescriptor) descriptor).setApplication(app);
getModuleDescriptor().getDescriptor().getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) { for (PersistenceUnitDescriptor pu : pus.getPersistenceUnitDescriptors()) {
appendTextChild(bundleNode, TagNames.MODULE_NAME, descriptor.getModuleDescriptor().getModuleName());