Package org.jboss.verifier

Examples of org.jboss.verifier.Section


      //
      // Spec 9.2.7
      //
      if (!hasEJBObjectInterface(remote))
      {
         fireSpecViolationEvent(entity, new Section("9.2.7.a"));
         status = false;
      }

      // The methods defined in the entity bean's remote interface MUST
      // have valid RMI-IIOP argument types.
      //
      // The methods defined in the entity bean's home interface MUST
      // have valid RMI-IIOP return types.
      //
      // The methods defined in the entity bean's home interface MUST
      // have java.rmi.RemoteException in their throws clause.
      //
      // Spec 9.2.7
      //
      Iterator it = Arrays.asList(remote.getMethods()).iterator();
      while (it.hasNext())
      {
         Method method = (Method)it.next();

         if (!hasLegalRMIIIOPArguments(method))
         {
            fireSpecViolationEvent(entity, method, new Section("9.2.7.b"));
            status = false;
         }

         if (!hasLegalRMIIIOPReturnType(method))
         {
            fireSpecViolationEvent(entity, method, new Section("9.2.7.c"));
            status = false;
         }

         if (!hasLegalRMIIIOPExceptionTypes(method))
         {
            fireSpecViolationEvent(entity, method, new Section("9.2.7.h"));
            status = false;
         }

         if (!throwsRemoteException(method))
         {
            fireSpecViolationEvent(entity, method, new Section("9.2.7.d"));
            status = false;
         }
      }

      // For each method defined in the remote interface, there MUST be
      // a matching method in the entity bean's class. The matching
      // method MUST have:
      //
      //     - The same name.
      //     - The same number and types of its arguments.
      //     - The same return type.
      //     - All the exceptions defined in the throws clause of the
      //       matching method of the enterprise Bean class must be
      //       defined in the throws clause of the method of the remote
      //       interface.
      //
      // Spec 9.2.7
      //
      it = Arrays.asList(remote.getMethods()).iterator();
      while (it.hasNext())
      {
         Method method = (Method)it.next();

         // Do not check the methods of the javax.ejb.EJBObject interface
         if (method.getDeclaringClass().getName().equals(EJB_OBJECT_INTERFACE))
            continue;

         if (!hasMatchingMethod(bean, method))
         {
            fireSpecViolationEvent(entity, method, new Section("9.2.7.e"));
            status = false;
         }

         if (hasMatchingMethod(bean, method))
         {
            try
            {
               Method beanMethod = bean.getMethod(method.getName(),
                       method.getParameterTypes());

               if (!hasMatchingReturnType(beanMethod, method))
               {
                  fireSpecViolationEvent(entity, method,
                          new Section("9.2.7.f"));
                  status = false;
               }

               if (!hasMatchingExceptions(beanMethod, method))
               {
                  fireSpecViolationEvent(entity, method,
                          new Section("9.2.7.g"));
                  status = false;
               }
            }
            catch (NoSuchMethodException ignored)
            {
View Full Code Here


      //
      // Spec 10.6.2
      //
      if (!hasEntityBeanInterface(bean))
      {
         fireSpecViolationEvent(entity, new Section("10.6.2.a"));
         status = false;
      }

      // The entity bean class MUST be defined as public and abstract.
      //
      // Spec 10.6.2
      //
      if (!isPublic(bean) || !isAbstract(bean))
      {
         fireSpecViolationEvent(entity, new Section("10.6.2.b"));
         status = false;
      }

      // The entity bean class MUST define a public constructor that
      // takes no arguments
      //
      // Spec 10.6.2
      //
      if (!hasDefaultConstructor(bean))
      {
         fireSpecViolationEvent(entity, new Section("10.6.2.c"));
         status = false;
      }

      // The entity bean class MUST NOT define the finalize() method.
      //
      // Spec 10.6.2
      //
      if (hasFinalizer(bean))
      {
         fireSpecViolationEvent(entity, new Section("10.6.2.d"));
         status = false;
      }

      // The ejbCreate(...) method signatures MUST follow these rules:
      //
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as final or static
      //      - The return type MUST be the entity bean's primary key type
      //      --- Only if method is on remote home ---
      //      - The method arguments MUST be legal types for RMI/IIOP
      //      - The method return value type MUST be legal type for RMI/IIOP
      //      --- End of only if method is on remote home ---
      //      - The method must define the javax.ejb.CreateException
      //
      // Spec 10.6.4
      //
      if (hasEJBCreateMethod(bean, false))
      {
         Iterator it = getEJBCreateMethods(bean);
         while (it.hasNext())
         {
            Method ejbCreate = (Method)it.next();
            if (!isPublic(ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("10.6.4.b"));
               status = false;
            }

            if ((isFinal(ejbCreate)) || (isStatic(ejbCreate)))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("10.6.4.c"));
               status = false;
            }

            if (!hasPrimaryKeyReturnType(entity, ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("10.6.4.d"));
               status = false;
            }

            /* FIXME
             *  This is only true if the method is on the remote home
             * interface
             if (!hasLegalRMIIIOPArguments(ejbCreate)) {
             fireSpecViolationEvent(entity, ejbCreate, new Section("10.6.4.d"));
             status = false;
             }

             if (!hasLegalRMIIIOPReturnType(ejbCreate)) {
             fireSpecViolationEvent(entity, ejbCreate, new Section("10.5.4.f"));
             status = false;
             }
             */

            if (!throwsCreateException(ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("10.6.4.g"));
               status = false;
            }
         }
      }

      // For each ejbCreate(...) method, the entity bean class MUST
      // define a matching ejbPostCreate(...) method.
      //
      // The ejbPostCreate(...) method MUST follow these rules:
      //
      //   - the method MUST be declared as public
      //   - the method MUST NOT be declared as final or static
      //   - the return type MUST be void
      //   - the method arguments MUST be the same as the matching
      //     ejbCreate(...) method
      //
      // Spec 10.6.5
      //
      if (hasEJBCreateMethod(bean, false))
      {
         Iterator it = getEJBCreateMethods(bean);

         while (it.hasNext())
         {
            Method ejbCreate = (Method)it.next();

            if (!hasMatchingEJBPostCreate(bean, ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("10.6.5.a"));
               status = false;
            }

            if (hasMatchingEJBPostCreate(bean, ejbCreate))
            {
               Method ejbPostCreate = getMatchingEJBPostCreate(bean,
                       ejbCreate);

               if (!isPublic(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("10.6.5.b"));
                  status = false;
               }

               if (isStatic(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("10.6.5.c"));
                  status = false;
               }

               if (isFinal(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("10.6.5.d"));
                  status = false;
               }

               if (!hasVoidReturnType(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("10.6.5.e"));
                  status = false;
               }
            }
         }
      }

      // The ejbHome(...) method signatures MUST follow these rules:
      //
      //      - The method name MUST have ejbHome as its prefix.
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as static.
      //      - The method MUST NOT define the java.rmi.RemoteException
      //
      // Spec 10.6.6
      //
      Iterator it = getEjbHomeMethods(bean);
      while (it.hasNext())
      {
         Method ejbHome = (Method)it.next();
         if (!isPublic(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.a"));
            status = false;
         }

         if (isStatic(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.b"));
            status = false;
         }

         if (throwsRemoteException(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.c"));
            status = false;
         }
      }

      // The CMP entity bean MUST implement get and set accessor methods for
      // each field within the abstract persistance schema.
      //
      // Spec 10.6.2
      //
      it = entity.getCMPFields();
      while (it.hasNext())
      {
         String fieldName = (String)it.next();
         String getName = "get" + fieldName.substring(0, 1).toUpperCase() +
                 fieldName.substring(1);
         Class fieldType = null;

         try
         {
            Method m = bean.getMethod(getName, new Class[0]);
            fieldType = m.getReturnType();

            // The getter must not return 'void' according to the JavaBeans
            // Spec
            if (fieldType == Void.TYPE)
            {
               fireSpecViolationEvent(entity,
                       new Section("jb.7.1.b", "Field: " + fieldName));
            }
         }
         catch (NoSuchMethodException nsme)
         {
            fireSpecViolationEvent(entity,
                    new Section("10.6.2.g", "Field: " + fieldName));
            status = false;
         }

         String setName = "set" + fieldName.substring(0, 1).toUpperCase() +
                 fieldName.substring(1);
         Class[] args = new Class[1];
         args[0] = fieldType;

         try
         {
            Method m = bean.getMethod(setName, args);
            fieldType = m.getReturnType();

            // According to the JavaBeans Spec, a setter method must
            // return 'void'
            if (fieldType != Void.TYPE)
            {
               fireSpecViolationEvent(entity,
                       new Section("jb.7.1.a", "Field: " + fieldName));
            }
         }
         catch (NoSuchMethodException nsme)
         {
            // Try with java.util.Collection
            //
            // FIXME: This should only be tried for CMR methods; a CMP
            //        setter cannot accept a Collection!
            try
            {
               args[0] = classloader.loadClass("java.util.Collection");
               Method m = bean.getMethod(setName, args);
            }
            catch (NoSuchMethodException nsme2)
            {
               fireSpecViolationEvent(entity,
                       new Section("10.6.2.h", "Field: " + fieldName));
               status = false;
            }
            catch (ClassNotFoundException cnfe)
            {
               // Something is really broken
            }
         }
      }

      // The ejbSelect(...) method signatures MUST follow these rules:
      //
      //      - The method name MUST have ejbSelect as its prefix.
      //      - The method MUST be declared as public
      //      - The method MUST be declared as abstract.
      //      - The method MUST define the javax.ejb.FinderException
      //
      // Spec 10.6.7
      //
      it = getEjbSelectMethods(bean);
      while (it.hasNext())
      {
         Method ejbSelect = (Method)it.next();

         if (!isPublic(ejbSelect))
         {
            fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.a"));
            status = false;
         }

         if (!isAbstract(ejbSelect))
         {
            fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.b"));
            status = false;
         }

         if (!throwsFinderException(ejbSelect))
         {
            fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.c"));
            status = false;
         }

         if (!hasMatchingQuery(ejbSelect, entity))
         {
            fireSpecViolationEvent(entity, ejbSelect, new Section("10.5.7"));
            status = false;
         }
      }

      // A CMP Entity Bean must not define Finder methods.
      //
      // Spec 10.6.2
      //
      if (hasFinderMethod(bean))
      {
         fireSpecViolationEvent(entity, new Section("10.6.2.i"));
         status = false;
      }

      return status;
   }
View Full Code Here

      //
      // Spec 12.2.2
      //
      if (!hasEntityBeanInterface(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.2.a"));
         status = false;
      }

      // The entity bean class MUST be defined as public and NOT abstract.
      //
      // Spec 12.2.2
      //
      if (!isPublic(bean) || isAbstract(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.2.b"));
         status = false;
      }

      // The entity bean class MUST NOT be defined as final.
      //
      // Spec 12.2.2
      //
      if (isFinal(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.2.c"));
         status = false;
      }

      // The entity bean class MUST define a public constructor that
      // takes no arguments
      //
      // Spec 12.2.2
      //
      if (!hasDefaultConstructor(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.2.d"));
         status = false;
      }

      // The entity bean class MUST NOT define the finalize() method.
      //
      // Spec 12.2.2
      //
      if (hasFinalizer(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.2.e"));
         status = false;
      }

      // The ejbCreate(...) method signatures MUST follow these rules:
      //
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as final or static
      //      - The return type MUST be the entity bean's primary key type
      //      --- If the method is on the remote home interface ---
      //      - The method arguments MUST be legal types for RMI/IIOP
      //      - The method return value type MUST be legal type for RMI/IIOP
      //      --- End if the method is on the remote home interface ---
      //
      // Spec 12.2.3
      //
      if (hasEJBCreateMethod(bean, false))
      {
         Iterator it = getEJBCreateMethods(bean);
         while (it.hasNext())
         {
            Method ejbCreate = (Method)it.next();
            if (!isPublic(ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("12.2.3.a"));
               status = false;
            }

            if ((isFinal(ejbCreate)) || (isStatic(ejbCreate)))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("12.2.3.b"));
               status = false;
            }

            if (!hasPrimaryKeyReturnType(entity, ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("12.2.3.c"));
               status = false;
            }

            /* FIXME
             * This code needs to only be invoked if the method is on the
             * remote home.
             if (!hasLegalRMIIIOPArguments(ejbCreate)) {
             fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.d"));
             status = false;
             }
             if (!hasLegalRMIIIOPReturnType(ejbCreate)) {
             fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.e"));
             status = false;
             }
            */
         }
      }

      // For each ejbCreate(...) method, the entity bean class MUST
      // define a matching ejbPostCreate(...) method.
      //
      // The ejbPostCreate(...) method MUST follow these rules:
      //
      //   - the method MUST be declared as public
      //   - the method MUST NOT be declared as final or static
      //   - the return type MUST be void
      //   - the method arguments MUST be the same as the matching
      //     ejbCreate(...) method
      //
      // Spec 12.2.4
      //
      if (hasEJBCreateMethod(bean, false))
      {
         Iterator it = getEJBCreateMethods(bean);
         while (it.hasNext())
         {
            Method ejbCreate = (Method)it.next();

            if (!hasMatchingEJBPostCreate(bean, ejbCreate))
            {
               fireSpecViolationEvent(entity, ejbCreate,
                       new Section("12.2.4.a"));
               status = false;
            }

            if (hasMatchingEJBPostCreate(bean, ejbCreate))
            {
               Method ejbPostCreate = getMatchingEJBPostCreate(bean,
                       ejbCreate);

               if (!isPublic(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("12.2.4.b"));
                  status = false;
               }

               if (isStatic(ejbPostCreate) || isFinal(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("12.2.4.c"));
                  status = false;
               }

               if (!hasVoidReturnType(ejbPostCreate))
               {
                  fireSpecViolationEvent(entity, ejbPostCreate,
                          new Section("12.2.4.d"));
                  status = false;
               }
            }
         }
      }

      // Every entity bean MUST define the ejbFindByPrimaryKey method.
      //
      // The return type for the ejbFindByPrimaryKey method MUST be the
      // primary key type.
      //
      // The ejbFindByPrimaryKey method MUST be a single-object finder.
      //
      // Spec 12.2.5
      //
      if (!hasEJBFindByPrimaryKey(bean))
      {
         fireSpecViolationEvent(entity, new Section("12.2.5.e"));
         status = false;
      }

      if (hasEJBFindByPrimaryKey(bean))
      {
         Method ejbFindByPrimaryKey = getEJBFindByPrimaryKey(bean);

         if (!hasPrimaryKeyReturnType(entity, ejbFindByPrimaryKey))
         {
            fireSpecViolationEvent(entity, ejbFindByPrimaryKey,
                    new Section("12.2.5.e1"));
            status = false;
         }

         if (!isSingleObjectFinder(entity, ejbFindByPrimaryKey))
         {
            fireSpecViolationEvent(entity, ejbFindByPrimaryKey,
                    new Section("12.2.5.e2"));
            status = false;
         }
      }

      // A finder method MUST be declared as public.
      //
      // A finder method MUST NOT be declared as static.
      //
      // A finder method MUST NOT be declared as final.
      //
      // The finder method argument types MUST be legal types for
      // RMI/IIOP
      //
      // The finder method return type MUST be either the entity bean's
      // primary key type, or java.lang.util.Enumeration interface or
      // java.lang.util.Collection interface.
      //
      // Spec 12.2.5
      //
      if (hasFinderMethod(bean))
      {
         Iterator it = getEJBFindMethods(bean);
         while (it.hasNext())
         {
            Method finder = (Method)it.next();

            if (!isPublic(finder))
            {
               fireSpecViolationEvent(entity, finder, new Section("12.2.5.a"));
               status = false;
            }

            if (isFinal(finder) || isStatic(finder))
            {
               fireSpecViolationEvent(entity, finder, new Section("12.2.5.b"));
               status = false;
            }

            /** FIXME
             * this path should only get invoked if the finder is on the
             * remote interface.
             if (!hasLegalRMIIIOPArguments(finder)) {
             fireSpecViolationEvent(entity, finder, new Section("12.2.5.c"));
             status = false;
             }
             */

            if (!(isSingleObjectFinder(entity, finder)
                    || isMultiObjectFinder(finder)))
            {
               fireSpecViolationEvent(entity, finder, new Section("12.2.5.d"));
               status = false;
            }
         }
      }

      // The ejbHome(...) method signatures MUST follow these rules:
      //
      //      - The method name MUST have ejbHome as its prefix.
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as static.
      //      - The method MUST NOT define the java.rmi.RemoteException
      //
      // Spec 10.6.6
      //
      Iterator it = getEjbHomeMethods(bean);
      while (it.hasNext())
      {
         Method ejbHome = (Method)it.next();

         if (!isPublic(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.a"));
            status = false;
         }

         if (isStatic(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.b"));
            status = false;
         }

         if (throwsRemoteException(ejbHome))
         {
            fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.c"));
            status = false;
         }
      }

      return status;
View Full Code Here

      if (entity.getPrimaryKeyClass() == null
              || entity.getPrimaryKeyClass().length() == 0)
      {
         if (cmp)
            fireSpecViolationEvent(entity, new Section("10.6.1.a"));
         else
            fireSpecViolationEvent(entity, new Section("12.2.1.a"));

         // We can't get any further if there's no PK class specified!
         return false;
      }

      // FIXME - Still missing the bits from 10.8.2 for CMP primary
      // keys.  Primarily the class must be public, all fields in the
      // class must be public and the fields must also be a subset of
      // the CMP fields within the bean.
      //
      Class cls = null;
      try
      {
         cls = classloader.loadClass(entity.getPrimaryKeyClass());
      }
      catch (ClassNotFoundException e)
      {
         if (cmp)
            fireSpecViolationEvent(entity, new Section("10.6.13.a"));
         else
            fireSpecViolationEvent(entity, new Section("12.2.12.a"));

         // Can't do any other checks if the class is null!
         return false;
      }

      // The primary key type must be a valid type in RMI-IIOP.
      //
      // Spec 10.6.13 & 12.2.12
      //
      if (!isRMIIDLValueType(cls))
      {
         if (cmp)
            fireSpecViolationEvent(entity, new Section("10.6.13.b"));
         else
            fireSpecViolationEvent(entity, new Section("12.2.12.b"));
         status = false;
      }

      // No primary key field specified, just a primary key class.
      if (entity.getPrimKeyField() == null ||
              entity.getPrimKeyField().length() == 0)
      {
         // This is a check for some interesting implementation of
         // equals() and hashCode().  I am not sure how well it works in
         // the end.
         //
         if (!cls.getName().equals("java.lang.Object"))
         {
            Object one, two;

            try
            {
               one = cls.newInstance();
               two = cls.newInstance();
               try
               {
                  if (!one.equals(two))
                  {
                     if (cmp)
                     {
                        // fireSpecViolationEvent(entity, new Section("10.6.13.c"));
                        log.warn("Default instances of primary key: " + cls
                                + " do not equate, check your equals method");
                     }
                     else
                     {
                        //fireSpecViolationEvent(entity, new Section("12.2.12.c"));
                        log.warn("Default instances of primary key: " + cls
                                + " do not equate, check your equals method");
                     }
                     status = true;
                  }
               }
               catch (NullPointerException e)
               {
                  // That's OK - the implementor expected the fields to
                  // have values
               }

               try
               {
                  if (one.hashCode() != two.hashCode())
                  {
                     if (cmp)
                     {
                        //fireSpecViolationEvent(entity, new Section("10.6.13.d"));
                        log.warn("Default instances of primary key: " + cls
                                + " do not have the same hash, check your hashCode method");
                     }
                     else
                     {
                        //fireSpecViolationEvent(entity, new Section("12.2.12.d"));
                        log.warn("Default instances of primary key: " + cls
                                + " do not have the same hash, check your hashCode method");
                     }
                     status = true;
                  }
               }
               catch (NullPointerException e)
               {
                  // That's OK - the implementor expected the fields to have values
               }
            }
            catch (IllegalAccessException e)
            {
               // If CMP primary key class MUST have a public
               // constructor with no parameters.  10.8.2.a
               ///
               if (cmp)
               {
                  fireSpecViolationEvent(entity, new Section("10.8.2.a"));
                  status = false;
               }
            }
            catch (InstantiationException e)
            {
               //Not sure what condition this is at the moment - JMW
               //fireSpecViolationEvent(entity, new Section("9.2.9.a"));
               //status = false;
            }
         }
      }
      else
      {
         //  BMP Beans MUST not include the primkey-field element in
         //  their deployment descriptor.  Deployment descriptor comment
         //
         if (entity.isBMP())
         {
            fireSpecViolationEvent(entity, new Section("dd.a"));
            status = false;
         }

         // The primary keyfield MUST be a CMP field within the
         // entity bean.
         //
         // Spec 10.8.1
         //
         boolean found = false;
         Iterator it = entity.getCMPFields();
         while (it.hasNext())
         {
            String fieldName = (String)it.next();
            if (fieldName.equals(entity.getPrimKeyField()))
            {
               found = true;
               break;
            }
         }

         if (!found)
         {
            status = false;
            fireSpecViolationEvent(entity, new Section("10.8.1.b"));
         }

         try
         {
            // The class of the primary key field MUST match the
            // primary key class specified for the entity bean.  We
            // figure out the class of this field by getting the
            // return type of the get<FieldName> accessor method.
            //
            // Spec 10.8.1
            //
            String pkField = entity.getPrimKeyField();
            String methodName = "get" +
                    pkField.substring(0, 1).toUpperCase() + pkField.substring(1);

            Method method = bean.getMethod(methodName, new Class[0]);
            if (!entity.getPrimaryKeyClass().equals(method.getReturnType().getName())
            )
            {
               status = false;
               fireSpecViolationEvent(entity, new Section("10.8.1.a"));
            }

         }
         catch (NoSuchMethodException e)
         {
            // The primary keyfield MUST be a CMP field within the
            // entity bean.
            //
            // Spec 10.8.1
            //
            status = false;
            fireSpecViolationEvent(entity, new Section("10.8.1.b"));
         }
      }

      return status;
   }
View Full Code Here

      //
      // Spec 15.7.2
      //
      if (!hasMessageDrivenBeanInterface(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.a"));
         status = false;
      }

      // A message driven bean MUST implement, directly or indirectly,
      // javax.jms.MessageListener interface.
      //
      // Spec 15.7.2
      //
      if (!hasMessageListenerInterface(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.b"));
         status = false;
      }

      // The message driven bean class MUST be defined as public.
      //
      // Spec 15.7.2
      //
      if (!isPublic(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.c1"));
         status = false;
      }

      // The message driven bean class MUST NOT be final.
      //
      // Spec 15.7.2
      //
      if (isFinal(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.c2"));
         status = false;
      }

      // The message driven bean class MUST NOT be abstract.
      //
      // Spec 15.7.2
      //
      if (isAbstract(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.c3"));
         status = false;
      }

      // The message driven bean class MUST have a public constructor that
      // takes no arguments.
      //
      // Spec 15.7.2
      //
      if (!hasDefaultConstructor(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.d"));
         status = false;
      }

      // The message driven bean class MUST NOT define the finalize() method.
      //
      // Spec 15.7.2
      //
      if (hasFinalizer(bean))
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.2.e"));
         status = false;
      }

      // A message driven bean MUST implement the ejbCreate() method.
      // The ejbCreate() method signature MUST follow these rules:
      //
      //      - The method name MUST be ejbCreate
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as final or static
      //      - The return type MUST be void
      //      - The method arguments MUST have no arguments.
      //      - The method MUST NOT define any application exceptions.
      //
      // Spec 15.7.2, 3
      //
      if (hasEJBCreateMethod(bean, false))
      {
         Iterator it = getEJBCreateMethods(bean);
         Method ejbCreate = (Method)it.next();

         if (!isPublic(ejbCreate))
         {
            fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.b"));
            status = false;
         }

         if ((isFinal(ejbCreate)) || (isStatic(ejbCreate)))
         {
            fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.c"));
            status = false;
         }

         if (!hasVoidReturnType(ejbCreate))
         {
            fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.d"));
            status = false;
         }

         if (!hasNoArguments(ejbCreate))
         {
            fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.e"));
            status = false;
         }

         if (!throwsNoException(ejbCreate))
         {
            fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.f"));
            status = false;
         }

         if (it.hasNext())
         {
            fireSpecViolationEvent(mdBean, new Section("15.7.3.a"));
            status = false;
         }
      }
      else
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.3.a"));
         status = false;
      }

      // A message driven bean MUST implement the onMessage(...) method.
      // The onMessage() method signature MUST follow these rules:
      //
      //      - The method name MUST be onMessage
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as final or static
      //      - The return type MUST be void
      //      - The method arguments MUST have a single argument of type
      //        javax.jms.Message.
      //      - The method MUST NOT define any application exceptions.
      //
      // Spec 15.7.4
      //
      if (hasOnMessageMethod(bean))
      {
         Iterator it = getOnMessageMethods(bean);
         Method onMessage = (Method)it.next();

         if (!isPublic(onMessage))
         {
            fireSpecViolationEvent(mdBean, onMessage, new Section("15.7.4.b"));
            status = false;
         }

         if ((isFinal(onMessage)) || (isStatic(onMessage)))
         {
            fireSpecViolationEvent(mdBean, onMessage, new Section("15.7.4.c"));
            status = false;
         }

         try
         {
            Class message = classloader.loadClass("javax.jms.Message");
            if (!hasSingleArgument(onMessage, message))
            {
               fireSpecViolationEvent(mdBean, onMessage,
                       new Section("15.7.4.e"));
               status = false;
            }

            if (!throwsNoException(onMessage))
            {
               fireSpecViolationEvent(mdBean, onMessage,
                       new Section("15.7.4.f"));
               status = false;
            }

            if (it.hasNext())
            {
               fireSpecViolationEvent(mdBean, new Section("15.7.4.a"));
               status = false;
            }
         }
         catch (ClassNotFoundException cnfe)
         {
            // javax.jms.Message is not available?!
         }
      }
      else
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.4.a"));
         status = false;
      }

      // A message driven bean MUST implement the ejbRemove() method.
      // The ejbRemove() method signature MUST follow these rules:
      //
      //      - The method name MUST be ejbRemove
      //      - The method MUST be declared as public
      //      - The method MUST NOT be declared as final or static
      //      - The return type MUST be void
      //      - The method MUST have no arguments.
      //      - The method MUST NOT define any application exceptions.
      //
      // Spec 15.7.5
      //
      if (hasEJBRemoveMethod(bean))
      {
         Iterator it = getEJBRemoveMethods(bean);
         Method ejbRemove = (Method)it.next();

         if (!isPublic(ejbRemove))
         {
            fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.b"));
            status = false;
         }

         if ((isFinal(ejbRemove)) || (isStatic(ejbRemove)))
         {
            fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.c"));
            status = false;
         }

         if (!hasVoidReturnType(ejbRemove))
         {
            fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.d"));
            status = false;
         }

         if (!hasNoArguments(ejbRemove))
         {
            fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.e"));
            status = false;
         }

         if (!throwsNoException(ejbRemove))
         {
            fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.f"));
            status = false;
         }

         if (it.hasNext())
         {
            fireSpecViolationEvent(mdBean, new Section("15.7.5.a"));
            status = false;
         }
      }
      else
      {
         fireSpecViolationEvent(mdBean, new Section("15.7.5.a"));
         status = false;
      }

      return status;
   }
View Full Code Here

/*  101 */       verified = (verified) && (verifyServiceEndpoint(session));
/*      */     }
/*      */
/*  112 */     if ((!localOrRemoteExists) && (!serviceEndpointExists))
/*      */     {
/*  114 */       fireSpecViolationEvent(session, new Section("7.11.1"));
/*  115 */       verified = false;
/*      */     }
/*      */
/*  118 */     if (verified)
/*      */     {
View Full Code Here

/*      */
/*  188 */     if (!localOrRemoteExists)
/*      */     {
/*  196 */       if (entity.isCMP())
/*      */       {
/*  198 */         fireSpecViolationEvent(entity, new Section("10.6.1"));
/*  199 */         verified = false;
/*      */       }
/*      */       else
/*      */       {
/*  203 */         fireSpecViolationEvent(entity, new Section("12.2.1"));
/*  204 */         verified = false;
/*      */       }
/*      */     }
/*      */
/*  208 */     if (verified)
View Full Code Here

/*  229 */       this.bean = this.classloader.loadClass(beanName);
/*  230 */       return true;
/*      */     }
/*      */     catch (ClassNotFoundException cnfe)
/*      */     {
/*  234 */       fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage()));
/*      */     }
/*  236 */     return false;
/*      */   }
View Full Code Here

/*      */     {
/*  258 */       this.home = this.classloader.loadClass(homeName);
/*      */     }
/*      */     catch (ClassNotFoundException cnfe)
/*      */     {
/*  262 */       fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage()));
/*      */
/*  264 */       status = false;
/*      */     }
/*      */
/*      */     try
/*      */     {
/*  270 */       this.remote = this.classloader.loadClass(remoteName);
/*      */     }
/*      */     catch (ClassNotFoundException cnfe)
/*      */     {
/*  274 */       fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage()));
/*      */
/*  276 */       status = false;
/*      */     }
/*      */
/*  279 */     return status;
View Full Code Here

/*      */     {
/*  300 */       this.localHome = this.classloader.loadClass(localHomeName);
/*      */     }
/*      */     catch (ClassNotFoundException cnfe)
/*      */     {
/*  304 */       fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage()));
/*      */
/*  307 */       status = false;
/*      */     }
/*      */
/*      */     try
/*      */     {
/*  312 */       this.local = this.classloader.loadClass(localName);
/*      */     }
/*      */     catch (ClassNotFoundException cnfe)
/*      */     {
/*  316 */       fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage()));
/*      */
/*  318 */       status = false;
/*      */     }
/*      */
/*  321 */     return status;
View Full Code Here

TOP

Related Classes of org.jboss.verifier.Section

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.