/** * Generate a unique id name for each J2EE component. */ public String getComponentEnvId(JndiNameEnvironment env) { String id = DOLUtils.getComponentEnvId(env); if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, DOLUtils.getApplicationName(env) + "Component Id: " + id); } return id; }
private String getResourceId(JndiNameEnvironment env, Descriptor desc){ String resourceId = ""; if(dependencyAppliesToScope(desc, ScopeType.COMPONENT)){ resourceId = DOLUtils.getApplicationName(env) + "/" + DOLUtils.getModuleName(env) + "/" + getComponentEnvId(env) ; } else if(dependencyAppliesToScope(desc, ScopeType.MODULE)){ resourceId = DOLUtils.getApplicationName(env) + "/" + DOLUtils.getModuleName(env) ; } else if(dependencyAppliesToScope(desc, ScopeType.APP)){ resourceId = DOLUtils.getApplicationName(env) ; } return resourceId; }
private Map getNamespace(String logicalJndiName, JndiNameEnvironment env) { String appName = DOLUtils.getApplicationName(env); Map namespace = null; if (logicalJndiName.startsWith(JAVA_COMP_PREFIX)) { String componentId = DOLUtils.getComponentEnvId(env); namespace = (Map) componentNamespaces.get(componentId); if (namespace == null) { namespace = new HashMap<String, Map>(); componentNamespaces.put(componentId, namespace); } } else if (logicalJndiName.startsWith(JAVA_MODULE_PREFIX)) { String moduleName = DOLUtils.getModuleName(env); AppModuleKey appModuleKey = new AppModuleKey(appName, moduleName); namespace = moduleNamespaces.get(appModuleKey); if (namespace == null) { namespace = new HashMap<AppModuleKey, Map>(); moduleNamespaces.put(appModuleKey, namespace); } } else if (logicalJndiName.startsWith(JAVA_APP_PREFIX)) { namespace = appNamespaces.get(appName); if (namespace == null) { namespace = new HashMap<String, Map>(); appNamespaces.put(appName, namespace); } } else { // java:global namespace = globalNameSpace; } return namespace; }
public void addToComponentNamespace(JndiNameEnvironment origEnv, Collection<EnvironmentProperty> envProps, Collection<ResourceReferenceDescriptor> resRefs) throws NamingException { String compEnvId = getComponentEnvId(origEnv); Collection<JNDIBinding> bindings = new ArrayList<JNDIBinding>(); addEnvironmentProperties(ScopeType.COMPONENT, envProps.iterator(), bindings); addResourceReferences(ScopeType.COMPONENT, resRefs.iterator(), bindings); boolean treatComponentAsModule = DOLUtils.getTreatComponentAsModule(origEnv); // Bind dependencies to the namespace for this component namingManager.bindToComponentNamespace(DOLUtils.getApplicationName(origEnv), DOLUtils.getModuleName(origEnv), compEnvId, treatComponentAsModule, bindings); return; }
/** * Store all the resources before starting the validation. */ private void parseResources(AppResources appResources) { parseResources(application, appResources); for (BundleDescriptor bd : application.getBundleDescriptors()) { if (bd instanceof WebBundleDescriptor || bd instanceof ApplicationClientDescriptor) parseResources(bd, appResources); if (bd instanceof EjbBundleDescriptor) { // Resources from Java files in the ejb.jar which are neither an EJB nor a managed bean are stored here. // Skip validation for them, validate only Managed Beans. for (ManagedBeanDescriptor mbd: bd.getManagedBeans()) { parseResources(mbd, (JndiNameEnvironment) bd, appResources); } EjbBundleDescriptor ebd = (EjbBundleDescriptor) bd; for (EjbDescriptor ejb : ebd.getEjbs()) parseEJB(ejb, appResources); } } parseManagedBeans(appResources); // Parse AppScoped resources String appName = DOLUtils.getApplicationName(application); Map<String, List<String>> resourcesList = (Map<String, List<String>>) dc.getTransientAppMetadata().get(ResourceConstants.APP_SCOPED_RESOURCES_JNDI_NAMES); appResources.storeAppScopedResources(resourcesList, appName); }
String appName = DOLUtils.getApplicationName(application);; String newPrefix = "java:global/" + appName + "/";
namingManager.unbindAppObjects(DOLUtils.getApplicationName(env)); } else {
namingManager.bindToAppNamespace(DOLUtils.getApplicationName(env), bindings); } else { namingManager.bindToComponentNamespace(DOLUtils.getApplicationName(env), DOLUtils.getModuleName(env), compEnvId, treatComponentAsModule, bindings); compEnvId = getComponentEnvId(env);