First page Back Continue Last page Graphics
...Continuation of Notes
Notes:
Extending set*Context( )
If a bean class needs to extend the setSessionContext( ) or setEntityContext( ) method to perform additional initialization, it simply uses super.set*Context( ). Earlier, we saw how ShoppingCartBean uses setSessionContext( ) to acquire references to BookHome and CustomerHome. Here is a revised version using the base class:
public class ShoppingCartBean extends SessionBase {
// private SessionContext _sctxt; // No longer needed
private BookHome _bookhome;
private CustomerHome _custhome;
public void setSessionContext(SessionContext sctxt) {
super.setSessionContext(sctxt); // Call ancestor method
// Look up related homes:
Context ctxt = ...; // Get initial JNDI context
_bookhome = ctxt.lookup(...); // Look up book home
_customerhome = ctxt.lookup(...); // Look up customer home
}
// Rest of class...
}