dblevins    2004/08/26 03:20:26

  Modified:    modules/core/src/java/org/openejb/core/entity
                        EntityContainer.java
  Log:

  Last changes on getting local interface support to work
  
  Revision  Changes    Path
  1.3       +20 -16    
openejb1/modules/core/src/java/org/openejb/core/entity/EntityContainer.java
  
  Index: EntityContainer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/core/entity/EntityContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntityContainer.java      26 Aug 2004 06:00:46 -0000      1.2
  +++ EntityContainer.java      26 Aug 2004 07:20:26 -0000      1.3
  @@ -51,6 +51,7 @@
   
   import javax.ejb.EJBHome;
   import javax.ejb.EJBLocalHome;
  +import javax.ejb.EJBLocalObject;
   import javax.ejb.EJBObject;
   import javax.ejb.EnterpriseBean;
   import javax.ejb.EntityBean;
  @@ -240,26 +241,29 @@
           if(!authorized)
               throw new org.openejb.ApplicationException(new 
RemoteException("Unauthorized Access by Principal Denied"));
   
  +        Class declaringClass = callMethod.getDeclaringClass();
  +        String methodName = callMethod.getName();
  +        
           // process home interface methods
  -        if(EJBHome.class.isAssignableFrom(callMethod.getDeclaringClass()) || 
EJBLocalHome.class.isAssignableFrom(callMethod.getDeclaringClass()) ){
  -            if(callMethod.getDeclaringClass() != EJBHome.class && 
callMethod.getDeclaringClass() != EJBLocalHome.class){
  +             if(EJBHome.class.isAssignableFrom(declaringClass) || 
EJBLocalHome.class.isAssignableFrom(declaringClass) ){
  +                     if(declaringClass != EJBHome.class && declaringClass != 
EJBLocalHome.class){
               // Its a home interface method, which is declared by the bean provider, 
but not a EJBHome method.
               // only create(), find<METHOD>( ) and home business methods are 
declared by the bean provider.
  -                if(callMethod.getName().equals("create")){
  +                if(methodName.equals("create")){
                       // create( ) method called, execute ejbCreate() method
                       return createEJBObject(callMethod, args, callContext);
  -                }else if(callMethod.getName().startsWith("find")){
  +                }else if(methodName.startsWith("find")){
                       // find<METHOD> called, execute ejbFind<METHOD>
                       return findMethod(callMethod, args, callContext);
                   }else{
                       // home method called, execute ejbHome method
                       return homeMethod(callMethod, args, callContext);
                   }
  -            }else if(callMethod.getName().equals("remove")){
  +            }else if(methodName.equals("remove")){
                   removeEJBObject(callMethod, args, callContext);
                   return null;
               }
  -        } else if(EJBObject.class == callMethod.getDeclaringClass()){
  +        } else if((EJBObject.class == declaringClass || EJBLocalObject.class == 
declaringClass) && methodName.equals("remove") ) {
               removeEJBObject(callMethod, args, callContext);
               return null;
           }
  @@ -512,11 +516,8 @@
           }
           
           Class callingClass = callMethod.getDeclaringClass();
  -             if (EJBLocalHome.class.isAssignableFrom(callingClass)) {
  -            return new ProxyInfo(deploymentInfo, primaryKey, 
deploymentInfo.getLocalInterface(), this);
  -        } else {
  -            return new ProxyInfo(deploymentInfo, primaryKey, 
deploymentInfo.getRemoteInterface(), this);
  -        }
  +             boolean isLocalInterface = 
EJBLocalHome.class.isAssignableFrom(callingClass);
  +        return new ProxyInfo(deploymentInfo, primaryKey, isLocalInterface, this);
           
           
       }
  @@ -543,6 +544,9 @@
           Method runMethod = deploymentInfo.getMatchingBeanMethod(callMethod);
           Object returnValue = invoke(callMethod,runMethod, args, callContext);
   
  +        Class callingClass = callMethod.getDeclaringClass();
  +             boolean isLocalInterface = 
EJBLocalHome.class.isAssignableFrom(callingClass);
  +
           /*
           * Find operations return either a single primary key or a collection of 
primary keys.
           * The primary keys are converted to ProxyInfo objects.
  @@ -552,7 +556,7 @@
               java.util.Vector proxies = new java.util.Vector();
               while(keys.hasNext()){
                   Object primaryKey = keys.next();
  -                proxies.addElement(new ProxyInfo(deploymentInfo, primaryKey, 
deploymentInfo.getRemoteInterface(), this));
  +                proxies.addElement(new ProxyInfo(deploymentInfo, primaryKey, 
isLocalInterface, this));
               }
               returnValue = proxies;
           }else if(returnValue instanceof java.util.Enumeration){
  @@ -560,11 +564,11 @@
               java.util.Vector proxies = new java.util.Vector();
               while(keys.hasMoreElements()){
                   Object primaryKey = keys.nextElement();
  -                proxies.addElement(new ProxyInfo(deploymentInfo, primaryKey, 
deploymentInfo.getRemoteInterface(), this));
  +                proxies.addElement(new ProxyInfo(deploymentInfo, primaryKey, 
isLocalInterface, this));
               }
               returnValue = new org.openejb.util.ArrayEnumeration(proxies);
           }else
  -            returnValue = new ProxyInfo(deploymentInfo, returnValue, 
deploymentInfo.getRemoteInterface(), this);
  +            returnValue = new ProxyInfo(deploymentInfo, returnValue, 
isLocalInterface, this);
   
           return returnValue;
       }
  
  
  

Reply via email to