Author: genspring
Date: Thu May 26 03:40:41 2011
New Revision: 1127772
URL: http://svn.apache.org/viewvc?rev=1127772&view=rev
Log:
OPENEJB-1560 Allow the user to call timer service method even when there are no
ejbTimeout method in the ejb.
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/NullEjbTimerServiceImpl.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/TimerServiceWrapper.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/NullEjbTimerServiceImpl.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/NullEjbTimerServiceImpl.java?rev=1127772&r1=1127771&r2=1127772&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/NullEjbTimerServiceImpl.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/NullEjbTimerServiceImpl.java
Thu May 26 03:40:41 2011
@@ -25,6 +25,8 @@ import javax.ejb.Timer;
import javax.ejb.TimerConfig;
import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
/**
* Idempotent EjbTimerServiceImplementation. Used if a Bean does not implement
a timeout method or no auto-started timer is configured by annotation or
deployment plan.
@@ -32,33 +34,42 @@ import org.apache.openejb.OpenEJBExcepti
* There's nothing in the spec which says a timeout-less bean cannot call
getTimerService. So, we now have NullEjbTimerServiceImpl, which does not do
very much...
*/
public class NullEjbTimerServiceImpl implements EjbTimerService {
+
+ private static final Logger log = Logger.getInstance(LogCategory.TIMER,
NullEjbTimerServiceImpl.class);
public Timer createTimer(Object primaryKey, Method timeoutMethod,
ScheduleExpression schedule, TimerConfig timerConfig) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Timer createTimer(Object primaryKey, Method timeoutMethod, Date
initialExpiration, long intervalDuration, TimerConfig timerConfig) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Timer createTimer(Object primaryKey, Method timeoutMethod, Date
expiration, TimerConfig timerConfig) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Timer createTimer(Object primaryKey, Method timeoutMethod, long
initialDuration, long intervalDuration, TimerConfig timerConfig) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Timer createTimer(Object primaryKey, Method timeoutMethod, long
duration, TimerConfig timerConfig) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Timer getTimer(long id) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public Collection<Timer> getTimers(Object primaryKey) {
- throw new IllegalStateException("TimerService operation not supported
for a bean without an ejbTimeout method or auto-started task");
+ log.error("Null ! TimerService operation not supported for a bean
without an ejbTimeout method or auto-started task");
+ return null;
}
public void start() throws OpenEJBException {
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/TimerServiceWrapper.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/TimerServiceWrapper.java?rev=1127772&r1=1127771&r2=1127772&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/TimerServiceWrapper.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/timer/TimerServiceWrapper.java
Thu May 26 03:40:41 2011
@@ -33,8 +33,12 @@ import org.apache.openejb.BeanContext;
import org.apache.openejb.MethodContext;
import org.apache.openejb.core.ThreadContext;
import org.apache.openejb.core.transaction.TransactionType;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
public class TimerServiceWrapper implements TimerService {
+
+ private static final Logger log = Logger.getInstance(LogCategory.TIMER,
TimerServiceWrapper.class);
public TimerServiceWrapper() {
}
@@ -102,7 +106,7 @@ public class TimerServiceWrapper impleme
}
if (!hasSchedules) {
- throw new IllegalStateException("This ejb does not support
timers " + beanContext.getDeploymentID() + " due to no timeout method nor
schedules in methodContext is configured");
+ log.error("This ejb does not support timers " +
beanContext.getDeploymentID() + " due to no timeout method nor schedules in
methodContext is configured");
}
}