Bean things you can do during creation

(stateful session bean)

image with no caption
image with no caption

constructor

setSessionContext()

ejbCreate()

nothing

Note

It’s too early to DO anything! You’re an object, but not yet a bean.

Use your SessionContext to:

Use your SessionContext to:

 

get a reference to your home

get a reference to your home

 

get a reference to your EJB object

get a reference to your EJB object

 

get security information about the client

get security information about the client

 

force a transaction to rollback (CMT beans)

force a transaction to rollback (CMT beans)

 

find out if the transaction has already been set to rollback (CMT beans)

find out if the transaction has already been set to rollback (CMT beans)

 

get a transaction reference, and call methods on it (BMT beans)

get a transaction reference, and call methods on it (BMT beans)

 

Access:

Access:

 

your special JNDI environment

your special JNDI environment

 

another bean’s methods

another bean’s methods

 

a resource manager (like a database)

a resource manager (like a database)

Note: the word “access” means “do things with”, so when the spec uses the phrase “resource manager access”, it means using the resource to do whatever that resource is for. So in setSessionContext(), for example, you can use JNDI to look up a resource manager connection factory, like javax.sql.DataSource, and you can ask the DataSource for a connection (myDataSource.getConnection()), but you can’t make a JDBC call on the connection reference. You can use your connection in ejbCreate().

image with no caption

an aspiring Bean Provider

image with no caption

the more experienced Bean Provider

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.