Methods Summary |
---|
public static javax.naming.InitialContext | getInitialContext()
return new InitialContext();
|
public static void | main(java.lang.String[] args)
testWithFlushMode();
testLongLivedSession();
|
public static void | testLongLivedSession()
ShoppingCart test = (ShoppingCart) getInitialContext().lookup("ShoppingCartBean/remote");
StatelessRemote remote = (StatelessRemote) getInitialContext().lookup("StatelessSessionBean/remote");
Customer c;
long id = test.createCustomer();
c = remote.find(id);
System.out.println("Created customer: " + c.getName());
test.update();
c = remote.find(id);
System.out.println("ShoppingCartBean.customer should stay managed because we're in an extended PC: Customer.getName() == " + c.getName());
test.update3();
c = remote.find(id);
System.out.println("Extended persistence contexts are propagated to nested EJB calls: Customer.getName() == " + c.getName());
test.checkout();
|
public static void | testWithFlushMode()
ShoppingCart cart = (ShoppingCart) getInitialContext().lookup("ShoppingCartBean/remote");
StatelessRemote dao = (StatelessRemote) getInitialContext().lookup("StatelessSessionBean/remote");
Customer c;
long id;
id = cart.createCustomer();
c = dao.find(id);
System.out.println("Created customer: " + c.getName());
cart.never();
c = dao.find(id);
System.out.println("Customer's name should still be William as pc was not yet flushed: Customer.getName() == " + c.getName());
cart.checkout();
c = dao.find(id);
System.out.println("Now that the pc has been flushed name should be 'Bob': Customer.getName() == " + c.getName());
|