/** * Set the DOL descriptor for this Archivist, used by super classes */ public void setDescriptor(Application descriptor) { // this is acceptable if the application actually represents // a standalone module Set ejbBundles = ((Application) descriptor).getEjbBundleDescriptors(); if (ejbBundles.size()>0) { this.descriptor = (EjbBundleDescriptor) ejbBundles.iterator().next(); if (this.descriptor.getModuleDescriptor().isStandalone()) return; else this.descriptor=null; } }
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); } }
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; }
public static 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; }
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()); } }
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()); } }
/** * Return the fully-qualified portable JNDI name for a given * client view (Remote, Local, or no-interface). */ public String getPortableJndiName(String clientViewType) { String appName = null; Application app = getEjbBundleDescriptor().getApplication(); if ( ! app.isVirtual() ) { appName = app.getAppName(); } String modName = getEjbBundleDescriptor().getModuleDescriptor().getModuleName(); StringBuffer javaGlobalPrefix = new StringBuffer("java:global/"); if (appName != null) { javaGlobalPrefix.append(appName); javaGlobalPrefix.append("/"); } javaGlobalPrefix.append(modName); javaGlobalPrefix.append("/"); javaGlobalPrefix.append(getName()); javaGlobalPrefix.append("!"); javaGlobalPrefix.append(clientViewType); return javaGlobalPrefix.toString(); }
protected String getJavaGlobalJndiNamePrefix() { String appName = null; Application app = ejbDescriptor.getApplication(); if ( ! app.isVirtual() ) { appName = ejbDescriptor.getApplication().getAppName(); } EjbBundleDescriptor ejbBundle = ejbDescriptor.getEjbBundleDescriptor(); String modName = ejbBundle.getModuleDescriptor().getModuleName(); String ejbName = ejbDescriptor.getName(); StringBuffer javaGlobalPrefix = new StringBuffer("java:global/"); if (appName != null) { javaGlobalPrefix.append(appName); javaGlobalPrefix.append("/"); } javaGlobalPrefix.append(modName); javaGlobalPrefix.append("/"); javaGlobalPrefix.append(ejbName); return javaGlobalPrefix.toString(); }
private String getJavaGlobalJndiNamePrefix(EjbDescriptor ejbDescriptor) { String appName = null; Application app = ejbDescriptor.getApplication(); if ( ! app.isVirtual() ) { appName = ejbDescriptor.getApplication().getAppName(); } EjbBundleDescriptor ejbBundle = ejbDescriptor.getEjbBundleDescriptor(); String modName = ejbBundle.getModuleDescriptor().getModuleName(); String ejbName = ejbDescriptor.getName(); StringBuilder javaGlobalPrefix = new StringBuilder("java:global/"); if (appName != null) { javaGlobalPrefix.append(appName); javaGlobalPrefix.append("/"); } javaGlobalPrefix.append(modName); javaGlobalPrefix.append("/"); javaGlobalPrefix.append(ejbName); return javaGlobalPrefix.toString(); }
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; }
/** 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 BundleDescriptor getBundle() { ComponentEnvManager compEnvManager = habitat.getService(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 String getModuleName(JndiNameEnvironment env) { String moduleName = null; if (env instanceof EjbDescriptor) { // EJB component EjbDescriptor ejbEnv = (EjbDescriptor) env; EjbBundleDescriptor ejbBundle = ejbEnv.getEjbBundleDescriptor(); moduleName = ejbBundle.getModuleDescriptor().getModuleName(); } else if (env instanceof EjbBundleDescriptor) { EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env; moduleName = ejbBundle.getModuleDescriptor().getModuleName(); } else if (env instanceof WebBundleDescriptor) { WebBundleDescriptor webEnv = (WebBundleDescriptor) env; moduleName = webEnv.getModuleName(); } else if (env instanceof ApplicationClientDescriptor) { ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env; moduleName = appEnv.getModuleName(); } else if (env instanceof ManagedBeanDescriptor) { ManagedBeanDescriptor mb = (ManagedBeanDescriptor) env; moduleName = mb.getBundle().getModuleName(); } else { throw new IllegalArgumentException("IllegalJndiNameEnvironment : env"); } return moduleName; }
private String getModuleName(JndiNameEnvironment env) { String moduleName = null; if (env instanceof EjbDescriptor) { // EJB component EjbDescriptor ejbEnv = (EjbDescriptor) env; EjbBundleDescriptor ejbBundle = ejbEnv.getEjbBundleDescriptor(); moduleName = ejbBundle.getModuleDescriptor().getModuleName(); } else if( env instanceof EjbBundleDescriptor ) { EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env; moduleName = ejbBundle.getModuleDescriptor().getModuleName(); } else if (env instanceof WebBundleDescriptor) { WebBundleDescriptor webEnv = (WebBundleDescriptor) env; moduleName = webEnv.getModuleName(); } else if (env instanceof ApplicationClientDescriptor) { ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env; moduleName = appEnv.getModuleName(); } else if ( env instanceof ManagedBeanDescriptor ) { ManagedBeanDescriptor mb = (ManagedBeanDescriptor) env; moduleName = mb.getBundle().getModuleName(); } else { throw new IllegalArgumentException("IllegalJndiNameEnvironment : env"); } return moduleName; }
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; }
/** * Sets the unique id for this application. It traverses through all * the ejbs in the application and sets the unique id for each of them. * The traversal is done in ascending element order. * * NOTE : assumption is that the id has already been left shifted 16 * bits to allow space for the component ids. * * @param id unique id for this application */ public void setUniqueId(long id) { _logger.log(Level.FINE, "[Application] " + getName() + " , uid: " + id); this.uniqueId = id; EjbDescriptor[] descs = getSortedEjbDescriptors(); for (int i = 0; i < descs.length; i++) { // Maximum of 2^16 beans max per application descs[i].setUniqueId((id | i)); if (_logger.isLoggable(Level.FINE)) { String module = descs[i].getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); _logger.log(Level.FINE, "Ejb " + module + ":" + descs[i].getName() + " id = " + descs[i].getUniqueId()); } } uniqueIdSet = true; }
/** * Sets the unique id for this application. It traverses through all * the ejbs in the application and sets the unique id for each of them. * The traversal is done in ascending element order. * * NOTE : assumption is that the id has already been left shifted 16 * bits to allow space for the component ids. * * @param id unique id for this application */ public void setUniqueId(long id) { _logger.log(Level.FINE, "[Application] " + getName() + " , uid: " + id); this.uniqueId = id; EjbDescriptor[] descs = getSortedEjbDescriptors(); for (int i = 0; i < descs.length; i++) { // Maximum of 2^16 beans max per application descs[i].setUniqueId((id | i)); if (_logger.isLoggable(Level.FINE)) { String module = descs[i].getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); _logger.log(Level.FINE, "Ejb " + module + ":" + descs[i].getName() + " id = " + descs[i].getUniqueId()); } } uniqueIdSet = true; }
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) {
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) {
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; }