/** * @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; }
/** * 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); } }
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; }
private Map<String, String> getAppLevelComponents(com.sun.enterprise.deployment.Application application, String type, Map<String, String> subComponentsMap) { Map<String, String> subComponentList = new LinkedHashMap<String, String>(); if (application.isVirtual()) { // for standalone module, get servlets or ejbs BundleDescriptor bundleDescriptor = application.getStandaloneBundleDescriptor(); subComponentList = getModuleLevelComponents(bundleDescriptor, type, subComponentsMap); } else { // for ear case, get modules Collection<ModuleDescriptor<BundleDescriptor>> modules = getSubModuleListForEar(application, type); for (ModuleDescriptor module : modules) { StringBuffer sb = new StringBuffer(); String moduleName = module.getArchiveUri(); sb.append("<"); String moduleType = getModuleType(module); sb.append(moduleType); sb.append(">"); subComponentList.put(moduleName, sb.toString()); subComponentsMap.put(module.getArchiveUri(), moduleType); } } return subComponentList; }
/** * Returns name prefix for DDL files extracted from the info instance by the * Sun-specific code. * * @param info the instance to use for the name generation. * @return name prefix as String. */ public static String getDDLNamePrefix(Object info) { StringBuffer rc = new StringBuffer(); if (info instanceof BundleDescriptor && !(info instanceof Application)) { BundleDescriptor bundle = (BundleDescriptor)info; rc.append(bundle.getApplication().getRegistrationName()); Application application = bundle.getApplication(); if (!application.isVirtual()) { String modulePath = bundle.getModuleDescriptor().getArchiveUri(); int l = modulePath.length(); // Remove ".jar" from the module's jar name. rc.append(DatabaseConstants.NAME_SEPARATOR). append(modulePath.substring(0, l - 4)); } } // no other option is available at this point. return (rc.length() == 0)? DEFAULT_NAME : rc.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 normalizeSingletonName(String origName, EjbSessionDescriptor sessionDesc) { String normalizedName; 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; }
/** Calculate module name from a bundle. * @return module name. */ public static String getModuleName(EjbBundleDescriptor bundle) { String moduleName = null; Application application = bundle.getApplication(); if (application.isVirtual()) { // Stand-alone module is deployed. moduleName = application.getRegistrationName(); } else { // Module is deployed as a part of an Application. String jarName = bundle.getModuleDescriptor().getArchiveUri(); int l = jarName.length(); // Remove ".jar" from the bundle's jar name. moduleName = jarName.substring(0, l - 4); } return moduleName; }
private ModuleInfo prepareBundle(final ModuleDescriptor md, Application application, final ExtendedDeploymentContext bundleContext) throws Exception { List<EngineInfo> orderedContainers = null; ProgressTracker tracker = bundleContext.getTransientAppMetaData(ExtendedDeploymentContext.TRACKER, ProgressTracker.class); try { // let's get the previously stored list of sniffers Hashtable<String, Collection<Sniffer>> sniffersTable = bundleContext.getSource().getParentArchive().getExtraData(Hashtable.class); Collection<Sniffer> sniffers = sniffersTable.get(md.getArchiveUri()); // let's get the list of containers interested in this module orderedContainers = deployment.setupContainerInfos(null, sniffers, bundleContext); if (orderedContainers == null) { return null; } } catch(Exception e) { deplLogger.log(Level.WARNING, ERROR_OCCURRED, e); throw e; } return deployment.prepareModule(orderedContainers, md.getArchiveUri(), bundleContext, tracker); }
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; }
/** * 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()) { BundleDescriptor bundleDesc = aModule.getDescriptor(); if (bundleDesc != null) { bundleSet.add(bundleDesc); for (RootDeploymentDescriptor rd : bundleDesc.getExtensionsDescriptors()) { if (rd instanceof BundleDescriptor) { bundleSet.add((BundleDescriptor)rd); } } } 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; } }
private List<String> getSubModulesForEar(com.sun.enterprise.deployment.Application application, String type) { List<String> moduleInfoList = new ArrayList<String>(); Collection<ModuleDescriptor<BundleDescriptor>> modules = getSubModuleListForEar(application, type); for (ModuleDescriptor moduleDesc : modules) { String moduleInfo = moduleDesc.getArchiveUri() + ":" + moduleDesc.getModuleType(); if (moduleDesc.getModuleType().equals(DOLUtils.warType())) { moduleInfo = moduleInfo + ":" + moduleDesc.getContextRoot(); } moduleInfoList.add(moduleInfo); } return moduleInfoList; }
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(); } }
/** * 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; }