  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | ServiceLocator end InitialContext | ServiceLocator end InitialContext 2004-07-14 - By Giovani Salvador
Back Hi all...
In the ServiceLocator pattern i build a IntialContext in its private contructor and use this IntialContext to lookup "services". I have seen in the examples and im my own use of this pattern that it?s built an IntialContext without parameter. What about if i have to "attach" to another context? If i have to do this i have to pass a Properties object in the InitialContext?s constructor, ok? But my ServiceLocator class has only one private variable instance of an InitialContext and this initialContext, as i said before, is built in the ServiceLocator?s private contructor and built withou parameter of context.
Example
....
public class ServiceLocator { private static ServiceLocator me; InitialContext context = null;
private ServiceLocator() throws ServiceLocatorException { try { context = new InitialContext(); } catch(NamingException ne) { throw new ServiceLocatorException(...); } }
// Returns the instance of ServiceLocator class public static ServiceLocator getInstance() throws ServiceLocatorException { if (me == null) { me = new ServiceLocator(); } return me;
}
...
What do i have to do if i want to use another context? How to achieve this in the ServiceLocator Pattern? Remember this patterns is suggested to be a singleton!!!!!!!!
Thanks
Giovani Salvador
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |