FileDocCategorySizeDatePackage
BankBean.javaAPI DocJBoss 4.2.17369Fri Jul 13 20:53:28 BST 2007org.jboss.ejb3.test.bank

BankBean

public class BankBean extends Object implements Serializable, javax.ejb.SessionSynchronization
see
author
$Author: wolfc $
version
$Revision: 60233 $

Fields Summary
private static final Logger
log
public transient DataSource
customerDb
static final String
ID
String
id
String
customerId
static long
nextAccountId
static long
nextCustomerId
String
initialized
private String
activated
private String
transactionState
private String
rollbackState
private boolean
beforeCalled
Constructors Summary
Methods Summary
public voidafterBegin()

      rollbackState = transactionState;
   
public voidafterCompletion(boolean committed)

      if (!committed)
         transactionState = rollbackState;  
   
public voidannotatedInit()

      initialized += "YES";
   
public voidbeforeCompletion()

      beforeCalled = true;
   
public java.lang.StringcreateAccountId(Customer customer)

      return getId() + "." + customer.getName() + "." + (nextAccountId++);
   
public java.lang.StringcreateCustomerId()

      return getId() + "." + (nextCustomerId++);
   
public java.lang.StringgetEnvEntryId()

      InitialContext jndiContext = new InitialContext();
      String value = (String)jndiContext.lookup(ID);
      return value;
   
public java.lang.StringgetId()


     
   
      return id;
   
public java.lang.StringgetTransactionState()

      return transactionState;
   
public voidinit()

      initialized += "YES";
   
public java.lang.StringinterceptCustomerId(java.lang.String customerId)

      return customerId;
   
public java.lang.StringisActivated()

      return activated;
   
public java.lang.StringisInitialized()

      return initialized;
   
public voidremove()

   
public java.lang.StringretrieveCustomerId()

      return customerId;
   
public voidstoreCustomerId(java.lang.String customerId)

      this.customerId = customerId;
   
public voidtestResource()

      if (customerDb == null) throw new Exception("customerDb resource not set");
      Connection connection = customerDb.getConnection();
      connection.close();
   
public voidtestTransactionTimeout()

      try
      {
         Thread.sleep(2000);
         transactionState = "ok";
      } 
      catch (Exception e)
      {
         e.printStackTrace();
      }