/** * Retusn the type of the ejb to whioch I refer. */ @Override public String getType() { if (ejbDescriptor==null) { return refType; } else { return ejbDescriptor.getType(); } }
/** * Retusn the type of the ejb to whioch I refer. */ public String getType() { if (ejbDescriptor==null) { return refType; } else { return ejbDescriptor.getType(); } }
/** * Check if the given EjbDescriptor matches the given Annotation. * @param ejbDesc * @param annotation * @return boolean check for validity of EjbDescriptor */ protected boolean isValidEjbDescriptor(EjbDescriptor ejbDesc, Annotation annotation) { return EjbMessageBeanDescriptor.TYPE.equals(ejbDesc.getType()); }
/** * Indicates if the EJB is and MDB * * @return True if the bean is an MDB, false otherwise */ public boolean isMessageDriven() { return (ejbDesc.getType().equals(EjbMessageBeanDescriptor.TYPE)); }
/** * Indicates if the bean is stateless * * @return True if stateless, false otherwise */ public boolean isStateless() { return (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) && ((EjbSessionDescriptor) ejbDesc).isStateless()); }
/** * Indicates if the bean is a EJB 3.1 Singleton * * @return True if the bean is a singleton, false otherwise */ public boolean isSingleton() { return (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) && ((EjbSessionDescriptor) ejbDesc).isSingleton()); }
/** * Indicates if the EJB is stateful * * @return True if the bean is stateful, false otherwise */ public boolean isStateful() { return (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) && ((EjbSessionDescriptor) ejbDesc).isStateful()); }
public EjbDescriptorImpl(EjbDescriptor ejbDescriptor) { ejbDesc = ejbDescriptor; if ( ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) || ejbDesc.getType().equals(EjbMessageBeanDescriptor.TYPE ) ) { // Before handling application-level interceptors that are defined using 299 metadata, // add the CDI impl-specific system-level interceptor that needs to be registered for ALL // EJB components. At runtime, this sets up the appropriate request context for invocations that // do not originate via the web tier. This interceptor must be registered *before* // any application-level interceptors in the chain, so add it in the framework interceptor // category within the ejb descriptor. EjbInterceptor systemLevelCDIInterceptor = createSystemLevelCDIInterceptor(); ejbDesc.addFrameworkInterceptor(systemLevelCDIInterceptor); } }
/** * Check if the given EjbDescriptor matches the given Annotation. * @param ejbDesc * @param annotation * @return boolean check for validity of EjbDescriptor */ protected boolean isValidEjbDescriptor(EjbDescriptor ejbDesc, Annotation annotation) { boolean isValid = EjbSessionDescriptor.TYPE.equals(ejbDesc.getType()); if( isValid ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; // Only check specific session-bean type if it's set in the descriptor. // Otherwise it was probably populated with a sparse ejb-jar.xml and // we'll set the type later. if( sessionDesc.isSessionTypeSet() && !sessionDesc.isStateful() ) { isValid = false; } } return isValid; }
/** * Check if the given EjbDescriptor matches the given Annotation. * @param ejbDesc * @param annotation * @return boolean check for validity of EjbDescriptor */ protected boolean isValidEjbDescriptor(EjbDescriptor ejbDesc, Annotation annotation) { boolean isValid = EjbSessionDescriptor.TYPE.equals(ejbDesc.getType()); if( isValid ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; // Only check specific session-bean type if it's set in the descriptor. // Otherwise it was probably populated with a sparse ejb-jar.xml and // we'll set the type later. if( sessionDesc.isSessionTypeSet() && !sessionDesc.isStateless() ) { isValid = false; } } return isValid; }
/** * Check if the given EjbDescriptor matches the given Annotation. * @param ejbDesc * @param annotation * @return boolean check for validity of EjbDescriptor */ protected boolean isValidEjbDescriptor(EjbDescriptor ejbDesc, Annotation annotation) { boolean isValid = EjbSessionDescriptor.TYPE.equals(ejbDesc.getType()); if( isValid ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; // Only check specific session-bean type if it's set in the descriptor. // Otherwise it was probably populated with a sparse ejb-jar.xml and // we'll set the type later. if( sessionDesc.isSessionTypeSet() && !sessionDesc.isSingleton() ) { isValid = false; } } return isValid; }
final String ejbType = ejbDescriptor.getType(); final String ejbSessionType = ejbType.equals("Session") ? ((EjbSessionDescriptor) ejbDescriptor).getSessionType() : null;
/** * Designate a method as asynchronous in the deployment descriptor * @param methodIntf null if processed on bean class / superclass. Otherwise, * set to the remote/local client view of the associated interface * @throws AnnotationProcessorException */ private void setAsynchronous(Method m0, EjbDescriptor ejbDesc, String methodIntf) throws AnnotationProcessorException { if( !ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) { throw new AnnotationProcessorException("Invalid asynchronous method " + m0 + "@Asynchronous is only permitted for session beans"); } EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; MethodDescriptor methodDesc = (methodIntf == null) ? new MethodDescriptor(m0) : new MethodDescriptor(m0, methodIntf); if (logger.isLoggable(Level.FINE)) { logger.fine("Adding asynchronous method " + methodDesc); } // There is no way to "turn off" the asynchronous designation in the // deployment descriptor, so we don't need to do any override checks // here. Just always add any async methods. sessionDesc.addAsynchronousMethod(methodDesc); }
Set<BusinessInterfaceDescriptor<?>> remoteBusIntfs = new HashSet<BusinessInterfaceDescriptor<?>>(); if( ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) ) {
/** * Get the remove methods of the EJB * * @return An iterator over the remove methods */ public Collection<Method> getRemoveMethods() { Set<Method> removeMethods = new HashSet<Method>(); if( ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; if( sessionDesc.isStateful() && sessionDesc.hasRemoveMethods() ) { for(MethodDescriptor mDesc : sessionDesc.getRemoveMethodDescriptors()) { Method m = mDesc.getMethod(ejbDesc); if( m == null ) { throw new IllegalStateException("Can't resolve remove method " + mDesc + " For EJB " + sessionDesc.getName()); } removeMethods.add(m); } } } return removeMethods; }
/** * Since ejb-class is optional, in some cases the lifecycle-class * for AroundInvoke, PostConstruct, etc. methods on the bean-class * is not known at processing time and must be applied lazily. As such, * this method should only be called if the ejb-class has been set * on this EjbDescriptor. */ public void applyDefaultClassToLifecycleMethods() { Set<LifecycleCallbackDescriptor> lifecycleMethods = new HashSet<LifecycleCallbackDescriptor>(); lifecycleMethods.addAll(getAroundInvokeDescriptors()); lifecycleMethods.addAll(getAroundTimeoutDescriptors()); lifecycleMethods.addAll(getPostConstructDescriptors()); lifecycleMethods.addAll(getPreDestroyDescriptors()); if (getType().equals(EjbSessionDescriptor.TYPE)) { EjbSessionDescriptor sfulDesc = (EjbSessionDescriptor) this; lifecycleMethods.addAll(sfulDesc.getPrePassivateDescriptors()); lifecycleMethods.addAll(sfulDesc.getPostActivateDescriptors()); } for (LifecycleCallbackDescriptor next : lifecycleMethods) { if (next.getLifecycleCallbackClass() == null) { next.setLifecycleCallbackClass(getEjbClassName()); } } }
/** visits an ejb bundle descriptor * @param bundleDescriptor ejb bundle descriptor */ public void accept(EjbBundleDescriptor bundleDescriptor) { if (bundleDescriptor.getEjbs().size() == 0) { throw new IllegalArgumentException(localStrings.getLocalString( "enterprise.deployment.util.no_ejb_in_ejb_jar", "Invalid ejb jar {0}: it contains zero ejb. A valid ejb jar requires at least one session/entity/message driven bean.", new Object[] {bundleDescriptor.getModuleDescriptor().getArchiveUri()})); } if (!bundleDescriptor.areResourceReferencesValid()) { throw new RuntimeException("Incorrectly resolved role references"); } this.ejbBundleDescriptor = bundleDescriptor; // Now that we have a classloader, we have to check for any // interceptor bindings that were specified in .xml to use // the syntax that refers to all overloaded methods with a // given name. handleOverloadedInterceptorMethodBindings(bundleDescriptor); InterceptorBindingTranslator bindingTranslator = new InterceptorBindingTranslator(bundleDescriptor); for(Iterator iter = bundleDescriptor.getEjbs().iterator(); iter.hasNext();) { EjbDescriptor ejb = (EjbDescriptor) iter.next(); if( ejb.getType() != EjbEntityDescriptor.TYPE ) { ejb.applyInterceptors(bindingTranslator); } } }
public boolean isRemoved(Object ejbRef) { EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef); if( localObjectImpl == null ) { throw new UnsupportedOperationException("Invalid ejb ref"); } Container container = localObjectImpl.getContainer(); EjbDescriptor ejbDesc = container.getEjbDescriptor(); boolean isStatefulBean = false; if( ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; isStatefulBean = sessionDesc.isStateful(); } if( !isStatefulBean ) { // TODO 299 impl is incorrectly calling isRemoved for stateless/singleton // beans. Until it's fixed just return false. Otherwise, any app acquiring // stateless/singleton references via 299 will fail until bug is fixed. return false; // TODO reenable this per SessionObjectReference.isRemoved SPI //throw new UnsupportedOperationException("ejbRef for ejb " + // ejbDesc.getName() + " is not a stateful bean "); } boolean removed = false; try { ((BaseContainer)container).checkExists(localObjectImpl); } catch(Exception e) { removed = true; } return removed; }
public void remove(Object ejbRef) { EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef); if( localObjectImpl == null ) { throw new UnsupportedOperationException("Invalid ejb ref"); } Container container = localObjectImpl.getContainer(); EjbDescriptor ejbDesc = container.getEjbDescriptor(); boolean isStatefulBean = false; if( ejbDesc.getType().equals(EjbSessionDescriptor.TYPE) ) { EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc; isStatefulBean = sessionDesc.isStateful(); } if( !isStatefulBean ) { // TODO 299 impl may incorrectly call this for stateless/singleton // beans. Until it's fixed just treat it as a no-op. Otherwise, any app acquiring // stateless/singleton references via 299 could fail until bug is fixed. return; // TODO reenable this after bug is fixed //throw new UnsupportedOperationException("ejbRef for ejb " + // ejbDesc.getName() + " is not a stateful bean "); } try { localObjectImpl.remove(); } catch(EJBException e) { _logger.log(Level.FINE, "EJBException during remove. ", e); } catch(javax.ejb.RemoveException re) { throw new NoSuchEJBException(re.getMessage(), re); } }
/** * visits an ejb descriptor * @param ejb descriptor */ public void accept(EjbDescriptor ejb) { DOLUtils.getDefaultLogger().info("=================="); DOLUtils.getDefaultLogger().info(ejb.getType() + " Bean " + ejb.getName()); DOLUtils.getDefaultLogger().info("\thomeClassName " + ejb.getHomeClassName()); DOLUtils.getDefaultLogger().info("\tremoteClassName " + ejb.getRemoteClassName()); DOLUtils.getDefaultLogger().info("\tlocalhomeClassName " +ejb.getLocalHomeClassName()); DOLUtils.getDefaultLogger().info("\tlocalClassName " + ejb.getLocalClassName()); DOLUtils.getDefaultLogger().info("\tremoteBusinessIntfs " + ejb.getRemoteBusinessClassNames()); DOLUtils.getDefaultLogger().info("\tlocalBusinessIntfs " + ejb.getLocalBusinessClassNames()); DOLUtils.getDefaultLogger().info("\tjndiName " + ejb.getJndiName()); DOLUtils.getDefaultLogger().info("\tejbClassName " + ejb.getEjbClassName()); DOLUtils.getDefaultLogger().info("\ttransactionType " + ejb.getTransactionType()); if (ejb.getUsesCallerIdentity() == false) { DOLUtils.getDefaultLogger().info("\trun-as role " + ejb.getRunAsIdentity()); } else { DOLUtils.getDefaultLogger().info("\tuse-caller-identity " + ejb.getUsesCallerIdentity()); } }