[jboss-cvs] JBossAS SVN: r106359 - projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 1 06:36:57 EDT 2010


Author: jaikiran
Date: 2010-07-01 06:36:57 -0400 (Thu, 01 Jul 2010)
New Revision: 106359

Modified:
   projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java
Log:
EJBTHREE-2128 1) Included an additional check for metadata type (2) include non-public method(s) while looking for timeout method

Modified: projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java
===================================================================
--- projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	2010-07-01 10:11:55 UTC (rev 106358)
+++ projects/ejb3/trunk/timerservice-deployer/src/main/java/org/jboss/ejb3/timerservice/deployer/AutoTimerInitializer.java	2010-07-01 10:36:57 UTC (rev 106359)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.timerservice.deployer;
 
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.List;
 
 import javax.ejb.TimerConfig;
@@ -115,7 +116,7 @@
 
       List<TimerMetaData> autoTimersMetaData = null;
 
-      if (enterpriseBeanMetaData.isSession())
+      if (enterpriseBeanMetaData.isSession() && enterpriseBeanMetaData instanceof JBossSessionBean31MetaData)
       {
          JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBeanMetaData;
          // Stateful beans don't have timerservice/timers
@@ -126,7 +127,8 @@
          // Get hold of the auto timer metadata
          autoTimersMetaData = sessionBean.getTimers();
       }
-      else if (enterpriseBeanMetaData.isMessageDriven())
+      else if (enterpriseBeanMetaData.isMessageDriven()
+            && enterpriseBeanMetaData instanceof JBossMessageDrivenBean31MetaData)
       {
          JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBeanMetaData;
          // get hold of auto timer metadata
@@ -157,9 +159,20 @@
          TimerConfig timerConfig = new TimerConfig();
          timerConfig.setPersistent(autoTimerMetaData.isPersistent());
          timerConfig.setInfo(autoTimerMetaData.getInfo());
+         NamedMethodMetaData timeoutMethodMetaData = autoTimerMetaData.getTimeoutMethod();
          // get hold of the timeout method for this auto-timer
-         Method timeoutMethod = this.getTimeoutMethod(autoTimerMetaData.getTimeoutMethod(), this.container
-               .getBeanClass());
+         Method timeoutMethod = this.getTimeoutMethod(timeoutMethodMetaData, this.container.getBeanClass());
+         if (timeoutMethod == null)
+         {
+            StringBuilder methodStringBuilder = new StringBuilder();
+            methodStringBuilder.append(timeoutMethodMetaData.getMethodName());
+            if (timeoutMethodMetaData.getMethodParams() != null)
+            {
+               methodStringBuilder.append(Arrays.toString(timeoutMethodMetaData.getMethodParams().toArray()));
+            }
+            throw new IllegalStateException("Timeout method: " + methodStringBuilder.toString() + " not found for bean class: "
+                  + enterpriseBeanMetaData.getEjbClass());
+         }
          // finally create/get the auto timer
          ejb31TimerService.getAutoTimer(autoTimerMetaData.getScheduleExpression(), timerConfig, timeoutMethod);
       }
@@ -204,28 +217,33 @@
          }
       }
       // now start looking for the method
-      Method[] methods = beanClass.getMethods();
-      for (Method method : methods)
+      Class<?> klass = beanClass;
+      while (klass != null)
       {
-         if (method.getName().equals(timeoutMethodName))
+         Method[] methods = beanClass.getDeclaredMethods();
+         for (Method method : methods)
          {
-            Class<?>[] methodParamTypes = method.getParameterTypes();
-            // param length doesn't match
-            if (timeoutMethodParamTypes.length != methodParamTypes.length)
+            if (method.getName().equals(timeoutMethodName))
             {
-               continue;
-            }
-            for (int i = 0; i < methodParamTypes.length; i++)
-            {
-               // param type doesn't match
-               if (timeoutMethodParamTypes[i].equals(methodParamTypes[i]) == false)
+               Class<?>[] methodParamTypes = method.getParameterTypes();
+               // param length doesn't match
+               if (timeoutMethodParamTypes.length != methodParamTypes.length)
                {
                   continue;
                }
+               for (int i = 0; i < methodParamTypes.length; i++)
+               {
+                  // param type doesn't match
+                  if (timeoutMethodParamTypes[i].equals(methodParamTypes[i]) == false)
+                  {
+                     continue;
+                  }
+               }
+               // match found
+               return method;
             }
-            // match found
-            return method;
          }
+         klass = klass.getSuperclass();
       }
       // no match found
       return null;



More information about the jboss-cvs-commits mailing list