FileDocCategorySizeDatePackage
NonAnnotationStatefulBean.javaAPI DocJBoss 4.2.14826Fri Jul 13 20:53:12 BST 2007org.jboss.ejb3.test.clusteredsession

NonAnnotationStatefulBean

public class NonAnnotationStatefulBean extends Object implements StatefulRemote, Serializable
Base class for various configs of a SFSB. No class-level clustering annotations applied so it can serve as a bean class that doesn't use annotations, or be subclassed by a bean that adds annotations.
see
StatefulBean
author
Ben Wang
author
Brian Stansberry
version
$Revision: 57207 $

Fields Summary
private static final long
serialVersionUID
The serialVersionUID
private Logger
log
private int
counter
private String
state
public static final VMID
myId
public String
name
private int
postActivateCalled
private int
prePassivateCalled
Constructors Summary
Methods Summary
public voidejbCreate()

      log.debug("My ID: " + myId);
   
public java.lang.StringgetHostAddress()

      return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
   
public NodeAnswergetNodeState()

      NodeAnswer state = new NodeAnswer(myId, this.name);
      log.debug("getNodeState, " + state);
      return state;
   
public intgetPostActivate()

      return postActivateCalled;
   
public intgetPrePassivate()

      return prePassivateCalled;
   
public java.lang.StringgetState()

      log.debug("getState(): entering ...");
      return this.state;
   
public intincrement()


     
   
      System.out.println("INCREMENT - counter: " + (counter++));
      return counter;
   
public voidlongRunning()
Sleep to test

throws
Exception

      log.debug("+++ longRunning() enter ");
      Thread.sleep(20000); // 20000 will break the passivation test now.
      log.debug("+++ longRunning() leave ");
   
public voidpostActivate()

      postActivateCalled++;
      log.debug("Activate. My ID: " + myId + " name: " + this.name);
   
public voidprePassivate()

      prePassivateCalled++;
      log.debug("Passivate. My ID: " + myId + " name: " + this.name);
   
public voidremove()

   
public voidreset()

      state = null;
      postActivateCalled = 0;
      prePassivateCalled = 0;
   
public voidresetActivationCounter()

      postActivateCalled = 0;
      prePassivateCalled = 0;
   
public voidsetName(java.lang.String name)

      this.name = name;
      log.debug("Name set to " + name);
   
public voidsetNameOnlyOnNode(java.lang.String name, java.rmi.dgc.VMID node)

      if (node.equals(myId))
         this.setName(name);
      else
         throw new EJBException("Trying to assign value on node " + myId + " but this node expected: " + node);
   
public voidsetState(java.lang.String state)

      this.state = state;
   
public voidsetUpFailover(java.lang.String failover)

      // To setup the failover property
      log.debug("Setting up failover property: " +failover);
      System.setProperty ("JBossCluster-DoFail", failover);