Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

1 or 2 homes - Part 2

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Thambi Rajah
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Unfortunately, I cannot pass the SessionContext object as reference to every rule.
As is, how many home objects are created in this situation?
Thanks in advance
Thambi
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I meant that you could pass the home or the EJBObject reference that you get from SessionContext to rule1.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As this is a stateless session bean, what's wrong with this:
reff1.runRule(rule2)?
 
Thambi Rajah
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Are you here to take over the surface world? Because this tiny ad will stop you!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic