[jboss-dev-forums] [Design of EJB 3.0] - Re: Mandating the presence of local/remote interface in Sess

jaikiran do-not-reply at jboss.com
Wed May 20 05:41:19 EDT 2009


I was planning to reimplement the resolveBusinessInterfaces method in SessionContainer to (use metadata):

Index: src/main/java/org/jboss/ejb3/session/SessionContainer.java                           
  | ===================================================================                         
  | --- src/main/java/org/jboss/ejb3/session/SessionContainer.java  (revision 89162)            
  | +++ src/main/java/org/jboss/ejb3/session/SessionContainer.java  (working copy)              
  | @@ -26,7 +26,6 @@                                                                           
  |  import java.rmi.NoSuchObjectException;                                                     
  |  import java.rmi.Remote;                                                                    
  |  import java.util.ArrayList;                                                                
  | -import java.util.Arrays;                                                                   
  |  import java.util.Hashtable;                                                                
  |  import java.util.List;                                                                     
  |  import java.util.Map;                                                                      
  | @@ -62,7 +61,6 @@                                                                           
  |  import org.jboss.ejb3.endpoint.SessionFactory;                                             
  |  import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;            
  |  import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;                    
  | -import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;                                    
  |  import org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory;                      
  |  import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase;                   
  |  import org.jboss.ejb3.proxy.spi.container.InvokableContext;                                
  | @@ -71,6 +69,8 @@                                                                           
  |  import org.jboss.ha.framework.server.HATarget;                                             
  |  import org.jboss.logging.Logger;                                                           
  |  import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;                              
  | +import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;                                 
  | +import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;                                
  |  import org.jboss.serial.io.MarshalledObjectForLocalCalls;                                  
  |                                                                                             
  |  /**                                                                                        
  | @@ -187,12 +187,43 @@                                                                       
  |     @Override                                                                               
  |     protected List<Class<?>> resolveBusinessInterfaces()                                    
  |     {                                                                                       
  | -      // Obtain all business interfaces                                                    
  | -      List<Class<?>> list = new ArrayList<Class<?>>();                                     
  | -      list.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(this)));     
  | -      list.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(this)));
  | -
  | -      return list;
  | +      // first find business locals
  | +      BusinessLocalsMetaData businessLocals = this.getMetaData().getBusinessLocals();
  | +      List<Class<?>> businessInterfaces = new ArrayList<Class<?>>();
  | +      for (String businessLocal : businessLocals)
  | +      {
  | +         try
  | +         {
  | +            Class<?> localBusinessInterface = this.classloader.loadClass(businessLocal);
  | +            businessInterfaces.add(localBusinessInterface);
  | +
  | +         }
  | +         catch (ClassNotFoundException cnfe)
  | +         {
  | +            throw new RuntimeException("Business local interface " + businessLocal + " for bean " + this.getEjbName()
  | +                  + " , in deployment " + this.getDeploymentUnit() + " , could not be found", cnfe);
  | +         }
  | +
  | +      }
  | +      // now business remotes
  | +      BusinessRemotesMetaData businessRemotes = this.getMetaData().getBusinessRemotes();
  | +      for (String businessRemote : businessRemotes)
  | +      {
  | +         try
  | +         {
  | +            Class<?> remoteBusinessInterface = this.classloader.loadClass(businessRemote);
  | +            businessInterfaces.add(remoteBusinessInterface);
  | +
  | +         }
  | +         catch (ClassNotFoundException cnfe)
  | +         {
  | +            throw new RuntimeException("Business remote interface " + businessRemote + " for bean " + this.getEjbName()
  | +                  + " , in deployment " + this.getDeploymentUnit() + " , could not be found", cnfe);
  | +         }
  | +
  | +      }
  | +      // return the business interfaces (local and remote)
  | +      return businessInterfaces;
  |     }
  | 

But looking at the earlier implementation, it used to take care of infering the EJB2.x style local interface from the @LocalHome (and similar for remote interface from @RemoteHome). I am not sure the metadata approach can handle that. 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4232165#4232165

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4232165



More information about the jboss-dev-forums mailing list