djencks     2005/02/14 13:32:15

  Modified:    modules/core/src/java/org/openejb
                        AbstractInstanceContext.java
                        EJBInstanceContext.java GenericEJBContainer.java
  Log:

  implement the amazing rules on when getTimerService() and the TimerService 
and Timer methods are available
  
  Revision  Changes    Path
  1.7       +21 -6     
openejb/modules/core/src/java/org/openejb/AbstractInstanceContext.java
  
  Index: AbstractInstanceContext.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/AbstractInstanceContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractInstanceContext.java      5 Feb 2005 02:36:23 -0000       1.6
  +++ AbstractInstanceContext.java      14 Feb 2005 18:32:12 -0000      1.7
  @@ -20,15 +20,14 @@
   import java.util.HashMap;
   import java.util.Map;
   import java.util.Set;
  -
   import javax.ejb.EnterpriseBean;
   import javax.ejb.TimerService;
   
   import org.apache.geronimo.core.service.Interceptor;
  -import org.openejb.dispatch.SystemMethodIndices;
   import org.openejb.proxy.EJBProxyFactory;
  -import org.openejb.timer.BasicTimerService;
   import org.openejb.timer.TimerServiceImpl;
  +import org.openejb.timer.BasicTimerService;
  +import org.openejb.timer.UnavailableTimerService;
   
   
   /**
  @@ -49,16 +48,20 @@
       protected EJBInvocation setContextInvocation;
       protected EJBInvocation unsetContextInvocation;
       protected final Interceptor systemChain;
  +    private final BasicTimerService activeTimer;
       private final TimerService timerService;
   
  +    private BasicTimerService timerState = UnavailableTimerService.INSTANCE;
  +
   
  -    public AbstractInstanceContext(Interceptor systemChain, Set 
unshareableResources, Set applicationManagedSecurityResources, EnterpriseBean 
instance, EJBProxyFactory proxyFactory, BasicTimerService timerService) {
  +    public AbstractInstanceContext(Interceptor systemChain, Set 
unshareableResources, Set applicationManagedSecurityResources, EnterpriseBean 
instance, EJBProxyFactory proxyFactory, BasicTimerService basicTimerService) {
           this.unshareableResources = unshareableResources;
           this.applicationManagedSecurityResources = 
applicationManagedSecurityResources;
           this.instance = instance;
           this.proxyFactory = proxyFactory;
           this.systemChain = systemChain;
  -        this.timerService = new TimerServiceImpl(timerService, this);
  +        this.activeTimer = basicTimerService;
  +        this.timerService = basicTimerService == null? null: new 
TimerServiceImpl(this);
       }
   
       public Object getId() {
  @@ -114,6 +117,18 @@
   
       public TimerService getTimerService() {
           return timerService;
  +    }
  +
  +    public BasicTimerService getBasicTimerService() {
  +        return timerState;
  +    }
  +
  +    public void setTimerServiceAvailable(boolean available) {
  +        if (available) {
  +            timerState = activeTimer;
  +        } else {
  +            timerState = UnavailableTimerService.INSTANCE;
  +        }
       }
   
   }
  
  
  
  1.5       +11 -6     
openejb/modules/core/src/java/org/openejb/EJBInstanceContext.java
  
  Index: EJBInstanceContext.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/EJBInstanceContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EJBInstanceContext.java   20 Jul 2004 23:40:01 -0000      1.4
  +++ EJBInstanceContext.java   14 Feb 2005 18:32:12 -0000      1.5
  @@ -48,16 +48,13 @@
   package org.openejb;
   
   import javax.ejb.EnterpriseBean;
  +import javax.ejb.TimerService;
   
   import org.apache.geronimo.transaction.InstanceContext;
  -
   import org.openejb.proxy.EJBProxyFactory;
   import org.openejb.timer.BasicTimerService;
   
   /**
  - *
  - *
  - *
    * @version $Revision$ $Date$
    */
   public interface EJBInstanceContext extends InstanceContext {
  @@ -68,5 +65,13 @@
   
       EJBProxyFactory getProxyFactory();
   
  -    javax.ejb.TimerService getTimerService();
  +    TimerService getTimerService();
  +
  +    BasicTimerService getBasicTimerService();
  +
  +    void setTimerServiceAvailable(boolean available);
  +
  +    //sets timer method availability based on operation, returns old 
availability
  +    boolean setTimerState(EJBOperation operation);
  +
   }
  
  
  
  1.37      +4 -4      
openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java
  
  Index: GenericEJBContainer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/GenericEJBContainer.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- GenericEJBContainer.java  12 Feb 2005 00:48:19 -0000      1.36
  +++ GenericEJBContainer.java  14 Feb 2005 18:32:12 -0000      1.37
  @@ -93,7 +93,7 @@
   import org.openejb.proxy.EJBProxyFactory;
   import org.openejb.proxy.ProxyInfo;
   import org.openejb.security.SecurityConfiguration;
  -import org.openejb.timer.BasicTimerService;
  +import org.openejb.timer.BasicTimerServiceImpl;
   
   
   /**
  @@ -118,7 +118,7 @@
       private final SecurityConfiguration securityConfiguration;
       private transient PolicyConfiguration policyConfiguration;
       private transient Subject defaultSubject;
  -    private final BasicTimerService timerService;
  +    private final BasicTimerServiceImpl timerService;
   
   
       public GenericEJBContainer(Object containerId,
  @@ -198,7 +198,7 @@
           contextFactory.setSystemChain(chains.getSystemChain());
           
contextFactory.setTransactionContextManager(transactionContextManager);
           if (timer != null) {
  -            timerService = new BasicTimerService(systemMethodIndices, 
interceptor, timer, objectName, kernel.getKernelName(), 
ObjectName.getInstance(objectName), transactionContextManager, classLoader);
  +            timerService = new BasicTimerServiceImpl(systemMethodIndices, 
interceptor, timer, objectName, kernel.getKernelName(), 
ObjectName.getInstance(objectName), transactionContextManager, classLoader);
               contextFactory.setTimerService(timerService);
           } else {
               timerService = null;
  
  
  

Reply via email to