I was just reading over the commit logs and noticed this patch to the
MDB code. I'd like to echo everyone else's comments that is is very
high quality work, and I am excited to see that MDBs deploy now. I
have some specific comments below...
======================================================================
========
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/
main/java/org/apache/openejb/core/CoreDeploymentInfo.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/
main/java/org/apache/openejb/core/CoreDeploymentInfo.java Wed Jan
3 22:06:16 2007
@@ -173,6 +177,13 @@
throw new SystemException(e);
}
}
+ if (TimedObject.class.isAssignableFrom(beanClass)) {
+ try {
+ this.ejbTimeout = beanClass.getMethod("ejbTimeout");
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException(e);
+ }
+ }
}
In EJB3 is there an annotation for Timeout?
+
+ /**
+ Only the NOT_SUPPORTED and REQUIRED transaction
attributes may be used for message-driven
+ bean message listener methods. The use of the other
transaction attributes is not meaningful
+ for message-driven bean message listener methods
because there is no pre-existing client transaction
+ context(REQUIRES_NEW, SUPPORTS) and no client to handle
exceptions (MANDATORY, NEVER).
+ */
+ if (componentType.isMessageDriven() && !
isBeanManagedTransaction && container instanceof
TransactionContainer) {
+ if (policy.policyType != policy.NotSupported &&
policy.policyType != policy.Required) {
+ if (method.equals(this.ejbTimeout) &&
policy.policyType == policy.RequiresNew) {
+ // do nothing. This is allowed as the timer
callback method for a message driven bean
+ // can also have a transaction policy of
RequiresNew Sec 5.4.12 of Ejb 3.0 Core Spec
+ } else {
+ throw new OpenEJBException("The transaction
attribute " + policy.policyToString() + "is not supported for the
method "
+ + method.getName()
+ " of the Message Driven Bean " + beanClass.getName());
+ }
+ }
+ }
We should add this check to the verifier. Also it would be helpful
to explicitly say in the exception message that only NotSupported and
Required are allowed.
BTW, have you tried sending a message through the container yet?
Very good work!
-dain