[jboss-jira] [JBoss JIRA] Commented: (JBMETA-41) EJBTHREE-1127 processing

Andrew Lee Rubinger (JIRA) jira-events at lists.jboss.org
Fri May 16 00:57:22 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBMETA-41?page=comments#action_12412957 ] 
            
Andrew Lee Rubinger commented on JBMETA-41:
-------------------------------------------

The logic currently used in Proxy Generation code from EJB3:

/**
    * Obtains the return types declared by the "create" methods for the specified home interface.
    * 
    * EJB3 Core Specification 3.6.2.1
    * JIRA: EJBTHREE-1127
    *  
    * @param homeInterface
    * @param isStateless Flag to indicate whether this is for a Stateful or Stateless container
    * @return
    */
   protected Set<Class<?>> getReturnTypesFromCreateMethods(Class<?> homeInterface, boolean isStateless)
   {
      // Ensure we've been passed a Home or LocalHome interface (Developers only)
      assert (EJBHome.class.isAssignableFrom(homeInterface) || EJBLocalHome.class.isAssignableFrom(homeInterface));

      // Ensure we've been passed a Home or LocalHome interface (End-User)
      if (!EJBHome.class.isAssignableFrom(homeInterface) && !EJBLocalHome.class.isAssignableFrom(homeInterface))
      {
         throw new RuntimeException("Declared EJB 2.1 Home Interface " + homeInterface.getName() + " does not extend "
               + EJBHome.class.getName() + " or " + EJBLocalHome.class.getName()
               + " as required by EJB 3.0 Core Specification 4.6.8 and 4.6.10");
      }

      // Initialize
      Set<Class<?>> types = new HashSet<Class<?>>();
      List<Method> createMethods = null;

      // If for a Stateless Container
      if (isStateless)
      {
         // Initialize error message
         String specViolationErrorMessage = "EJB 3.0 Specification Violation (4.6.8 Bullet 4, 4.6.10 Bullet 4): \""
               + "A stateless session bean must define exactly one create method with no arguments." + "\"; found in "
               + homeInterface.getName();

         // Get all methods with signature "create"
         createMethods = new ArrayList<Method>();
         try
         {
            createMethods.add(homeInterface.getMethod("create", new Class<?>[]
            {}));
         }
         // EJB 3.0 Specification 4.6.8 Bullet 4 Violation
         // EJBTHREE-1156
         catch (NoSuchMethodException e)
         {
            throw new RuntimeException(specViolationErrorMessage);
         }

         // Ensure only one create method is defined
         // EJB 3.0 Specification 4.6.8 Bullet 4 Violation
         // EJBTHREE-1156
         if (createMethods.size() > 1)
         {
            throw new RuntimeException(specViolationErrorMessage);
         }
      }
      else
      {
         // Obtain all "create<METHOD>" methods
         createMethods = ClassHelper.getAllMethodsByPrefix(homeInterface, "create");
      }
      if (createMethods.size() == 0)
      {
         throw new RuntimeException("EJB 3.0 Core Specification Violation (4.6.8 Bullet 5): EJB2.1 Home Interface "
               + homeInterface + " does not declare a \'create<METHOD>\' method");
      }

      // Add all return types
      for (Method method : createMethods)
      {
         types.add(method.getReturnType());
      }

      // Return
      return types;
   }

> EJBTHREE-1127 processing
> ------------------------
>
>                 Key: JBMETA-41
>                 URL: http://jira.jboss.com/jira/browse/JBMETA-41
>             Project: JBoss Metadata
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 1.0.0.Beta15
>            Reporter: Scott M Stark
>         Assigned To: Alexey Loubyansky
>             Fix For: 1.0.0.CR1
>
>
> Another annotation processing example is:
> @RemoteHome
> public interface RemoteHome extends EJBHome
> {
>   public RemoteInterface1 create();
>   public RemoteInterface2 create2();
> }	
> The above example defines 2 EJB2.x Remote interfaces, even though they're not explicitly marked as such anywhere.
> That's EJBTHREE-1127, defined by, "EJB3 Core Specification 3.6.2.1":
> The return type of a create method on the remote home interface is the session bean's remote interface.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list