[jboss-cvs] jboss-ejb3/src/test/org/jboss/ejb3/test/cache/nested ...

Ben Wang bwang at jboss.com
Mon Jul 24 12:52:50 EDT 2006


  User: bwang   
  Date: 06/07/24 12:52:50

  Added:       src/test/org/jboss/ejb3/test/cache/nested     Tag:
                        Branch_4_0 NestedStateful.java
                        NestedStatefulBean.java ParentStatefulBean.java
                        ParentStatefulRemote.java
  Log:
  Added test cases for simple cache.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +20 -0     jboss-ejb3/src/test/org/jboss/ejb3/test/cache/nested/Attic/NestedStateful.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NestedStateful.java
  ===================================================================
  RCS file: NestedStateful.java
  diff -N NestedStateful.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NestedStateful.java	24 Jul 2006 16:52:50 -0000	1.1.2.1
  @@ -0,0 +1,20 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.ejb3.test.cache.nested;
  +
  +/**
  + * Comment
  + *
  + * @author Ben Wang
  + * @version $Revision: 1.1.2.1 $
  + */
  +public interface NestedStateful
  +{
  +   int increment();
  +   void reset();
  +}
  
  
  
  1.1.2.1   +65 -0     jboss-ejb3/src/test/org/jboss/ejb3/test/cache/nested/Attic/NestedStatefulBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NestedStatefulBean.java
  ===================================================================
  RCS file: NestedStatefulBean.java
  diff -N NestedStatefulBean.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NestedStatefulBean.java	24 Jul 2006 16:52:50 -0000	1.1.2.1
  @@ -0,0 +1,65 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.ejb3.test.cache.nested;
  +
  +import org.jboss.logging.Logger;
  +
  +import javax.ejb.*;
  +import java.rmi.dgc.VMID;
  +
  +/**
  + * Nested SFSB
  + *
  + * @author Ben Wang
  + * @version $Revision: 1.1.2.1 $
  + */
  + at Stateful(name="testNestedStateful")
  + at org.jboss.annotation.ejb.cache.simple.CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
  +public class NestedStatefulBean implements java.io.Serializable, NestedStateful
  +{
  +   private static Logger log = Logger.getLogger(NestedStatefulBean.class);
  +   private int counter = 0;
  +
  +   public int increment()
  +   {
  +      log.debug("INCREMENT - nested counter: " + (counter++));
  +      return counter;
  +   }
  +
  +   public static int postActivateCalled = 0;
  +   public static int prePassivateCalled = 0;
  +
  +   public int getPostActivate()
  +   {
  +      return postActivateCalled;
  +   }
  +
  +   public int getPrePassivate()
  +   {
  +      return prePassivateCalled;
  +   }
  +
  +   public void reset()
  +   {
  +      counter = 0;
  +      NestedStatefulBean.postActivateCalled = 0;
  +      NestedStatefulBean.prePassivateCalled = 0;
  +   }
  +
  +   @PostActivate
  +   public void postActivate()
  +   {
  +      ++NestedStatefulBean.postActivateCalled;
  +   }
  +
  +   @PrePassivate
  +   public void prePassivate()
  +   {
  +      ++NestedStatefulBean.prePassivateCalled;
  +   }
  +}
  
  
  
  1.1.2.1   +170 -0    jboss-ejb3/src/test/org/jboss/ejb3/test/cache/nested/Attic/ParentStatefulBean.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ParentStatefulBean.java
  ===================================================================
  RCS file: ParentStatefulBean.java
  diff -N ParentStatefulBean.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ ParentStatefulBean.java	24 Jul 2006 16:52:50 -0000	1.1.2.1
  @@ -0,0 +1,170 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.ejb3.test.cache.nested;
  +
  +import org.jboss.logging.Logger;
  +import org.jboss.system.server.ServerConfig;
  +
  +import javax.interceptor.Interceptors;
  +import javax.annotation.PostConstruct;
  +import javax.ejb.EJB;
  +import javax.ejb.Stateful;
  +import javax.ejb.Remote;
  +import javax.ejb.PostActivate;
  +import javax.ejb.PrePassivate;
  +import javax.ejb.Remove;
  +import javax.ejb.EJBException;
  +import java.rmi.dgc.VMID;
  +
  +/**
  + * SFSB with nested bean
  + *
  + * @author Ben Wang
  + * @version $Revision: 1.1.2.1 $
  + */
  + at Stateful(name="testParentStateful")
  + at org.jboss.annotation.ejb.cache.simple.CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
  + at Remote(ParentStatefulRemote.class)
  +public class ParentStatefulBean implements java.io.Serializable, ParentStatefulRemote
  +{
  +   private static Logger log = Logger.getLogger(ParentStatefulBean.class);
  +   private int counter = 0;
  +   private String state;
  +   public transient VMID myId = null;
  +   public String name;
  +
  +   @EJB
  +   private NestedStateful nested;
  +
  +   public int increment()
  +   {
  +      counter = nested.increment();
  +
  +      log.debug("INCREMENT - parent counter: " + counter);
  +      return counter;
  +   }
  +
  +   public String getHostAddress()
  +   {
  +      return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
  +   }
  +
  +   public static int postActivateCalled = 0;
  +   public static int prePassivateCalled = 0;
  +
  +   /**
  +    * Sleep to test
  +    * @throws Exception
  +    */
  +   public void longRunning() throws Exception
  +   {
  +      log.debug("+++ longRunning() enter ");
  +      Thread.sleep(10000);
  +      log.debug("+++ longRunning() leave ");
  +   }
  +
  +   public int getPostActivate()
  +   {
  +      return ParentStatefulBean.postActivateCalled;
  +   }
  +
  +   public int getPrePassivate()
  +   {
  +      return ParentStatefulBean.prePassivateCalled;
  +   }
  +
  +   public int getNestedPostActivate()
  +   {
  +      return NestedStatefulBean.postActivateCalled;
  +   }
  +
  +   public int getNestedPrePassivate()
  +   {
  +      return NestedStatefulBean.prePassivateCalled;
  +   }
  +
  +   public void setState(String state)
  +   {
  +      this.state = state;
  +   }
  +
  +   public String getState()
  +   {
  +      log.debug("getState(): entering ...");
  +      return this.state;
  +   }
  +
  +   public void reset()
  +   {
  +      state = null;
  +      counter = 0;
  +      ParentStatefulBean.postActivateCalled = 0;
  +      ParentStatefulBean.prePassivateCalled = 0;
  +   }
  +
  +   public void resetActivationCounter()
  +   {
  +      ParentStatefulBean.postActivateCalled = 0;
  +      ParentStatefulBean.prePassivateCalled = 0;
  +      NestedStatefulBean.postActivateCalled = 0;
  +      NestedStatefulBean.prePassivateCalled = 0;
  +   }
  +
  +   @PostActivate
  +   public void postActivate()
  +   {
  +      ++ParentStatefulBean.postActivateCalled;
  +      if (this.myId == null)
  +      {
  +         //it is a failover: we need to assign ourself an id
  +         this.myId = new VMID();
  +      }
  +      log.debug("Activate. My ID: " + this.myId + " name: " + this.name);
  +   }
  +
  +   @PrePassivate
  +   public void prePassivate()
  +   {
  +      ++ParentStatefulBean.prePassivateCalled;
  +      log.debug("Passivate. My ID: " + this.myId + " name: " + this.name);
  +   }
  +
  +   @Remove
  +   public void remove()
  +   {
  +   }
  +
  +   @PostConstruct
  +   public void ejbCreate()
  +   {
  +      this.myId = new VMID();
  +      log.debug("My ID: " + this.myId);
  +   }
  +
  +   // Remote Interface implementation ----------------------------------------------
  +
  +   public void setName(String name)
  +   {
  +      this.name = name;
  +      log.debug("Name set to " + name);
  +   }
  +
  +   public void setNameOnlyOnNode(String name, VMID node)
  +   {
  +      if (node.equals(this.myId))
  +         this.setName(name);
  +      else
  +         throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node);
  +   }
  +
  +   public void setUpFailover(String failover) {
  +      // To setup the failover property
  +      log.debug("Setting up failover property: " +failover);
  +      System.setProperty ("JBossCluster-DoFail", failover);
  +   }
  +}
  
  
  
  1.1.2.1   +46 -0     jboss-ejb3/src/test/org/jboss/ejb3/test/cache/nested/Attic/ParentStatefulRemote.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ParentStatefulRemote.java
  ===================================================================
  RCS file: ParentStatefulRemote.java
  diff -N ParentStatefulRemote.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ ParentStatefulRemote.java	24 Jul 2006 16:52:50 -0000	1.1.2.1
  @@ -0,0 +1,46 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
  +package org.jboss.ejb3.test.cache.nested;
  +
  +import java.rmi.dgc.VMID;
  +
  +/**
  + * Comment
  + *
  + * @author Ben Wang
  + * @version $Revision: 1.1.2.1 $
  + */
  +public interface ParentStatefulRemote
  +{
  +   int increment();
  +   String getHostAddress();
  +
  +   int getPostActivate();
  +
  +   int getPrePassivate();
  +
  +   int getNestedPostActivate();
  +
  +   int getNestedPrePassivate();
  +
  +   void setState(String state);
  +
  +   String getState();
  +
  +   void reset();
  +
  +   void resetActivationCounter();
  +
  +   void longRunning() throws Exception;
  +
  +   void remove();
  +
  +   public void setName(String name);
  +
  +   public void setNameOnlyOnNode(String name, VMID node);
  +}
  
  
  



More information about the jboss-cvs-commits mailing list