SERVICE LOCATOR ?? Is it really an interesting Design pattern??

Hi everybody,
i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
It is said that by making use of a Service Locator we can :
- hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
- multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
But i would like to understand at which side should that service locator object reside??!!??
If it is at server side then the clients need well an initial context in order to make a lookup on that object.
Conclusion :
the service locator doesn't hide the complexities of initial context!!
Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
If it is at client side, each client needs his own services locator object
Conclusion :
multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
There is certainly something that i don't understand so help me please!! Thanks.

Hi Yves,
But i would like to understand at which side should
that service locator object reside??!!??
If it is at client side, each client needs his own
services locator object
Conclusion :
multiple client don't reuse the same service locator.
What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
a singleton. Since it is possible that there could be multiple
class loaders/JVMs on the client side, and therefore, multiple
instances of the "singleton" service locator. This is typical
in a distributed environment (e.g. servlets/JSPs in a web-tier
cluster using service locator). Thus service locator is not
a truly "distributed singleton" object. But, the empahsis
is to design the service locator such that it does not hold
any state that needs to be replicated across multiple
instances across different JVMs as mentioned. Thus, there
is no need for multiple clients to use the "same" service locator,
but still the benefits of implementing this pattern is realized.
By making it a singleton, and keeping it from holding state
that needs to be replicated, we realize the benefits of this pattern.
You may also want to visit the J2EE Pattern interest list
and see these relevant discussions :
Topic: Service Locator and passivation
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
Topic: Caching EJBHome interfaces
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
Topic: Using Service Locator for Data Source caching
http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
hope this helps,
thanks,
-deepak

