[jboss-cvs] JBossAS SVN: r59043 - in trunk/server/src/main/org/jboss/ejb: . txtimer
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 14 08:39:33 EST 2006
Author: alex.loubyansky at jboss.com
Date: 2006-12-14 08:39:30 -0500 (Thu, 14 Dec 2006)
New Revision: 59043
Modified:
trunk/server/src/main/org/jboss/ejb/Container.java
trunk/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
Log:
JBCTS-381 allow to objects that don't implement TimedObject to call ctx.getTimerService()
Modified: trunk/server/src/main/org/jboss/ejb/Container.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/Container.java 2006-12-14 13:36:11 UTC (rev 59042)
+++ trunk/server/src/main/org/jboss/ejb/Container.java 2006-12-14 13:39:30 UTC (rev 59043)
@@ -33,7 +33,10 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.Date;
+import java.util.Collection;
import java.rmi.MarshalException;
+import java.io.Serializable;
import javax.ejb.EJBException;
import javax.ejb.EJBObject;
@@ -58,6 +61,7 @@
import org.jboss.deployment.DeploymentInfo;
import org.jboss.ejb.plugins.local.BaseLocalProxyFactory;
import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.ejb.txtimer.EJBTimerServiceImpl;
import org.jboss.invocation.*;
import org.jboss.logging.Logger;
import org.jboss.metadata.ApplicationMetaData;
@@ -700,13 +704,10 @@
throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService");
// Validate that the bean implements the TimedObject interface
- Class beanClass = this.getBeanClass();
if( TimedObject.class.isAssignableFrom(beanClass) == false )
{
- String msg = this.getBeanMetaData().getEjbName()
- +" requested getTimerService but "+beanClass
- +" does not implement javax.ejb.TimedObject";
- throw new IllegalStateException(msg);
+ // jbcts-381
+ return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT;
}
TimerService timerService = null;
Modified: trunk/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java 2006-12-14 13:36:11 UTC (rev 59042)
+++ trunk/server/src/main/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java 2006-12-14 13:39:30 UTC (rev 59043)
@@ -30,8 +30,12 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Date;
+import java.io.Serializable;
import javax.ejb.TimerService;
+import javax.ejb.Timer;
+import javax.ejb.EJBException;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
@@ -57,6 +61,44 @@
// Logging support
private static Logger log = Logger.getLogger(EJBTimerServiceImpl.class);
+ /**
+ * Used for objects that don't implement javax.ejb.TimedObject but still call getTimerService()
+ * According to the CTS, it's allowed (jbcts-381).
+ */
+ public static TimerService FOR_NON_TIMED_OBJECT = new TimerService()
+ {
+ public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException,
+ IllegalStateException,
+ EJBException
+ {
+ throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!");
+ }
+
+ public Timer createTimer(long initialDuration, long intervalDuration, Serializable info)
+ throws IllegalArgumentException, IllegalStateException, EJBException
+ {
+ throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!");
+ }
+
+ public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException,
+ IllegalStateException,
+ EJBException
+ {
+ throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!");
+ }
+
+ public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info)
+ throws IllegalArgumentException, IllegalStateException, EJBException
+ {
+ throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!");
+ }
+
+ public Collection getTimers() throws IllegalStateException, EJBException
+ {
+ return Collections.EMPTY_LIST;
+ }
+ };
+
// Attributes
// The object name of the retry policy
More information about the jboss-cvs-commits
mailing list