User: juha    
  Date: 00/11/05 11:02:37

  Modified:    src/main/org/jboss/verifier/strategy EJBVerifier20.java
                        EJBVerifier11.java AbstractVerifier.java
  Log:
  6.10.6 for session beans
  
  Revision  Changes    Path
  1.8       +11 -26    jboss/src/main/org/jboss/verifier/strategy/EJBVerifier20.java
  
  Index: EJBVerifier20.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/verifier/strategy/EJBVerifier20.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EJBVerifier20.java        2000/08/20 20:48:07     1.7
  +++ EJBVerifier20.java        2000/11/05 19:02:36     1.8
  @@ -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: EJBVerifier20.java,v 1.7 2000/08/20 20:48:07 juha Exp $
  + * $Id: EJBVerifier20.java,v 1.8 2000/11/05 19:02:36 juha Exp $
    */
   
   
  @@ -31,11 +31,8 @@
   
   
   // non-standard class dependencies
  -import org.gjt.lindfors.pattern.StrategyContext;
  +import org.jboss.verifier.factory.DefaultEventFactory;
   
  -import org.jboss.verifier.event.VerificationEvent;
  -import org.jboss.verifier.factory.VerificationEventFactory;
  -
   import org.jboss.metadata.BeanMetaData;
   import org.jboss.metadata.SessionMetaData;
   import org.jboss.metadata.EntityMetaData;
  @@ -45,40 +42,28 @@
   /**
    * EJB 2.0 bean verifier.
    *
  - * For more detailed documentation, refer to the
  - * <a href="" << INSERT DOC LINK HERE >> </a>
  - *
  - * @see     << OTHER RELATED CLASSES >>
  - *
    * @author   Juha Lindfors   ([EMAIL PROTECTED])
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    * @since    JDK 1.3
    */
   public class EJBVerifier20 extends AbstractVerifier {
   
  -    private VerificationContext context      = null; 
  -
  -
       /*
        * Constructor
        */
       public EJBVerifier20(VerificationContext context) {
  -        this.context = context;
  +        super(context, new DefaultEventFactory());
       }
   
       
  -    /*
  -     ***********************************************************************
  -     *
  -     *    IMPLEMENTS VERIFICATION STRATEGY INTERFACE
  -     *
  -     ***********************************************************************
  -     */
  +/*
  + ***********************************************************************
  + *
  + *    IMPLEMENTS VERIFICATION STRATEGY INTERFACE
  + *
  + ***********************************************************************
  + */
       
  -    public StrategyContext getContext() {
  -        return context;
  -    }
  -
       public void checkSession(SessionMetaData session) {
               
               // NOT IMPLEMENTED YET
  
  
  
  1.23      +69 -92    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- EJBVerifier11.java        2000/10/20 23:00:06     1.22
  +++ EJBVerifier11.java        2000/11/05 19:02:36     1.23
  @@ -19,27 +19,20 @@
    * 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.22 2000/10/20 23:00:06 juha Exp $
  + * $Id: EJBVerifier11.java,v 1.23 2000/11/05 19:02:36 juha Exp $
    */
   
   
   // standard imports
   import java.util.Iterator;
   import java.util.Arrays;
  -import java.net.URL;
  -import java.net.URLClassLoader;
   import java.lang.reflect.Member;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.lang.reflect.Field;
   
   // non-standard class dependencies
  -import org.gjt.lindfors.pattern.StrategyContext;
  -
   import org.jboss.verifier.Section;
  -import org.jboss.verifier.event.VerificationEvent;
  -
  -import org.jboss.verifier.factory.VerificationEventFactory;
   import org.jboss.verifier.factory.DefaultEventFactory;
   
   import org.jboss.metadata.ApplicationMetaData;
  @@ -61,57 +54,18 @@
    * @author  Juha Lindfors ([EMAIL PROTECTED])
    * @author  Aaron Mulder  ([EMAIL PROTECTED])
    *
  - * @version $Revision: 1.22 $
  + * @version $Revision: 1.23 $
    * @since   JDK 1.3
    */
   public class EJBVerifier11 extends AbstractVerifier {
   
  -    /** 
  -     * Context is used for retrieving application level information, such
  -     * as the application meta data, location of the jar file, etc. <p>
  -     *
  -     * Initialized in the constructor.
  -     */
  -    private VerificationContext context      = null;
  -    
  -    /**
  -     * Factory for generating the verifier events. <p>
  -     *
  -     * Initialized in the constructor.
  -     * 
  -     * @see org.jboss.verifier.factory.DefaultEventFactory
  -     */
  -    private VerificationEventFactory factory = null;
  -    
  -    /**
  -     * The application classloader. This can be provided by the context directly
  -     * via {@link VerificationContext#getClassLoader} method, or constructed
  -     * by this object by creating a classloader to the URL returned by 
  -     * {@link VerificationContext#getJarLocation} method. <p>
  -     *
  -     * Initialized in the constructor.
  -     */
  -    private ClassLoader classloader          = null;
  -
  -
  -
       /**
        * Constructs the verifier object.
        *
        * @param   context     context for application information
        */
       public EJBVerifier11(VerificationContext context) {
  -
  -        this.context       = context;
  -        this.factory       = new DefaultEventFactory();
  -        this.classloader   = context.getClassLoader();
  -
  -        if (this.classloader == null) {
  -            URL[] list = { context.getJarLocation() };
  -
  -            ClassLoader parent = Thread.currentThread().getContextClassLoader();
  -            this.classloader   = new URLClassLoader(list, parent);
  -        }
  +        super(context, new DefaultEventFactory());
       }
   
   
  @@ -177,14 +131,6 @@
           }
       }
   
  -    /**
  -     * Returns the context object reference for this strategy implementation.
  -     *
  -     * @return  the client object using this algorithm implementation
  -     */
  -    public StrategyContext getContext() {
  -        return context;
  -    }
   
   
   /*
  @@ -316,13 +262,72 @@
                   status = false;
               }
   
  -            // [TODO] 6.10.6 each create method must have a matching ejbCreate
  -            //               with same number and types of arguments (diff.
  -            //               return type)
  -            //        6.10.6 the return type of create must be remote interface
  -            //        6.10.6 all the exceptions of ejbCreate must be included
  -            //               in the throws clause of create method
  -            //        6.10.6 throws clause must include CreateException
  +           
  +            /*
  +             * Each create(...) method in the session bean's home interface MUST
  +             * have a matching ejbCreate(...) method in the session bean's class.
  +             *
  +             * Each create(...) method in the session bean's home interface MUST
  +             * have the same number and types of arguments to its matching
  +             * ejbCreate(...) method.
  +             *
  +             * The return type for a create(...) method MUST be the session
  +             * bean's remote interface type.
  +             *
  +             * All the exceptions defined in the throws clause of the matching
  +             * ejbCreate(...) method of the enterprise bean class MUST be
  +             * included in the throws clause of a matching create(...) method.
  +             *
  +             * The throws clause of a create(...) method MUST include the
  +             * javax.ejb.CreateException.
  +             *
  +             * Spec 6.10.6
  +             */
  +            Iterator createMethods = getCreateMethods(home);
  +            
  +            try {
  +                String beanClass   = session.getEjbClass();
  +                Class  bean        = classloader.loadClass(beanClass);
  +                
  +                while (createMethods.hasNext()) {
  +                    
  +                    Method create = (Method)createMethods.next();
  +                    
  +                    if (!hasMatchingEJBCreate(bean, create)) {
  +                        
  +                        fireSpecViolationEvent(session, create, new 
Section("6.10.6.f"));
  +                        
  +                        status = false;
  +                    }
  +                    
  +                    if (!hasRemoteReturnType(session, create)) {
  +                        
  +                        fireSpecViolationEvent(session, create, new 
Section("6.10.6.g"));
  +                        
  +                        status = false;
  +                    }
  +                    
  +                    if (hasMatchingEJBCreate(bean, create)) {
  +                    
  +                        Method ejbCreate     = getMatchingEJBCreate(bean, create);
  +                        
  +                        if (!hasMatchingExceptions(ejbCreate, create)) {
  +                                   
  +                            fireSpecViolationEvent(session, create, new 
Section("6.10.6.h"));
  +                        }
  +                    }
  +                    
  +                    if (!throwsCreateException(create)) {
  +                        
  +                        fireSpecViolationEvent(session, create, new 
Section("6.10.6.i"));
  +                        
  +                        status = false;
  +                    }
  +                }
  +            }
  +            catch (ClassNotFoundException ignored) {}
  +            
  +            
           }
           catch (ClassNotFoundException e) {
   
  @@ -1371,34 +1376,6 @@
   
           return status;
       }
  -
  -
  -    protected void fireSpecViolationEvent(BeanMetaData bean, Section section) {
  -        fireSpecViolationEvent(bean, null /* method */, section);
  -    }
  -    
  -    protected void fireSpecViolationEvent(BeanMetaData bean, Method method,
  -                                          Section section) {
  -
  -        VerificationEvent event = factory.createSpecViolationEvent(context, 
section);
  -        event.setName(bean.getEjbName());
  -        event.setMethod(method);
  -        
  -        context.fireSpecViolation(event);
  -    }
  -
  -    protected void fireBeanVerifiedEvent(BeanMetaData bean) {
  -
  -        VerificationEvent event = factory.createBeanVerifiedEvent(context);
  -        event.setName(bean.getEjbName());
  -
  -        context.fireBeanChecked(event);
  -    }
  -
  -
  -
  -
  -
   
   
   
  
  
  
  1.14      +116 -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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AbstractVerifier.java     2000/10/20 23:00:05     1.13
  +++ AbstractVerifier.java     2000/11/05 19:02:36     1.14
  @@ -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.13 2000/10/20 23:00:05 juha Exp $
  + * $Id: AbstractVerifier.java,v 1.14 2000/11/05 19:02:36 juha Exp $
    */
   
   // standard imports
  @@ -33,13 +33,21 @@
   import java.util.Iterator;
   import java.util.Arrays;
   
  +import java.net.URL;
  +import java.net.URLClassLoader;
   
  +
   // non-standard class dependencies
   import org.jboss.metadata.ApplicationMetaData;
   import org.jboss.metadata.BeanMetaData;
   import org.jboss.metadata.EntityMetaData;
   import org.jboss.metadata.SessionMetaData;
   
  +import org.jboss.verifier.factory.VerificationEventFactory;
  +import org.jboss.verifier.event.VerificationEvent;
  +import org.jboss.verifier.Section;
  +
  +import org.gjt.lindfors.pattern.StrategyContext;
   
   
   /**
  @@ -53,7 +61,7 @@
    * @author   Juha Lindfors ([EMAIL PROTECTED])
    * @author  Aaron Mulder  ([EMAIL PROTECTED])
    *
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    * @since    JDK 1.3
    */
   public abstract class AbstractVerifier implements VerificationStrategy {
  @@ -65,6 +73,66 @@
           "javax.ejb.EJBHome";
   
   
  +    /**
  +     * The application classloader. This can be provided by the context directly
  +     * via {@link VerificationContext#getClassLoader} method, or constructed
  +     * by this object by creating a classloader to the URL returned by 
  +     * {@link VerificationContext#getJarLocation} method. <p>
  +     *
  +     * Initialized in the constructor.
  +     */
  +    protected ClassLoader classloader          = null;
  +
  +    /**
  +     * Factory for generating the verifier events. <p>
  +     *
  +     * Initialized in the constructor.
  +     * 
  +     * @see org.jboss.verifier.factory.DefaultEventFactory
  +     */
  +    private VerificationEventFactory factory = null;
  +
  +    /** 
  +     * Context is used for retrieving application level information, such
  +     * as the application meta data, location of the jar file, etc. <p>
  +     *
  +     * Initialized in the constructor.
  +     */
  +    private VerificationContext context      = null;
  +
  +/*
  + *************************************************************************
  + *
  + *      CONSTRUCTORS
  + *
  + *************************************************************************
  + */
  +
  +    public AbstractVerifier(VerificationContext      context, 
  +                            VerificationEventFactory factory) {
  +        
  +        this.factory     = factory;
  +        this.context     = context;
  +        this.classloader = context.getClassLoader();
  +
  +        if (this.classloader == null) {
  +            URL[] list = { context.getJarLocation() };
  +
  +            ClassLoader parent = Thread.currentThread().getContextClassLoader();
  +            this.classloader   = new URLClassLoader(list, parent);
  +        }
  +        
  +    }
  +
  +
  +/*
  + *************************************************************************
  + *
  + *      PUBLIC INSTANCE METHODS
  + *
  + *************************************************************************
  + */
  +    
       public boolean hasLegalRMIIIOPArguments(Method method) {
   
           Class[] params = method.getParameterTypes();
  @@ -585,7 +653,37 @@
           }
       }
   
  +/*
  + *************************************************************************
  + *
  + *      PROTECTED INSTANCE METHODS
  + *
  + *************************************************************************
  + */
  + 
  +    protected void fireSpecViolationEvent(BeanMetaData bean, Section section) {
  +        fireSpecViolationEvent(bean, null /* method */, section);
  +    }
  +    
  +    protected void fireSpecViolationEvent(BeanMetaData bean, Method method,
  +                                          Section section) {
  +
  +        VerificationEvent event = factory.createSpecViolationEvent(context, 
section);
  +        event.setName(bean.getEjbName());
  +        event.setMethod(method);
  +        
  +        context.fireSpecViolation(event);
  +    }
   
  +    protected void fireBeanVerifiedEvent(BeanMetaData bean) {
  +
  +        VerificationEvent event = factory.createBeanVerifiedEvent(context);
  +        event.setName(bean.getEjbName());
  +
  +        context.fireBeanChecked(event);
  +    }
  +
  +    
   /*
    *************************************************************************
    *
  @@ -602,7 +700,16 @@
        */
       public void checkMessageBean(BeanMetaData bean) {}
   
  +    /**
  +     * Returns the context object reference for this strategy implementation.
  +     *
  +     * @return  the client object using this algorithm implementation
  +     */
  +    public StrategyContext getContext() {
  +        return context;
  +    }
   
  +    
   /*
    *************************************************************************
    *
  @@ -693,9 +800,13 @@
   
       private boolean isRMIIDLRemoteInterface(Class type) {
   
  +        /*
  +         * If does not implement java.rmi.Remote, cannot be valid RMI-IDL
  +         * remote interface.
  +         */
           if (!java.rmi.Remote.class.isAssignableFrom(type))
               return false;
  -
  +        
           Iterator methodIterator = Arrays.asList(type.getMethods()).iterator();
   
           while (methodIterator.hasNext()) {
  @@ -707,8 +818,9 @@
                *
                * Spec 28.2.3 (2)
                */
  -            if (!throwsRemoteException(m))
  +            if (!throwsRemoteException(m)) {
                   return false;
  +            }
   
               /*
                * All checked exception classes used in method declarations
  
  
  

Reply via email to