[jboss-cvs] jboss-ejb3/src/main/org/jboss/ejb3/service ...
Carlo de Wolf
carlo at nerdnet.nl
Tue Jul 11 06:01:57 EDT 2006
User: wolfc
Date: 06/07/11 06:01:57
Modified: src/main/org/jboss/ejb3/service ServiceContainer.java
Log:
EJBTHREE-613: working service container timeout
Revision Changes Path
1.42 +40 -6 jboss-ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServiceContainer.java
===================================================================
RCS file: /cvsroot/jboss/jboss-ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- ServiceContainer.java 7 Jun 2006 14:40:55 -0000 1.41
+++ ServiceContainer.java 11 Jul 2006 10:01:57 -0000 1.42
@@ -23,6 +23,9 @@
import java.lang.reflect.Method;
import java.util.Hashtable;
+
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
import javax.ejb.TimerService;
import javax.management.Attribute;
import javax.management.AttributeList;
@@ -33,33 +36,36 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.ReflectionException;
+
import org.jboss.annotation.ejb.Management;
import org.jboss.annotation.ejb.Service;
import org.jboss.aop.AspectManager;
import org.jboss.aop.MethodInfo;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.annotation.AnnotationRepository;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.util.MethodHashing;
import org.jboss.aop.util.PayloadKey;
import org.jboss.aspects.asynch.FutureHolder;
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb.AllowedOperationsFlags;
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.EJBContainerInvocation;
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.SessionContainer;
import org.jboss.ejb3.ThreadLocalENCFactory;
import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
-import org.jboss.ejb3.injection.Injector;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.timerservice.TimedObjectInvoker;
+import org.jboss.ejb3.timerservice.TimerServiceFactory;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision: 1.41 $
+ * @version $Revision: 1.42 $
*/
-public class ServiceContainer extends SessionContainer
+public class ServiceContainer extends SessionContainer implements TimedObjectInvoker
{
ServiceMBeanDelegate delegate;
Object singleton;
@@ -67,6 +73,7 @@
BeanContext beanContext;
MBeanServer mbeanServer;
ObjectName delegateObjectName;
+ private TimerService timerService;
private static final Logger log = Logger.getLogger(ServiceContainer.class);
@@ -79,6 +86,28 @@
this.mbeanServer = server;
}
+ public void callTimeout(Timer timer) throws Exception
+ {
+ Method timeout = callbackHandler.getTimeoutCallback();
+ if (timeout == null) throw new EJBException("No method has been annotated with @Timeout");
+ Object[] args = {timer};
+ AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
+ try
+ {
+ localInvoke(timeout, args);
+ }
+ catch(Throwable throwable)
+ {
+ if (throwable instanceof Exception) throw (Exception) throwable;
+ if(throwable instanceof Error) throw (Error) throwable;
+ throw new RuntimeException(throwable);
+ }
+ finally
+ {
+ AllowedOperationsAssociation.popInMethodFlag();
+ }
+ }
+
public Object getSingleton()
{
return singleton;
@@ -102,6 +131,9 @@
initBeanContext();
+ // make sure the timer service is there before injection takes place
+ timerService = TimerServiceFactory.createTimerService(this.getObjectName(), this);
+
injectDependencies(beanContext);
registerManagementInterface();
@@ -115,6 +147,8 @@
public void stop() throws Exception
{
+ if (timerService != null) TimerServiceFactory.removeTimerService(timerService);
+
super.stop();
if (delegate != null)
@@ -136,7 +170,7 @@
public TimerService getTimerService()
{
- throw new RuntimeException("TimerService not implemented for container");
+ return timerService;
}
public void invokePostConstruct(BeanContext beanContext)
More information about the jboss-cvs-commits
mailing list