I have the following situation. RuleBean is a stateless session bean which calls Rule classes such as Rule1, Rule2..... etc where Rule1 and Rule2 are Java classes having only one method, execute( ). A client gets a home reference of RuleHome, home1, through a JNDI lookup. Using home1, the client gets a remote reference, rref1 and invokes runRule( ) method in RuleBean. The method runRule( ) gets a refernce (rule1) to Rule1 class and invokes the rule1.execute( ) method:
In execute ( ) method of Rule1, it needs to run another rule, Rule2. It needs another JNDI lookup for RuleHome, home2, and eventually invokes the rule2.execute( ) method.
My Question is: Is there any way we can get rref2 from a single RuleHome reference, home1? OR should we always need two RuleHome references, home1 and home2, in this situation? Thanks in advance, Thambi
Stateless session beans have access to SessionContext methods that can retrieve references to their own homes or EJBObjects. The bean could pass a reference to one of these to rule1, which could use that get at rule2.
Thanks to Anthony Watson for your suggestion. When I read the HFEJB book (pg. 91), I had the impression that the Container will always create a single instance of RuleHome object. However, when Rule1 class invokes the execute( ) method of Rule2, I believe that the Container will create two RuleHome instances rather than one. Would anybody confirm exactly how many RuleHome objects are created in this situation? Thanks in advance, Thambi