User: dsundstrom
  Date: 01/08/26 12:37:10

  Modified:    src/main/org/jboss/ejb/plugins/cmp/bridge
                        EntityBridgeInvocationHandler.java
                        SelectorBridge.java
  Log:
  Added ejbSelect query support.
  
  Revision  Changes    Path
  1.4       +24 -8     
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
  
  Index: EntityBridgeInvocationHandler.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EntityBridgeInvocationHandler.java        2001/08/03 17:15:45     1.3
  +++ EntityBridgeInvocationHandler.java        2001/08/26 19:37:10     1.4
  @@ -16,6 +16,7 @@
   import javax.ejb.EJBException;
   
   import org.jboss.ejb.DeploymentException;
  +import org.jboss.ejb.EntityContainer;
   import org.jboss.ejb.EntityEnterpriseContext;
   import org.jboss.proxy.InvocationHandler;
   
  @@ -32,26 +33,26 @@
    *           One per cmp entity bean instance, including beans in pool.             
 
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */                            
   public class EntityBridgeInvocationHandler implements InvocationHandler {
  +     protected EntityContainer container;
        protected EntityBridge entityBridge;
        protected Class beanClass;
        protected EntityEnterpriseContext ctx;
        protected Map cmpFieldMap;
        protected Map cmrFieldMap;
  +     protected Map selectorMap;
        
  -     public EntityBridgeInvocationHandler(EntityBridge entityBridge, Class 
beanClass) throws Exception {
  +     public EntityBridgeInvocationHandler(EntityContainer container, EntityBridge 
entityBridge, Class beanClass) throws Exception {
  +             this.container = container;
                this.entityBridge = entityBridge;
                this.beanClass = beanClass;
                Map abstractAccessors = getAbstractAccessors();
                setupCMPFieldMap(abstractAccessors);
  -             try {
                setupCMRFieldMap(abstractAccessors);
  -             } catch(Exception e) {
  -                     e.printStackTrace();
  -                     throw e;
  -             }
  +             
  +             setupSelectorMap();
        }
        
        public void setContext(EntityEnterpriseContext ctx) {
  @@ -90,8 +91,14 @@
                                return null;
                        }
                        throw new EJBException("Unknown cmr field method: " + 
methodName);
  -             }               
  +             }
                
  +             SelectorBridge selector = (SelectorBridge) selectorMap.get(method);
  +             if(selector != null) {
  +                     
container.synchronizeEntitiesWithinTransaction(ctx.getTransaction());
  +                     return selector.execute(args);
  +             }
  +             
                Exception e = new EJBException("Unknown method type: " + methodName);
                e.printStackTrace();
                throw e;
  @@ -181,6 +188,15 @@
                if(setterMethod != null) {
                        cmrFieldMap.put(setterMethod, cmrField);
                        abstractAccessors.remove(setterName);
  +             }
  +     }
  +     
  +     protected void setupSelectorMap() {
  +             SelectorBridge[] selectors = entityBridge.getSelectors();
  +             selectorMap = new HashMap(selectors.length);
  +
  +             for(int i=0; i<selectors.length; i++) {
  +                     selectorMap.put(selectors[i].getMethod(), selectors[i]);
                }
        }
   }
  
  
  
  1.3       +6 -2      
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/SelectorBridge.java
  
  Index: SelectorBridge.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/SelectorBridge.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelectorBridge.java       2001/08/03 17:15:45     1.2
  +++ SelectorBridge.java       2001/08/26 19:37:10     1.3
  @@ -7,6 +7,9 @@
    
   package org.jboss.ejb.plugins.cmp.bridge;
   
  +import java.lang.reflect.Method;
  +import javax.ejb.FinderException;
  +
   /**
    * SelectorBridge represents one ejbSelect method. 
    *
  @@ -17,11 +20,12 @@
    *           One for each entity bean ejbSelect method.              
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */                            
   public interface SelectorBridge {
        public String getSelectorName();
  +     public Method getMethod();
        public Class getReturnType();
                
  -     public Object execute(Object[] args);
  +     public Object execute(Object[] args) throws FinderException;
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to