Similar Messages

  • I am just starting out in graphic design and I wanted to know how to get more involved with either adobe and or graphic design? I am really very interested in working with adobe and graphic design more and becoming more involved with both!!

    I am just starting out in graphic design and I wanted to know how to get more involved with either adobe and or graphic design? I am really very interested in working with adobe and graphic design more and becoming more involved with both!!

    I have now recently downloaded 10.0.2 which is confusing in itself, as, as far as I can ascertain that is actually version 11, but I'm not even sure about that.
    Version 10.0.2 is the newest version and the successor to GarageBand '11 (version 6.0.5).
    The '11 is referring to the iLife '11 suit of multimedia application - the older GarageBand was a part of this bundle.
    Have a look at Edgar's graphical enhanced manuals, the explain very detailed how things work and why. You can buy them as iBooks from the iBook store or directly from the page:
    http://DingDingMusic.com/Manuals/

  • Service Locator and session facade pattern

    What are differences between Service Locator and session facade pattern?
    For me it seems one and the same.
    Please explain me in detail. Expecting kind help.
    Thanks,
    Rahul
    Edited by: rahulb1 on Feb 26, 2008 5:07 PM

    rdoekes wrote:
    The ServiceLocator Pattern is a singleton which hold a map of used DataSources. The idea is that you perform a lookup once and use the cache afterwards. The session facade is just one DataSource lookup.huh? Those J2EE patterns are not really reduced to datasources and the SessionFacade has actually nothing to do with datasources.
    Session Facade
    It has Facade in it and a Facade is usually used to give a simple entrypoint by providing a standartized interface. The same is now with the Session Facade. You have a Session bean that represents a high-level business component that interacts and calls lower-level business components.
    Imagine having client a accessing 5 business objects with the remote calls, which is not an efficient way (network latency) or accessing the SessionFace and the session face is doing all the work through local access.
    Service Locator
    As J2EE components are using JDNI to lookup for ejb interfaces,DataSources, JMS components, connections etc. isntead of writing all the lookup in many code piecess across the project, you write a service locator that gives you a centralized place to handle the lookup's. It's easier to maintain and to control such a setup.
    As you can see there's quite a big difference ;-)
    cya,
    Nail

  • Location manager design pattern?

    What is the best design pattern for using the location manager with intermittent but time-sensitive use? My app records location each time the user creates a photo, creates a note, records audio, etc and stores it using CoreData. The problem is the location manager has to spin for a bit to get the best reading, and in that time the user could easily have navigated the UI to delete the object they've created and create a new one. In that case I'd want to interrupt any location services active for the deleted object.
    Is a singleton the best pattern, keeping the active objects in an array and using @synchronize(object)...but running each in a different thread?
    Or assigning the location manager as a transient property of the object and calling stopUpdatingLocation if it gets deleted?
    Any thoughts? TIA...

    I created a singleton for this - seems to work quite well

  • Service location

    Hi,
    I am a bit confused when I came across a word service location.Is t what we call functional location(related toISU connection object) ? If not so how is it related to premise.
    Regards,
    Bhanu

    Hello Els,
    I suppose you're talking about a CRM - IS/U integration. If you install the Utilities plug-in in the CRM system the webclient will have enhanced views and processes especially designed for the Utilities industry.
    Processes like the way the WebClient works, next to the indentification of a business partner, which is not obligatory in the WebClient IS/U scenario, you can confirm on installed base components. (ibase components like installation, POD, ...)
    Furthermore there are some views, if you install the plug-in, to maintain this typical IS/U technical data.
    Hope this helps,
    Regards,
    Joost

  • Service Locator implementaion for PetStore

    PetStore use two service locator class, one for the web
    http://java.sun.com/blueprints/code/jps131/src/com/sun/j2ee/blueprints/servicelocator/web/ServiceLocator.java.html
    and another one for ejb
    http://java.sun.com/blueprints/code/jps131/src/com/sun/j2ee/blueprints/servicelocator/ejb/ServiceLocator.java.html
    as explanied on this topic
    http://java.sun.com/blueprints/patterns/ServiceLocator.html
    I wonder why they have made the Web-tier class is a singleton, and caches the objects it looks up, while the EJB-tier class is not a singleton, and does not cache?
    Does any body have a clue
    thanks

    Hi,
    This question was answered on the patterns interest list recently. The response is at
    http://swjscmail1.java.sun.com/cgi-bin/wa?A2=ind0301&L=j2eepatterns-interest&P=R5864
    hope that helps,
    Sean

  • Service locator vs singleton cLass

    I have doubt regarding these two. How they are related to each other.
    Thanks in advance

    A solution can use more than one pattern, most designs will uses several patterns at once. Some patterns like Service Locator are themselves constructed from several patterns. Singleton, Facade and factory method are all present in the Service Locator pattern.
    To elaborate on crackers comment above. A singleton is a pattern for ensuring that only a single instance of a class exists. A class that offers the Service Locator functionality can also use the singleton to ensure that it exists only once, and therefore a single instance deals with all Service Requests.

  • If we use the $495 DPS service we don't really need the cloud correct?

    If we use the $495 DPS service we don't really need the cloud, correct?

    The 495 covers a pro account which allows for subscription apps as well as single edition. If all you’re interested in is single edition then Creative Cloud is the way to go.
    Bob

  • Location Aplliance will not synch network design

    2710 Location appliance running 4.0.33.0, WCS running 4.2.130.
    2 Campus Network Designs each with multiple buildings and floors. One can be assigned to the location server and synchroization works perfectly. The second network design shows unassigned. If I assign it to the location appliance and then sychronize network designs it reverts to unassigned.
    Has anyone run into this issue and been able to resolve it?

    1) Connect to LOCAPP CLI
    2) Stop the LOC Service(/etc/init.d/locserverd stop)
    3) Take the backup of Loation DB which can be found at /opt/locserver/db/linux/server-eng.db
    i.e. copy the server-eng.db to some other directory e.g. /home
    4) Delete the DB by issuing the command
    rm -f /opt/locserver/db/linux/server-eng.db
    5) Start the LOC service (/etc/init.d/locserverd start)
    6) Perform the sync. through WCS
    Hope this will help you...

  • How can i see when someone has accessed my call/text log. (This is possible on google) I have been informed that someone has accessed my activity log and is giving my information to a third party. I believe it is a service tech, but I am not interested in

    How can i see when someone has accessed my call/text log. (This is possible on google/gmail) I have been informed that someone has accessed my activity log and is giving my information to a third party. I believe it is a service tech, but I am not interested in persuing that further. I just need to see when my account has been accessed if possible.

    Hi lynniewigs,
    This is a common concern among Android and I-phone user, and one of the drawbacks to using a smart phone.  We lose so much privacy. Our phones become cameras into our homes for us to be spied on.
    I don't know what type of phone you have, if it is even a smart phone, but here is an example of an application that you can use to determine which applications are accessing your information and sending it out. 
    Permission Scanner - Android Apps on Google Play
    Google just recently revamp their permissions geared to hide invasive applications that spy and send out your information without your knowledge.  Report says be aware of what your Android app does - CNET
    Please continue to be mindful of the apps you download and the permissions you give. 

  • Using service Locator pattern to dynamically access remote EJBs

    Hi All,
    Please help to guide me how I can use a service locator to retrieve a remote object (residing on another application but on same domain) .
    I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO)). Each EJB implementation implements its own remote/local interface that extends this global POJO interface.
    I have two J2ee-Applications on same domain. J2EE-Application 1 has an EJB module (EJB Module 1) that intends to access an EJB Module (EJB Module 2) in J2EE-Application 2. Following observations:
    1. Dependency Injection fails if (include the EJB Module 2 jar in J2EE-Application 1). Reason App Server complains the EJB has been deployed (Deployment fails)
    2. Dependency Injection works if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1).Positive Observation (Deployment success and DI also success)
    3.Using Service Locator to retrieve the remote object if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1). Negative and Positive Observation.
    Positive Observation: Using dependency injection I can still retrieve the Remote Object
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Negative Observation:
    The Service Locator lookup to this same remote object with Successful Dependency Injection fails (An Ejb in a different application).
    Can't retrieve the Remote Object with Service Locator. Message from Server:.
    NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
    Thanks in advance

    "I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO))"
    If you're calling ejbs from other ejbs or servlets, the same could probably be acomplished by using dependency injection (@EJB) in a number of instance variables typed with different remote/local interfaces or even with different beanName attributes (for when more than one bean implements the same managed interface in the same app - not sure how it works outside the same jee app...) , and dinamically selecting one of them; or encapsulating those injected variables into a stateless ejb as your service locator to make them accessible from POJOs too (which, due to concurrent acess, wouldn't work for statefull ejbs references...).
    Anyway, using the jndi lookup service locator pattern seems ok in this case.
    What doesn't seem ok, given the nature of the error for the negative observation - jndi context initialization - is that
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Can you check your code and reconfirm that you're using the same context initialization code for both the positive and negative observations ?

  • How to give Service locator in flash builder 4.5

    hi friends,
    In flex 3.0 we are giving service locator like this
    <?xml version="1.0" encoding="utf-8"?>
    <cairngorm:ServiceLocator xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:cairngorm="com.adobe.cairngorm.business.*">
    </cairngorm:ServiceLocator>
    How to give in flash builder 4.5 i tried in same way it is not recognizing ServiceLocator.
    How to do in 4.5

    Ya i tried by keeping <fx:Declarations> part but still it is throwing error,
    In flex3 we are making a component ex: <mx:canvas> and changeing that component to
    <cairngorm:ServiceLocator xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:cairngorm="com.adobe.cairngorm.business.*">
    </cairngorm:ServiceLocator>
    if any one used 4.5 with cairngorm let me know
    thanks

  • Can we implement "Service Locator" in Stateless Session Bean??

    Hi,
    My enterprise application is using Stateless Session Bean. To increase the performace , I think of implementing "service Locator" pattern so as to cache the EJBHome objects in order to avoid looking up Home object every time. I want to know whether this will work out in case of stateless session bean??
    Thanks for ur help.

    Hi,
    The purpose of service locator is to abstract the lookup of the server side services like ejb and DSNs. It should be a normal java class but as such there is no such restriction. You can have a look at the service locator patter at the j2ee blue prints.
    /Ashwani

  • Service Locator and Performance?

    We currently have an application with numerious EJBs. Obviously, this in turn involves
    numerous JNDI look ups for these EJBs. Both the client (a web application) and
    the EJBs run within the same JVM, however not as part of a singe EAR application
    (the EJBs are deployed as standalone application modules). We do not have any
    Service Locator (J2EE pattern) implemented. My question is, given this scenario,
    will there be a performance enhancement if a Service locator is implemented to
    cache JNDI look-ups? If so, Will this come into play if we deploy the app as an
    EAR?
    Thanks,
    Krish

    There are a lot of tools out there.
    Here's what I've used:
    On Windows/Linux, OptimizeIt and Jprobe are pretty common.
    If you're using jrockit, try JRA
    http://dev2dev.com/products/wljrockit81/analyzer.jsp
    On HP-UX, I like HP's JMeter:
    http://www.hpjmeter.com
    -- Rob
    Krish wrote:
    Is there a Profiling tool that I could use to identify where most of the time is
    being spent?
    Thx,
    Rob Woollen <[email protected]> wrote:
    If your end goal is to improve performance, then I'd strongly encourage
    you to spend some time tracking down where time is currently being spent.
    In my experience, creating InitialContext objects can be expensive.
    Lookups generally aren't that bad, but it's a reasonable approach to
    cache both.
    Basically, if you're spending a lot of time in JNDI lookups, then I'd
    suggest doing the Service Locator pattern. If your time is being mainly
    spent elsewhere, attack that first.
    -- Rob
    Krish wrote:
    We currently have an application with numerious EJBs. Obviously, thisin turn involves
    numerous JNDI look ups for these EJBs. Both the client (a web application)and
    the EJBs run within the same JVM, however not as part of a singe EARapplication
    (the EJBs are deployed as standalone application modules). We do nothave any
    Service Locator (J2EE pattern) implemented. My question is, given thisscenario,
    will there be a performance enhancement if a Service locator is implementedto
    cache JNDI look-ups? If so, Will this come into play if we deploy theapp as an
    EAR?
    Thanks,
    Krish

  • Using Service Locator in Struts app without ant eejb components

    Hi
    We are developing a Struts application witjout any EJB components.
    But we may go for EJB in future.
    Keeping that in mind we want to introduce a service locator between the action class and the business logic. So it may be easier to acomodate in future.
    But how do i do that ? Can anyone help me in this?
    Since all the Service locator example which i have seen is implemented using ejb
    Please do help me in this
    Thanks
    Ottran

    Controller (Action class) gets reference to Business Delegate (BD) and calls a particular business method.
    The BD gets reference to Service Locator (from JNDI tree) to access a business service. The business sevice can be implemented using EJB, POJO, Web Service, legacy app, etc.
    A UML diagram is available at
    http://www.softwareleadership.org/docs/J2EEDesignPatterns.html
    Click on Business Delegate to view diagram with Service Locator.

Maybe you are looking for

  • OUTPUT DETERMINATION FOR ACCOUNT GROUPS

    dEAR experts, Kindly write to me where to maintain output determination for customer account groups. Kindly help. Kind Regards biju

  • Index. Strange thing happens

    Oracle Version: 8.0.5.0.0 on windows NT 4.0 We have been having problem with some tables, access method. For Example, TBPLL. The Primary Key is (PLL_LOJ_NUMERO, PLL_PCE_CODIGO). I'm gonna show two queries with the SAME WHERE clause, and the explain p

  • Load file during runtime

    Is it possible to open a local file at runtime? If so, how? Ex: load "C:\myAnimation.swf" and display it. Thanks

  • Touchstart, Touchmove & Touchend Help Please

    Hi There. I have been working on on a Drag Touch start, move and end project. What I am trying to do is move / drag an item on an ipad so that when it reaches a certain area on the stage it creates an event- for example. Hide or show an object. I hav

  • IDS_ERR_EAI_SA_NO_USERKEY

    Hi pals, I'm facing one problem with my Integration Object for a web service I have the next xml      <ListOfSthnewcontact>           <Contact>                <FirstName>Mario</FirstName>                <IntegrationId>1-A</IntegrationId>