/** * @return true if the jarName corresponds to component jar (like a war or ejb.jar) in an .ear false otherwise */ public static boolean isComponentJar(String jarName, Set<ModuleDescriptor<BundleDescriptor>> moduleDescriptors) { boolean isComponentJar = false; for (ModuleDescriptor md : moduleDescriptors) { String archiveUri = md.getArchiveUri(); if (jarName.equals(archiveUri)) { isComponentJar = true; break; } } return isComponentJar; }
/** return name used for deployment */ public String getDeployName() { return getModuleDescriptor().getArchiveUri(); }
/** * 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; }
private String getModuleLocation(ModuleDescriptor module) throws IOException { String moduleLocation = (new File(rootLocation_.getURI())).getAbsolutePath(); if( !module.isStandalone() ) { // If this is an ear, get module jar by adding the module path // to the root directory. String archiveUri = module.getArchiveUri(); archiveUri = archiveUri.replace('.', '_'); moduleLocation = moduleLocation + File.separator + archiveUri; } return moduleLocation; }
/** * Get the uri of a target based on a source module and a a relative uri * from the perspective of that source module. * * @param origin bundle descriptor within an application * @param relativeTargetUri relative uri from the given bundle * descriptor * @return target uri */ private String getTargetUri(BundleDescriptor origin, String relativeTargetUri) { try { String archiveUri = origin.getModuleDescriptor().getArchiveUri(); return new URI(archiveUri).resolve(relativeTargetUri).getPath(); } catch (URISyntaxException use) { throw new RuntimeException(use); } }
/** * Get the uri of a target based on a source module and a * a relative uri from the perspective of that source module. * * @param origin bundle descriptor within this application * @param relativeTargetUri relative uri from the given bundle descriptor * @return target uri */ public String getTargetUri(BundleDescriptor origin, String relativeTargetUri) { String targetUri = null; try { String archiveUri = origin.getModuleDescriptor().getArchiveUri(); URI originUri = new URI(archiveUri); URI resolvedUri = originUri.resolve(relativeTargetUri); targetUri = resolvedUri.getPath(); } catch (URISyntaxException use) { _logger.log(Level.FINE, "origin " + origin + " has invalid syntax", use); } return targetUri; }
/** * Return the relative uri between two modules, from the perspective * of the first bundle. * * @return relative uri or empty string if the two bundles are the same */ public String getRelativeUri(BundleDescriptor origin, BundleDescriptor target) { String originUri = origin.getModuleDescriptor().getArchiveUri(); String targetUri = target.getModuleDescriptor().getArchiveUri(); StringTokenizer tokenizer = new StringTokenizer(originUri, "/"); int numTokens = tokenizer.countTokens(); int numSeparators = (numTokens > 0) ? (numTokens - 1) : 0; StringBuffer relativeUri = new StringBuffer(); // The simplest way to compute a relative uri is to add one "../" // for each sub-path in the origin URI, then add the target URI. // It's possible for the result to not be normalized if the origin // and target have at least one common root, but that shouldn't // matter as long as when the relative URI is resolved against the // origin it produces the target. for (int i = 0; i < numSeparators; i++) { relativeUri.append("../"); } relativeUri.append(targetUri); return relativeUri.toString(); }
public int compare(Object o1, Object o2) { EjbDescriptor desc1 = (EjbDescriptor) o1; EjbDescriptor desc2 = (EjbDescriptor) o2; String moduleUri1 = desc1.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); String moduleUri2 = desc2.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); return (moduleUri1 + desc1.getName()).compareTo( moduleUri2 + desc2.getName()); } }
/** * @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; }
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"); } }
private String normalizeSingletonName(String origName, EjbSessionDescriptor sessionDesc) { String normalizedName = origName; boolean fullyQualified = origName.contains("#"); Application app = sessionDesc.getEjbBundleDescriptor().getApplication(); if (fullyQualified) { int indexOfHash = origName.indexOf("#"); String ejbName = origName.substring(indexOfHash + 1); String relativeJarPath = origName.substring(0, indexOfHash); BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(), relativeJarPath); if (bundle == null) { throw new IllegalStateException("Invalid @DependOn value = " + origName + " for Singleton " + sessionDesc.getName()); } normalizedName = bundle.getModuleDescriptor().getArchiveUri() + "#" + ejbName; } else { normalizedName = sessionDesc.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri() + "#" + origName; } return normalizedName; }
public String getUniqueName() { if(uniqueName == null) { BundleDescriptor bundle = getEjbBundleDescriptor(); Application application = bundle.getApplication(); // Add ejb name and application name. StringBuffer rc = new StringBuffer(). append(getName()). append(NAME_CONCATENATOR). append(application.getRegistrationName()); // If it's not just a module, add a module name. if (!application.isVirtual()) { rc.append(NAME_CONCATENATOR). append(bundle.getModuleDescriptor().getArchiveUri()); } uniqueName = getBaseName(getEjbClassName()) + getUniqueNumber(rc.toString()); } return uniqueName; }
private String getWebDir(String baseDir) { if (baseDir == null) { return null; } StringBuilder dir = new StringBuilder(baseDir); dir.append(File.separator); com.sun.enterprise.deployment.Application app = _wbd.getApplication(); if (app != null && !app.isVirtual()) { dir.append(FileUtils.makeFriendlyFilename( app.getRegistrationName())); dir.append(File.separator); dir.append(FileUtils.makeFriendlyFilename( _wbd.getModuleDescriptor().getArchiveUri())); } else { dir.append(FileUtils.makeLegalNoBlankFileName( _wbd.getModuleID())); } return dir.toString(); } }
/** * 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; }
/** * @return the module ID for this module descriptor */ public String getModuleID() { if (moduleID == null) { moduleID = getModuleDescriptor().getArchiveUri(); } if (getModuleDescriptor().isStandalone()) { return moduleID; } if (application != null && !application.isVirtual()) { return application.getRegistrationName() + "#" + getModuleDescriptor().getArchiveUri(); } else { return moduleID; } }
public String getModuleName() { String moduleName = null; // for standalone jars, return its registration name // for applications, return the module uri if (getApplication().isVirtual()) { moduleName = getApplication().getRegistrationName(); } else { moduleName = getModuleDescriptor().getArchiveUri(); } return moduleName; }
public String getGeneratedWsdlFilePath() { if (hasWsdlFile()) { String xmlDir = getBundleDescriptor().getApplication().getGeneratedXMLDirectory(); if(!getBundleDescriptor().getModuleDescriptor().isStandalone()) { String uri = getBundleDescriptor().getModuleDescriptor().getArchiveUri(); xmlDir = xmlDir + File.separator + uri.replaceAll("\\.", "_"); } if(xmlDir == null) { return null; } return xmlDir + File.separator + wsdlFileUri; } else { return getWsdlFileUrl().getPath(); } }
/** * 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; }
/** * 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 '/' } } }
CallFlowInfoImpl(BaseContainer container, EjbDescriptor descriptor, ComponentType compType) { this.container = container; this.ejbDescriptor = descriptor; this.appName = (ejbDescriptor.getApplication().isVirtual()) ? null : ejbDescriptor.getApplication().getRegistrationName(); String archiveuri = ejbDescriptor.getEjbBundleDescriptor() .getModuleDescriptor().getArchiveUri(); this.modName = com.sun.enterprise.util.io.FileUtils .makeFriendlyFilename(archiveuri); this.ejbName = ejbDescriptor.getName(); this.componentType = compType; }