In HFEJB, p. 327, it states that you can use your entity context to get a reference to your home. Does this imply that a home object will exist for entity beans in general, or that a home object will be created for each different type of entity bean before they are actually instantiated?
For example, I have 2 entity beans: CustomerBean and ProductBean. My container decides to create a few bean instances in the pool to serve as "actors" for these 2 entity beans. So, the constructor is called and the entity context is set. In the entity context, will I be able to get the home for entity beans in general, or is it more specific; does it create a home object for CustomerBean and a home object for ProductBean? If that's the case, are the beans in the pool "type-casted", meaning that will a bean instance in the pool only be capable of playing CustomerBean roles because it's entity context has it slaved to a customer home?
The relation to a bean to its respective home object is many to one (typically, but some situations may warrent to have multiple home object each handling some set of beans). Therefore for your CustomerBean object there should be a home (say CustomerHome) object. Otherwise, how will CustomerBean get instantiated? The create signatures of you CustomerBean is known only to the home (CustomerHome). Therefore, every bean has a corresponding home object. The reference to the home object in the bean context refers to that bean's home object.
In the entity context, will I be able to get the home for entity beans in general, or is it more specific; does it create a home object for CustomerBean and a home object for ProductBean?
Yes. But not within the no-arg constructor - It is accessible thru ejbContext in setEntityContext() and other methods.
According to the spec, the bean instance should assume that a home object is available in the setEntityContext() and other methods (except constructor). It is upto to the container implementation to have: 1. One EJBHome object for each instance of a bean from the same home. 2. One EJBHome object for all the instance of a bean from the same home.
But, there cannot be one global home object for all the beans in an enterprise application. Will it make sense? No. Because a home is a group of bean instances that belong to a particular family, which means that a home object will find or create a bean of a particular type only.