public void addModule(ModuleDescriptor<BundleDescriptor> descriptor) { modules.add(descriptor); if (descriptor.getDescriptor() != null) { descriptor.getDescriptor().setApplication(this); } }
public void removeModule(ModuleDescriptor<BundleDescriptor> descriptor) { if (modules.contains(descriptor)) { if (descriptor.getDescriptor() != null) { descriptor.getDescriptor().setApplication(null); } modules.remove(descriptor); } }
/** * @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; }
/** * 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 BundleDescriptor getModuleByUri(String uri) { ModuleDescriptor<BundleDescriptor> md = getModuleDescriptorByUri(uri); if (md != null) { return md.getDescriptor(); } return null; }
private String getModuleName(BundleDescriptor bundleDesc, Application app) { Set<ModuleDescriptor<BundleDescriptor>> moduleDescriptors = app.getModules(); if(moduleDescriptors != null){ for(ModuleDescriptor moduleDesc : moduleDescriptors){ if(bundleDesc.equals(moduleDesc.getDescriptor())){ return moduleDesc.getModuleName(); } } } return null; }
/** * 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; }
public void addManagedBean(ManagedBeanDescriptor managedBeanDesc) { BundleDescriptor bundleDesc = (BundleDescriptor) ((BundleDescriptor) descriptor).getModuleDescriptor().getDescriptor(); bundleDesc.addManagedBean(managedBeanDesc); }
/** * @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; } }
/** * 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; }
/** * if this application object is virtual, return the standalone * bundle descriptor it is wrapping otherwise return null * * @return the wrapped standalone bundle descriptor */ public BundleDescriptor getStandaloneBundleDescriptor() { if (isVirtual()) { if (getModules().size()>1) { // this is an error, the application is virtual, // which mean a wrapper for a standalone module and // it seems I have more than one module in my list... throw new IllegalStateException("Virtual application contains more than one module"); } return getModules().iterator().next().getDescriptor(); } else { return null; } }
private boolean getTreatComponentAsModule(JndiNameEnvironment env) { boolean treatComponentAsModule = false; if( env instanceof WebBundleDescriptor ) { treatComponentAsModule = true; } else { if (env instanceof EjbDescriptor ) { EjbDescriptor ejbDesc = (EjbDescriptor) env; EjbBundleDescriptor ejbBundle = ejbDesc.getEjbBundleDescriptor(); if( ejbBundle.getModuleDescriptor().getDescriptor() instanceof WebBundleDescriptor ) { treatComponentAsModule = true; } } } return treatComponentAsModule; }
/** * @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; }
/** * Archivists can be associated with a module descriptor once the * XML deployment descriptors have been read and the DOL tree * is initialized. */ public void setModuleDescriptor(ModuleDescriptor<T> module) { setDescriptor(module.getDescriptor()); setManifest(module.getManifest()); }
/** * Get a map of bean class to managed bean descriptor for the managed beans * defined within the current module. */ private Map<String, ManagedBeanDescriptor> getManagedBeanMap() { BundleDescriptor thisBundle = getBundleDescriptor(); Set<ManagedBeanDescriptor> managedBeans = new HashSet<ManagedBeanDescriptor>(); // Make sure we're dealing with the top-level bundle descriptor when looking // for managed beans if( thisBundle != null ) { Object desc = thisBundle.getModuleDescriptor().getDescriptor(); if( desc instanceof BundleDescriptor ) { managedBeans = ((BundleDescriptor)desc).getManagedBeans(); } } Map<String, ManagedBeanDescriptor> managedBeanMap = new HashMap<String, ManagedBeanDescriptor>(); for(ManagedBeanDescriptor managedBean : managedBeans ) { String beanClassName = managedBean.getBeanClassName(); managedBeanMap.put(beanClassName, managedBean); } return managedBeanMap; }
private BundleDescriptor getBundle() { ComponentEnvManager compEnvManager = habitat.getByContract(ComponentEnvManager.class); JndiNameEnvironment env = compEnvManager.getCurrentJndiNameEnvironment(); BundleDescriptor bundle = null; if( env instanceof BundleDescriptor) { bundle = (BundleDescriptor) env; } else if( env instanceof EjbDescriptor ) { bundle = (BundleDescriptor) ((EjbDescriptor)env).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor(); } if( bundle == null ) { throw new IllegalStateException("Invalid context for managed bean creation"); } return bundle; }
public static List<URL> getLibraryJars(BundleDescriptor bundleDesc, ReadableArchive archive) throws IOException { List<URL> libraryURLs = new ArrayList<URL>(); // add libraries referenced through manifest libraryURLs.addAll(DeploymentUtils.getManifestLibraries(archive)); ReadableArchive parentArchive = archive.getParentArchive(); if (parentArchive == null || bundleDesc == null) { // ear level or standalone module return libraryURLs; } File appRoot = new File(parentArchive.getURI()); ModuleDescriptor moduleDesc = ((BundleDescriptor)bundleDesc).getModuleDescriptor(); Application app = ((BundleDescriptor)moduleDesc.getDescriptor()).getApplication(); // add libraries jars inside application lib directory libraryURLs.addAll(ASClassLoaderUtil.getAppLibDirLibrariesAsList( appRoot, app.getLibraryDirectory(), null)); return libraryURLs; }
public void setElementValue(XMLElement element, String value) { if (TagNames.MODULE_NAME.equals(element.getQName())) { EjbBundleDescriptor bundleDesc = getDescriptor(); // ejb-jar.xml <module-name> only applies if this is an ejb-jar if( bundleDesc.getModuleDescriptor().getDescriptor() instanceof EjbBundleDescriptor ) { bundleDesc.getModuleDescriptor().setModuleName(value); } } else { super.setElementValue(element, value); } }
/** * Creates a new application to hold a standalone module * * @param name the application name * @param newModule the standalone module descriptor * @return the application */ public static Application createApplication(Habitat habitat, String name, ModuleDescriptor<BundleDescriptor> newModule) { // create a new empty application Application application = new Application(habitat); application.setVirtual(true); if (name == null && newModule.getDescriptor() != null) { name = newModule.getDescriptor().getDisplayName(); } String untaggedName = VersioningUtils.getUntaggedName(name); if (name != null) { application.setDisplayName(untaggedName); application.setName(untaggedName); application.setAppName(untaggedName); } // add the module to it newModule.setStandalone(true); newModule.setArchiveUri(untaggedName); if (newModule.getDescriptor() != null) { newModule.getDescriptor().setApplication(application); } application.addModule(newModule); return application; }
public static String getContextID(EjbBundleDescriptor ejbBundleDesc) { String cid = null; if (ejbBundleDesc != null) { /* detect special case of EJBs embedded in a war, * and make sure psuedo policy context id is unique within app */ Object root = ejbBundleDesc.getModuleDescriptor().getDescriptor(); if( (root != ejbBundleDesc) && (root instanceof WebBundleDescriptor ) ) { cid = createUniquePseudoModuleID(ejbBundleDesc); } else { cid = VersioningUtils.getRepositoryName(ejbBundleDesc.getApplication().getRegistrationName()) + '/' + ejbBundleDesc.getUniqueFriendlyId(); } } return cid; } public static String getContextID(WebBundleDescriptor wbd) {
moduleDesc.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);