User: juha    
  Date: 00/07/25 10:36:13

  Modified:    src/main/org/jboss/verifier/strategy EJBVerifier11.java
                        AbstractVerifier.java
  Log:
  some additional session stuff
  
  Revision  Changes    Path
  1.11      +112 -4    jboss/src/main/org/jboss/verifier/strategy/EJBVerifier11.java
  
  Index: EJBVerifier11.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/verifier/strategy/EJBVerifier11.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- EJBVerifier11.java        2000/07/22 21:23:42     1.10
  +++ EJBVerifier11.java        2000/07/25 17:36:12     1.11
  @@ -19,7 +19,7 @@
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    *
    * This package and its source code is available at www.jboss.org
  - * $Id: EJBVerifier11.java,v 1.10 2000/07/22 21:23:42 juha Exp $
  + * $Id: EJBVerifier11.java,v 1.11 2000/07/25 17:36:12 juha Exp $
    */
   
   
  @@ -51,12 +51,12 @@
    * Enterprise JavaBeans v1.1 specification.
    *
    * For more detailed documentation, refer to the
  - * <a href="" << INSERT DOC LINK HERE >> </a>
  + * <a href="http://java.sun.com/products/ejb/docs.html">Enterprise JavaBeans v1.1, 
Final Release</a>
    *
  - * @see     << OTHER RELATED CLASSES >>
  + * @see     org.jboss.verifier.strategy.AbstractVerifier
    *
    * @author   Juha Lindfors ([EMAIL PROTECTED])
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    * @since    JDK 1.3
    */
   public class EJBVerifier11 extends AbstractVerifier {
  @@ -225,6 +225,72 @@
                    }   
                }
                
  +            /*
  +             * The session bean's home interface MUST extend the
  +             * javax.ejb.EJBHome interface.
  +             *
  +             * Spec 6.10.6
  +             */
  +            if (!hasEJBHomeInterface(home)) {
  +                
  +                fireSpecViolationEvent(new Section("6.10.6.a"));
  +                
  +                status = false;
  +            }
  +            
  +            /*                
  +             * Method arguments defined in the home interface MUST be
  +             * of valid types for RMI/IIOP.
  +             *
  +             * Method return values defined in the home interface MUST
  +             * be of valid types for RMI/IIOP.
  +             *
  +             * Methods defined in the home interface MUST include
  +             * java.rmi.RemoteException in their throws clause.
  +             *
  +             * Spec 6.10.6
  +             */
  +            Iterator it = getMethods(home);
  +            
  +            while (it.hasNext()) {
  +                
  +                Method method = (Method)it.next();    
  +                
  +                if (!hasLegalRMIIIOPArguments(method)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.6.b"));
  +                    
  +                    status = false;
  +                }
  +                
  +                if (!hasLegalRMIIIOPReturnType(method)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.6.c"));
  +                    
  +                    status = false;
  +                }
  +                
  +                if (!throwsRemoteException(method)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.6.d"));
  +                    
  +                    status = false;
  +                }
  +            }
  +
  +            /*
  +             * A session bean's home interface MUST define one or more
  +             * create(...) methods.
  +             *
  +             * Spec 6.10.6
  +             */
  +            if (!hasCreateMethod(home)) {
  +                
  +                fireSpecViolationEvent(new Section("6.10.6.e"));
  +
  +                status = false;
  +            }
  +
                
           }
           catch (ClassNotFoundException e) {
  @@ -310,6 +376,48 @@
                   }
               }
   
  +            /*
  +             * For each method defined in the remote interface, there MUST be
  +             * a matching method in the session bean's class. The matching
  +             * method MUST have:
  +             *
  +             *  - the same name
  +             *  - the same number and types of arguments, and the same
  +             *    return type
  +             *  - All the exceptions defined in the throws clause of the 
  +             *    matching method of the session bean class must be defined
  +             *    in the throws clause of the method of the remote interface
  +             *
  +             * Spec 6.10.5
  +             */
  +            try {
  +                String beanName = session.getEjbClass();
  +                Class  bean     = classloader.loadClass(beanName);
  +                
  +                if (!hasMatchingMethodNames(remote, bean)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.5.e"));
  +                    
  +                    status = false;
  +                }
  +                
  +                if (!hasMatchingMethodArgs(remote, bean)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.5.f"));
  +                    
  +                    status = false;
  +                }
  +                
  +                if (!hasMatchingMethodExceptions(remote, bean)) {
  +                    
  +                    fireSpecViolationEvent(new Section("6.10.5.g"));
  +                    
  +                    status = false;
  +                }
  +            }
  +            
  +            catch (ClassNotFoundException ignored) {}
  +            
           }
           catch (ClassNotFoundException e) {
   
  
  
  
  1.5       +66 -4     jboss/src/main/org/jboss/verifier/strategy/AbstractVerifier.java
  
  Index: AbstractVerifier.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/verifier/strategy/AbstractVerifier.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractVerifier.java     2000/07/22 21:23:42     1.4
  +++ AbstractVerifier.java     2000/07/25 17:36:12     1.5
  @@ -19,7 +19,7 @@
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    *
    * This package and its source code is available at www.jboss.org
  - * $Id: AbstractVerifier.java,v 1.4 2000/07/22 21:23:42 juha Exp $
  + * $Id: AbstractVerifier.java,v 1.5 2000/07/25 17:36:12 juha Exp $
    */
   
   // standard imports
  @@ -46,7 +46,7 @@
    * @see     org.jboss.verifier.strategy.VerificationStrategy
    *
    * @author   Juha Lindfors ([EMAIL PROTECTED])
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @since    JDK 1.3
    */
   public abstract class AbstractVerifier implements VerificationStrategy {
  @@ -267,6 +267,22 @@
   
   
       /*
  +     * Finds javax.ejb.EJBHome interface from the class or its superclasses
  +     */
  +    public boolean hasEJBHomeInterface(Class c) {
  +        
  +        Class[] interfaces = c.getInterfaces();
  +        
  +        for (int i = 0; i < interfaces.length; ++i) {
  +            
  +            if ((EJB_HOME_INTERFACE).equals(interfaces[i].getName()))
  +                return true;
  +        }
  +        
  +        return false;
  +    }
  +    
  +    /*
        * Finds javax.ejb.SessionSynchronization interface from the class
        */
       public boolean hasSessionSynchronizationInterface(Class c) {
  @@ -327,6 +343,32 @@
       }
   
       /*
  +     * Searches for an instance of a public create method from the class
  +     */
  +    public boolean hasCreateMethod(Class c) {
  +        
  +        try {
  +            Method[] method = c.getMethods();
  +            
  +            for (int i = 0; i < method.length; ++i) {
  +                
  +                String name = method[i].getName();
  +                
  +                if (name.equals(CREATE_METHOD))
  +                    return true;
  +            }
  +        }
  +        
  +        catch (SecurityException e) {
  +            System.err.println(e);
  +            // [TODO]   Can be thrown by the getMethods() call if access is
  +            //          denied --> createVerifierWarningEvent
  +        }
  +
  +        return false;
  +    }
  +            
  +    /*
        * Searches for an instance of a public ejbCreate method from the class
        */
       public boolean hasEJBCreateMethod(Class c) {
  @@ -498,6 +540,22 @@
           return (count > 1);
       }
       
  +    public boolean hasMatchingMethodNames(Class a, Class b) {
  +        
  +        return true;
  +    }
  +    
  +    public boolean hasMatchingMethodArgs(Class a, Class b) {
  +        
  +        return true;
  +    }
  +    
  +    public boolean hasMatchingMethodExceptions(Class a, Class b) {
  +        
  +        return true;
  +    }
  +    
  +    
       /*
        * Ejb-jar DTD
        */
  @@ -533,13 +591,17 @@
       private final static String REMOTE_EXCEPTION      =
           "java.rmi.RemoteException";
   
  -    private final static String EJB_OBJECT_INTERFACE   =
  +    private final static String EJB_OBJECT_INTERFACE  =
           "javax.ejb.EJBObject";
   
  +    private final static String EJB_HOME_INTERFACE    =
  +        "javax.ejb.EJBHome";
  +        
  +        
        
       private final static String EJB_CREATE_METHOD     =
           "ejbCreate";
  -        
  +     
       private final static String CREATE_METHOD         =
           "create";
   
  
  
  

Reply via email to