String name = sb.getEjbName(); String type = sb.getSessionType().toString(); for(String iface : sb.getBusinessLocal()) { added = true; registry.addEJBView(name, type, iface, false); for(String iface : sb.getBusinessRemote()) { added = true; registry.addEJBView(name, type, iface, true); if(sb.getLocal() != null) { added = true; registry.addEJBView(name, type, sb.getLocal(), false); if(sb.getLocalHome() != null) { added = true; registry.addEJBView(name, type, sb.getLocalHome(), false); if(sb.getRemote() != null) { added = true; registry.addEJBView(name, type, sb.getRemote(), true); if(sb.getHome() != null) { added = true; registry.addEJBView(name, type, sb.getHome(), true); registry.addEJBView(name, type, sb.getEjbClass(), false);
public void addBusinessLocal(final Class businessLocal) { addBusinessLocal(businessLocal.getName()); }
public void addBusinessRemote(final Class businessRemote) { addBusinessRemote(businessRemote.getName()); }
if (s.getSessionType() == SessionType.STATEFUL) { bean = new StatefulBeanInfo(); bean.passivable = s.getPassivationCapable() == null || s.getPassivationCapable(); final StatefulBeanInfo stateful = (StatefulBeanInfo) bean; copyCallbacks(s.getPostActivate(), stateful.postActivate); copyCallbacks(s.getPrePassivate(), stateful.prePassivate); copyCallbacks(s.getAfterBegin(), stateful.afterBegin); copyCallbacks(s.getBeforeCompletion(), stateful.beforeCompletion); copyCallbacks(s.getAfterCompletion(), stateful.afterCompletion); for (final InitMethod initMethod : s.getInitMethod()) { final InitMethodInfo init = new InitMethodInfo(); init.beanMethod = toInfo(initMethod.getBeanMethod()); for (final RemoveMethod removeMethod : s.getRemoveMethod()) { final RemoveMethodInfo remove = new RemoveMethodInfo(); remove.beanMethod = toInfo(removeMethod.getBeanMethod()); } else if (s.getSessionType() == SessionType.MANAGED) { bean = new ManagedBeanInfo(); final ManagedBeanInfo managed = (ManagedBeanInfo) bean; copyCallbacks(s.getPostActivate(), managed.postActivate); copyCallbacks(s.getPrePassivate(), managed.prePassivate); for (final RemoveMethod removeMethod : s.getRemoveMethod()) { final RemoveMethodInfo remove = new RemoveMethodInfo();
if (s.getSessionType() == SessionType.STATEFUL) { bean = new StatefulBeanInfo(); StatefulBeanInfo stateful = ((StatefulBeanInfo) bean); stateful.localbean = s.getLocalBean() != null; copyCallbacks(s.getPostActivate(), stateful.postActivate); copyCallbacks(s.getPrePassivate(), stateful.prePassivate); for (InitMethod initMethod : s.getInitMethod()) { InitMethodInfo init = new InitMethodInfo(); init.beanMethod = toInfo(initMethod.getBeanMethod()); for (RemoveMethod removeMethod : s.getRemoveMethod()) { RemoveMethodInfo remove = new RemoveMethodInfo(); remove.beanMethod = toInfo(removeMethod.getBeanMethod()); } else if (s.getSessionType() == SessionType.MANAGED) { bean = new ManagedBeanInfo(); ManagedBeanInfo managed = ((ManagedBeanInfo) bean); copyCallbacks(s.getPostActivate(), managed.postActivate); copyCallbacks(s.getPrePassivate(), managed.prePassivate); for (RemoveMethod removeMethod : s.getRemoveMethod()) { RemoveMethodInfo remove = new RemoveMethodInfo(); remove.beanMethod = toInfo(removeMethod.getBeanMethod()); } else if (s.getSessionType() == SessionType.SINGLETON) { bean = new SingletonBeanInfo();
String ejbName = sessionBean.getEjbName(); descriptor.add(sessionBean.getHome()); descriptor.add(sessionBean.getRemote()); descriptor.add(sessionBean.getLocalHome()); descriptor.add(sessionBean.getLocal()); descriptor.addAll(sessionBean.getBusinessLocal()); descriptor.addAll(sessionBean.getBusinessRemote()); descriptor.add(sessionBean.getServiceEndpoint()); xml.addLocals(sessionBean.getBusinessLocal(), ejbModule.getClassLoader()); xml.addRemotes(sessionBean.getBusinessRemote(), ejbModule.getClassLoader()); if (sessionBean.getServiceEndpoint() == null) { Class defaultEndpoint = DeploymentInfo.ServiceEndpoint.class; sessionBean.setServiceEndpoint(className); } else { sessionBean.setServiceEndpoint(defaultEndpoint.getName()); sessionBean.setServiceEndpoint(defaultEndpoint.getName()); } else if (!defaultEndpoint.equals(DeploymentInfo.ServiceEndpoint.class)) { sessionBean.setServiceEndpoint(defaultEndpoint.getName()); for (Class interfce : all.local) sessionBean.addBusinessLocal(interfce); for (Class interfce : all.remote) sessionBean.addBusinessRemote(interfce); for (Class interfce : all.unspecified) sessionBean.addBusinessLocal(interfce);
if (session.getSessionType() == SessionType.STATEFUL) { for (final LifecycleCallback callback : session.getPrePassivate()) { checkCallback(ejbClass, "PrePassivate", callback, bean); for (final LifecycleCallback callback : session.getPostActivate()) { checkCallback(ejbClass, "PostActivate", callback, bean); for (final LifecycleCallback callback : session.getAfterBegin()) { checkCallback(ejbClass, "AfterBegin", callback, bean); for (final LifecycleCallback callback : session.getBeforeCompletion()) { checkCallback(ejbClass, "BeforeCompletion", callback, bean); for (final LifecycleCallback callback : session.getAfterCompletion()) { checkCallback(ejbClass, "AfterCompletion", callback, bean, boolean.class); for (final AroundTimeout aroundTimeout : session.getAroundTimeout()) { ignoredMethodAnnotation("AroundTimeout", bean, bean.getEjbClass(), aroundTimeout.getMethodName(), SessionType.STATEFUL.getName()); for (final Timer timer : session.getTimer()) { ignoredMethodAnnotation("Schedule/Schedules", bean, bean.getEjbClass(), timer.getTimeoutMethod().getMethodName(), SessionType.STATEFUL.getName()); for (final LifecycleCallback callback : session.getAfterBegin()) { ignoredMethodAnnotation("AfterBegin", bean, bean.getEjbClass(), callback.getMethodName(), session.getSessionType().getName()); for (final LifecycleCallback callback : session.getBeforeCompletion()) { ignoredMethodAnnotation("BeforeCompletion", bean, bean.getEjbClass(), callback.getMethodName(), session.getSessionType().getName());
if (sessionBean.getServiceEndpoint() == null) continue; sessionBean.setServiceEndpoint(null); if (sessionBean.getHome() != null) continue; if (sessionBean.getLocalHome() != null) continue; if (sessionBean.getBusinessLocal().size() > 0) continue; if (sessionBean.getBusinessRemote().size() > 0) continue;
sessionBean.getParents().add(clazz.getName()); if (!clazz.isInterface()) { for (Class<?> current = clazz.getSuperclass(); !current.equals(Object.class); current = current.getSuperclass()) { sessionBean.getParents().add(current.getName()); if (sessionBean.getDependsOn() == null) { final DependsOn dependsOn = getInheritableAnnotation(clazz, DependsOn.class); if (dependsOn != null) { sessionBean.setDependsOn(dependsOn.value()); } else { sessionBean.setDependsOn(Collections.EMPTY_LIST); if (sessionBean.getSessionType() != SessionType.STATEFUL) { sessionBean.setRestService(true); if (sessionBean.getSessionType() == SessionType.SINGLETON) { if (sessionBean.getConcurrencyManagementType() == null) { final ConcurrencyManagement tx = getInheritableAnnotation(clazz, ConcurrencyManagement.class); javax.ejb.ConcurrencyManagementType concurrencyType = javax.ejb.ConcurrencyManagementType.CONTAINER; sessionBean.setConcurrencyManagementType(ConcurrencyManagementType.BEAN); break; case CONTAINER: sessionBean.setConcurrencyManagementType(ConcurrencyManagementType.CONTAINER); break; if (sessionBean.getConcurrencyManagementType() == ConcurrencyManagementType.CONTAINER) {
if (sessionBean.getSessionType() == SessionType.STATEFUL) continue; if (sessionBean.getSessionType() == SessionType.MANAGED) continue; if (sessionBean.getServiceEndpoint() == null) continue; EjbDeployment deployment = deploymentsByEjbName.get(sessionBean.getEjbName()); if (deployment == null) continue; ejbClass = ejbModule.getClassLoader().loadClass(sessionBean.getEjbClass()); } catch (ClassNotFoundException e) { throw new OpenEJBException("Unable to load ejb class: " + sessionBean.getEjbClass(), e); PortComponent portComponent = portMap.get(sessionBean.getEjbName()); if (portComponent == null) { portComponent = new PortComponent(); portComponent.setPortComponentName(sessionBean.getEjbName()); serviceImplBean.setEjbLink(sessionBean.getEjbName()); portComponent.setServiceImplBean(serviceImplBean); portComponent.setServiceEndpointInterface(sessionBean.getServiceEndpoint()); HandlerChains handlerChains = getHandlerChains(ejbClass, sessionBean.getServiceEndpoint(), ejbModule.getClassLoader()); portComponent.setHandlerChains(handlerChains);
final SessionBean sessionBean = (SessionBean) bean; if (sessionBean.getSessionType() == STATEFUL && SessionSynchronization.class.isAssignableFrom(clazz)) { try { sessionBean.getAfterBegin().add(new LifecycleCallback(clazz.getMethod("afterBegin"))); sessionBean.getBeforeCompletion().add(new LifecycleCallback(clazz.getMethod("beforeCompletion"))); sessionBean.getAfterCompletion().add(new LifecycleCallback(clazz.getMethod("afterCompletion", boolean.class))); } catch (final NoSuchMethodException e) { ref.getInjectionTarget().add(target); sessionBean.getResourceEnvRef().add(ref);
SessionBean session = (SessionBean) bean; if (session.getSessionType() == SessionType.STATEFUL ) { for (LifecycleCallback callback : session.getPrePassivate()) { checkCallback(ejbClass, "PrePassivate", callback, bean); for (LifecycleCallback callback : session.getPostActivate()) { checkCallback(ejbClass, "PostActivate", callback, bean); for (LifecycleCallback callback : session.getPrePassivate()) { ignoredStatefulAnnotation("PrePassivate", bean, callback.getMethodName(), session.getSessionType().getName()); for (LifecycleCallback callback : session.getPostActivate()) { ignoredStatefulAnnotation("PostActivate", bean, callback.getMethodName(), session.getSessionType().getName()); for (RemoveMethod method : session.getRemoveMethod()) { ignoredStatefulAnnotation("Remove", bean, method.getBeanMethod().getMethodName(), session.getSessionType().getName()); for (InitMethod method : session.getInitMethod()) { ignoredStatefulAnnotation("Init", bean, method.getBeanMethod().getMethodName(), session.getSessionType().getName());
if (bean instanceof SessionBean && ((SessionBean) bean).getProxy() != null) { continue; final SessionBean sessionBean = (SessionBean) b; for (final String interfce : sessionBean.getBusinessLocal()) { checkInterface(b, beanClass, "business-local", interfce); for (final String interfce : sessionBean.getBusinessRemote()) { checkInterface(b, beanClass, "business-remote", interfce);
private String getType(EnterpriseBean bean) { if (bean instanceof SessionBean) { SessionBean sessionBean = (SessionBean) bean; switch(sessionBean.getSessionType()){ case STATEFUL: return "Stateful"; case STATELESS: return "Stateless"; case SINGLETON: return "Singleton"; case MANAGED: return "Managed"; default: throw new IllegalArgumentException("Uknown SessionBean type "+bean.getClass()); } } else if (bean instanceof MessageDrivenBean) return "MessageDriven"; else if (bean instanceof EntityBean) return "EJB 2.1 Entity"; else throw new IllegalArgumentException("Uknown bean type "+bean.getClass()); } }
if (sessionBean.getSessionType() == SessionType.SINGLETON) { if (sessionBean.getConcurrencyType() == null) { ConcurrencyManagement tx = getInheritableAnnotation(clazz, ConcurrencyManagement.class); ConcurrencyManagementType concurrencyType = ConcurrencyManagementType.CONTAINER; sessionBean.setConcurrencyType(ConcurrencyType.BEAN); break; case CONTAINER: sessionBean.setConcurrencyType(ConcurrencyType.CONTAINER); break; if (sessionBean.getConcurrencyType() == ConcurrencyType.CONTAINER) { processAttributes(new ConcurrencyAttributeHandler(assemblyDescriptor, ejbName), clazz, inheritedClassFinder); } else { if (!sessionBean.hasLoadOnStartup()) { Startup startup = getInheritableAnnotation(clazz, Startup.class); sessionBean.setLoadOnStartup(startup != null); if (sessionBean.getDependsOn() == null) { DependsOn dependsOn = getInheritableAnnotation(clazz, DependsOn.class); if (dependsOn != null) { sessionBean.setDependsOn(dependsOn.value()); } else { sessionBean.setDependsOn(Collections.EMPTY_LIST);
if (sessionBean.getSessionType() != null) { continue; sessionBean.setSessionType(getSessionType(clazz)); } catch (final Throwable handledInValidation) { sessionBean.setSessionType(SessionType.SINGLETON); sessionBean.setMappedName(singleton.mappedName()); sessionBean.setSessionType(SessionType.STATELESS); sessionBean.setMappedName(stateless.mappedName()); final SessionBean sessionBean = (SessionBean) enterpriseBean; sessionBean.setSessionType(SessionType.STATEFUL); if (stateful.mappedName() != null) { sessionBean.setMappedName(stateful.mappedName()); if (sessionBean.getPassivationCapable() == null) { sessionBean.setPassivationCapable(stateful.passivationCapable()); sessionBean.setSessionType(SessionType.MANAGED); final TransactionType transactionType = sessionBean.getTransactionType(); if (transactionType == null) { sessionBean.setTransactionType(TransactionType.BEAN);
public void buildDependsOnRefs(EjbModule module, EnterpriseBean enterpriseBean, EnterpriseBeanInfo beanInfo, String moduleId) throws OpenEJBException { if (!(enterpriseBean instanceof SessionBean)) return; SessionBean sessionBean = (SessionBean) enterpriseBean; if (sessionBean.getSessionType() != SessionType.SINGLETON) return; URI moduleUri = null; if (moduleId != null) { try { moduleUri = new URI(moduleId); } catch (URISyntaxException e) { throw new OpenEJBException("Illegal moduleId " + moduleId, e); } } EjbResolver ejbResolver = getEjbResolver(moduleId); for (String ejbName : sessionBean.getDependsOn()) { String deploymentId = ejbResolver.resolve(new SimpleRef(ejbName), moduleUri); if (deploymentId != null) { beanInfo.dependsOn.add(deploymentId); } } }
if (sessionBean.getSessionType() != null) { continue; sessionBean.setSessionType(getSessionType(clazz)); } catch (final Throwable handledInValidation) { sessionBean.setSessionType(SessionType.SINGLETON); sessionBean.setMappedName(singleton.mappedName()); sessionBean.setSessionType(SessionType.STATELESS); sessionBean.setMappedName(stateless.mappedName()); final SessionBean sessionBean = (SessionBean) enterpriseBean; sessionBean.setSessionType(SessionType.STATEFUL); if (stateful.mappedName() != null) { sessionBean.setMappedName(stateful.mappedName()); sessionBean.setSessionType(SessionType.MANAGED); final TransactionType transactionType = sessionBean.getTransactionType(); if (transactionType == null) { sessionBean.setTransactionType(TransactionType.BEAN);
SessionBean sessionBean = (SessionBean) b; for (String interfce : sessionBean.getBusinessLocal()) { checkInterface(b, beanClass, "business-local", interfce); for (String interfce : sessionBean.getBusinessRemote()) { checkInterface(b, beanClass, "business-remote", interfce);
public AppModule deploy(AppModule appModule) throws OpenEJBException { for (org.apache.openejb.config.EjbModule ejbModule : appModule.getEjbModules()) { OpenejbJar openejbJar = ejbModule.getOpenejbJar(); EjbJar ejbJar = ejbModule.getEjbJar(); for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) { if (enterpriseBean instanceof SessionBean) { SessionBean sessionBean = (SessionBean) enterpriseBean; switch (sessionBean.getSessionType()) { case STATEFUL: String ejbName = sessionBean.getEjbName(); EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(ejbName); if (null == ejbDeployment) { throw new OpenEJBException("No ejbDeployment for ejbName [" + ejbName + "]"); } ejbDeployment.setContainerId(containerId); } } } } return appModule; } }