Title: [2626] branches/v2_1/openejb2/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java: Use reflection to determin if an ejb implements the TimedObject interface.
Revision
2626
Author
dain
Date
2006-04-27 17:17:09 -0400 (Thu, 27 Apr 2006)

Log Message

Use reflection to determin if an ejb implements the TimedObject interface.  This change is required because the deployers see different versions of the spec classes then are used for the deployed objects themselves.  This change should be reverted once the deployment classloader structure is fixed.

Modified Paths

Diff

Modified: branches/v2_1/openejb2/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java (2625 => 2626)

--- branches/v2_1/openejb2/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java	2006-04-26 04:18:19 UTC (rev 2625)
+++ branches/v2_1/openejb2/modules/openejb-builder/src/java/org/openejb/deployment/AbstractContainerBuilder.java	2006-04-27 21:17:09 UTC (rev 2626)
@@ -517,18 +517,26 @@
     }
 
     protected AbstractNameQuery getTimerName(Class beanClass) {
-        AbstractNameQuery timerName = null;
-        if (TimedObject.class.isAssignableFrom(beanClass)) {
-            InterfaceMethodSignature signature = new InterfaceMethodSignature("ejbTimeout", new Class[]{Timer.class}, false);
-            TransactionPolicy transactionPolicy = TransactionPolicies.getTransactionPolicy(getTransactionPolicySource().getTransactionPolicy("timeout", signature));
-            boolean isTransacted = transactionPolicy == ContainerPolicy.Required || transactionPolicy == ContainerPolicy.RequiresNew;
-            if (isTransacted) {
-                timerName = getTransactedTimerName();
-            } else {
-                timerName = getNonTransactedTimerName();
-            }
+        // use reflection to determine if class implements TimedObject
+        // todo remove the reflection code when we adjust the class loaders so deployment sees the same classes as the deployers
+        Class timedObjectClass = null;
+        try {
+            timedObjectClass = beanClass.getClassLoader().loadClass("javax.ejb.TimedObject");
+        } catch (ClassNotFoundException e) {
+            return null;
         }
-        return timerName;
+        if (!timedObjectClass.isAssignableFrom(beanClass)) {
+            return null;
+        }
+
+        InterfaceMethodSignature signature = new InterfaceMethodSignature("ejbTimeout", new Class[]{Timer.class}, false);
+        TransactionPolicy transactionPolicy = TransactionPolicies.getTransactionPolicy(getTransactionPolicySource().getTransactionPolicy("timeout", signature));
+        boolean isTransacted = transactionPolicy == ContainerPolicy.Required || transactionPolicy == ContainerPolicy.RequiresNew;
+        if (isTransacted) {
+            return getTransactedTimerName();
+        } else {
+            return getNonTransactedTimerName();
+        }
     }
 
 }

Reply via email to