Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A Factory Pattern for returning the instance of EJBRemote Object from EJBHome.create() Method ??  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Instead of Normal calling of EJBs from Servlets through BusinessDelegates and ServiceLocator to pass the JNDI name for getting the EJBHome and then calling the Business Methods on the Remote Object ,

How feasable is it to have a Factory class in between which will do all these operations .




The coding of PredefinedReportFactory is as follows :




Thanks in advance .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you use a Singleton here? And does it not make sense to cache EJBHome references rather than look them up every time?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul , whats wrong here ??

As those (JNDI Names) are static Data i am using singleton class .
I did not post the Whole code , the jndi names are fetched through caching only .

This is the caching code of the ServiceLocator :
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public synchronized PredefinedReportSBSLRemote getPredefinedReport() throws Exception
{

prHome= (PredefinedReportSBSLRemoteHome) PortableRemoteObject.narrow(obj,PredefinedReportSBSLRemoteHome.class);
}

return prHome.create();
}



This will perform the narrowing step and call create every time to call getPredefinedReport(). Why do this?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!