public void process(JBossSessionBeanMetaData metaData, Class<?> type) { LocalHomeBinding annotation = finder.getAnnotation(type, LocalHomeBinding.class); if (annotation == null) return; if (annotation.jndiBinding().length() > 1) metaData.setLocalHomeJndiName(annotation.jndiBinding()); }
/** * Ultimately, the container name should come from the <code>sessionBeanMetadata</code>. However * because of the current behaviour where the container on its start sets the containername in the * metadata, its not possible to get this information even before the container is started. * * <p>Hence let's for the time being create the container name from all the information that we * have in the <code>unit</code> * * @param unit The deployment unit * @param sessionBeanMetadata Session bean metadata * @return Returns the container name for the bean corresponding to the <code>sessionBeanMetadata * </code> in the <code>unit</code> * @throws MalformedObjectNameException */ private String getContainerName(DeploymentUnit unit, JBossSessionBeanMetaData sessionBeanMetadata) throws MalformedObjectNameException { // TODO the base ejb3 jmx object name comes from Ejb3Module.BASE_EJB3_JMX_NAME, but // we don't need any reference to ejb3-core. Right now just hard code here, we need // a better way/place for this later StringBuilder containerName = new StringBuilder("jboss.j2ee:service=EJB3" + ","); // Get the top level unit for this unit (ex: the top level might be an ear and this unit might // be the jar // in that ear DeploymentUnit toplevelUnit = unit.getTopLevel(); if (toplevelUnit != null) { // if top level is an ear, then create the name with the ear reference if (isEar(toplevelUnit)) { containerName.append("ear="); containerName.append(toplevelUnit.getSimpleName()); containerName.append(","); } } // now work on the passed unit, to get the jar name if (unit.getSimpleName() == null) { containerName.append("*"); } else { containerName.append("jar="); containerName.append(unit.getSimpleName()); } // now the ejbname containerName.append(",name="); containerName.append(sessionBeanMetadata.getEjbName()); if (logger.isTraceEnabled()) { logger.trace( "Container name generated for ejb = " + sessionBeanMetadata.getEjbName() + " in unit " + unit + " is " + containerName); } ObjectName containerJMXName = new ObjectName(containerName.toString()); return containerJMXName.getCanonicalName(); }
@Override protected void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossEnterpriseBeanMetaData beanMetaData = unit.getAttachment(JBossEnterpriseBeanMetaData.class); if (beanMetaData == null) return; if (!beanMetaData.isSession()) return; JBossSessionBeanMetaData sessionBeanMetaData = (JBossSessionBeanMetaData) beanMetaData; String appName = getApplicationName(unit); String moduleName = getModuleName(unit); String componentName = getComponentName(unit); String javaCompName = "jboss.naming:"; if (appName != null) javaCompName += "application=" + appName + ","; javaCompName += "module=" + moduleName + ",component=" + componentName; String sessionBeanTypeName = "jboss.ejb3:"; if (appName != null) sessionBeanTypeName += "application=" + appName + ","; sessionBeanTypeName += "module=" + moduleName + ",component=" + componentName + ",service=" + SessionBeanTypeWrapper.class.getSimpleName(); { BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder( sessionBeanTypeName, SessionBeanTypeWrapper.class.getName()); builder.addConstructorParameter( JBossSessionBeanMetaData.class.getName(), sessionBeanMetaData); builder.addConstructorParameter(ClassLoader.class.getName(), unit.getClassLoader()); builder.addConstructorParameter( JavaEEComponent.class.getName(), builder.createInject(javaCompName)); unit.getParent().addAttachment(sessionBeanTypeName, builder.getBeanMetaData()); } String beanInstanceName = "jboss.ejb3:"; if (appName != null) beanInstanceName += "application=" + appName + ","; beanInstanceName += "module=" + moduleName + ",component=" + componentName + ",service=" + EJBBinder.class.getSimpleName(); BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(beanInstanceName, EJBBinder.class.getName()); builder.addConstructorParameter( SessionBeanType.class.getName(), builder.createInject(sessionBeanTypeName)); builder.addPropertyMetaData( "globalContext", builder.createInject("NameSpaces", "globalContext")); builder.addPropertyMetaData("proxyFactory", sessionBeanMetaData.isStateless() ? lazy : legacy); builder.setStart("bind"); builder.setStop("unbind"); for (DependencyBuilder db : builders) db.buildDependency(unit, builder); unit.getParent().addAttachment(beanInstanceName, builder.getBeanMetaData()); }
public void assertFullSessionBean(String ejbName, JBossSessionBeanMetaData session, Mode mode) { assertId(ejbName, session); assertMappedName(ejbName, session.getMappedName()); assertClass(ejbName, "Home", session.getHome()); assertClass(ejbName, "Remote", session.getRemote()); assertClass(ejbName, "LocalHome", session.getLocalHome()); assertClass(ejbName, "Local", session.getLocal()); assertClasses(ejbName, "BusinessLocal", 2, session.getBusinessLocals()); assertClasses(ejbName, "BusinessRemote", 2, session.getBusinessRemotes()); assertClass(ejbName, "ServiceEndpoint", session.getServiceEndpoint()); assertClass(ejbName, "EjbClass", session.getEjbClass()); assertEquals(SessionType.Stateless, session.getSessionType()); assertNamedMethod(ejbName + "TimeoutMethod", 2, session.getTimeoutMethod()); assertInitMethods(ejbName, 2, session.getInitMethods()); assertRemoveMethods(ejbName, 3, session.getRemoveMethods()); assertEquals(TransactionManagementType.CONTAINER, session.getTransactionType()); assertAroundInvokes(ejbName, 2, session.getAroundInvokes()); assertLifecycleCallbacks(ejbName, "PostActivate", 2, session.getPostActivates()); assertLifecycleCallbacks(ejbName, "PrePassivate", 2, session.getPrePassivates()); assertEnvironment(ejbName, session.getJndiEnvironmentRefsGroup(), true, mode); assertContainerTransactions(ejbName, 6, 6, session.getContainerTransactions()); assertMethodPermissions( ejbName, ejbName + "MethodPermission", 3, 3, session.getMethodPermissions()); assertExcludeList(ejbName, 5, 5, session.getExcludeList()); assertSecurityRoleRefs(ejbName, 2, session.getSecurityRoleRefs()); assertSecurityIdentity(ejbName, "SecurityIdentity", session.getSecurityIdentity(), true, mode); }