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

Similar Messages

  • Business Delegate and Session Facade Pattern

    Hi!
    The only way to use the Session Facade Pattern, is if I use EJB for Persistence.
    Is valid to do this?:
    I use Ejb for simple update, insert querys. From my business delegate I call the Session Facade Layer, and from this I invoque Entyties for persistence.
    But if I have complex querys, is correct to make PL SQL Procedures and do the following:
    From my business delegate I call to the Dao layer, and from this via JDBC I call the Procedure.
    Please explain me the best form to do this, having complex querys for reporting and simple querys for inserts/update.
    Is valid to combine the use of CMP (for simple persistence cases), BMP (for complex persistence cases), and JDBC for complex select querys with multiple result rows.
    Thanks!!

    It depends on your design goals. One of the forces driving the use of patterns is the desire to tier an application and abstract the internals of each tier away from the other tiers. One (normal) benefit of this methodology is that the application should become more portable. Now, if you are using PL/SQL, BMP and CMP, you are mixing and matching portable versus proprietary. This is okay. But you should abstract away whether you are using PL/SQL, BMP or CMP from the business layer (or domain model). Ideally, you could completely swap database technologies (say from relational to object) and only have to re-write your integration tier (your DAO's).
    Session facade is simply a glorified Facade pattern. It abstracts the lower-level details of what you are persisting and instead forces you to think in terms of objects. You can use a facade without even remotely touching EJB's. It just so happens that, historically, EJB containers made a mess out of scalability when it came to entity beans. The "session" facade refers to a facade pattern implemented in session beans (that have fewer scalability problems) communicating with the entity beans which do have scalability problems.
    So... to make a long story short, use whatever persistence mechanism you desire. Remember that you should be able to completely switch your persistent store from one type or another and simply re-write your DAO's (or CMP deployment descriptors). Using a facade pattern can help towards this end, but don't make it a straightjacket.
    - Saish
    "My karma ran over your dogma." - Anon

  • Business delegate and Session facade design patterns

    Does any one tell me, what is the difference between business delegate and session facade design patterns.

    1. Session Facade decouples client code from Entity beans introducing session bean as a middle layer while Business Delegate decouples client code from EJB layer ( Session beans).
    2. SF reduces network overhead while BD reduces maintenance overhead.
    3. In SF any change in Session bean would make client code change.
    While in DB client is totally separate from Session bean because BD layer insulate client from Session beans(EJB layer).
    3. In only SF scenario, Client coder has to know about EJB programming but BD pattern no EJB specialization needed.
    4.SF emphasizes on separation of Verb, Noun scenario while BD emphasizes on separation of client(presentable) and EJB layer.
    Anybody pls suggest more differences ?

  • Business Delegate and Session Facade usage.

    Hi guys.
    I am new to JavaEE and I recently learnt the Business Delegate and Session Facade design patterns. The tutorials from Oracle did gave me a basic idea of what they are and why they are used, but the example didn't really answer all my questions. So I decided to use a real life scenario here and put my question in to it. Any help is appreciated.
    Assume I want to create a search employee page for my company, the employees are categorized by his or her department and the province he or she is in. I have in the database a look up table for department and province. (as shown in the image below)
    http://oi46.tinypic.com/idvpsl.jpg
    So I create three JPA entities, one for each table. Now I am stuck with what is the proper way to design the session facade design pattern. I know that I will need the to access all three entities in my page. (to get the drop down list for Provinces and Departments, and to retrieve list of Employees based on the selection) So should I create a Stateless Session Bean as session facade to access all three JPA Entities or should I create three separate Stateless Session Bean to manage one Entity each?
    I came up three component diagram in the below picture.
    The first one has one Stateless Session Bean as session facade and manages all three Entities.
    The second one has a session facade to manage the relationship between business objects such as ProvinceManagerEJB and DepartmentManagerEJB which will manage the corresponding Entities.
    The last one has three Stateless Session Beans that will manage one Entity each, all three Stateless Session Beans can be looked up via the Business Delegate pattern.
    http://oi46.tinypic.com/10pqets.jpg
    Please let me know if any one of them is the proper way to use business delegate and session facade. or none of them is correct. (which I assume might happen)
    Again, thank you so much for your help.
    Cheers
    Edited by: 992005 on 05-Mar-2013 18:15
    Edited by: 992005 on 05-Mar-2013 18:17

    Well I can't access any of your diagrams from here so can't comment on them. For dividing the functionality into separate classes, think about
    1.) Quantity - Are there many enough service calls to require splitting up or will one application service class be enough? The size of the system is important here.
    2.) Are you duplicating logic in the services? e.g save person, delete person in one service and save department, delete department in another e.t.c is better factored into one service with save entity, delete entity calls because the JPA entity manager doesn't know about the type anyway and it's easier to apply common logic (e.g logging auditing) around the calls.
    3.) Will each service makes sense on it's own or do you always need the other functionality to completely describe the service? Here it is important not think about entities but about the business use cases. Process1Service is better than Entity1Service, Entity2Service ... EntitynService.Think granule of reuse = granule of release. Only split out individually reusable services. A good way to understand granules of reuse in your system is to think about (or start by writing) test cases for the functionality. Testable code is reusable code.
    4.) Will the services change together? At class level you would look at common closure principle (classes that change together should be packaged together). You can apply the closure to the methods as well. Make it easy for future developers to recognize dependent functionality by packaging it together.
    These are just general because in enterprise development requirements are king. You can chose to follow or discard any of these rules depending on your requirements as long you understand the impact of each decision.

  • Diferences between Business Delegate and Session Facade

    Hi, I've been programming with java for a long time now, but recently decided to formally studing the J2EE patterns. By now I have the intuition of many of them but in paper looks a little confusing. Let me ask you what is a clear diference between Business Delegate and Session Facade.
    For me, exposing interfaces, hiding implementations and masking the complex interactions in the back are common factors in these patterns, could you please help me to identify diferences?

    There are more subtle differences, but the basic gyst is that the Business Delegate is used on the client/presentation tier. The Session Facade is used on the server/service tier. The Business Delegate typically performs a lookup of the SessionFacade which in turn fronts a service method (EJB or otherwise). The Business Delegate pattern is typically associated with J2EE remoting and its shortcomings.
    - Saish

  • Session Facade Pattern without EJB

    All of the session facade pattern examples that I can find are heavily emphasized on EJB. I am planning on implementing a system without EJB's, and am interested in the advantages of using the Session Facade pattern.
    Are there any good examples of using the Facade pattern outside of EJB to build a java server system? If there aren't, is there a better way to implement this type of strategy in a non-EJB system?

    What is the best way to allow the client to
    interact
    with Entity objects, without exposing them. ShouldI
    implement Value objects that are easily serialized
    for transfer across the network?
    If you are not using EJB or a distributed
    architecture, you do not need DTO's or VO's. They
    are an odious construct used to obviate the
    shortcomings of remote method calls over anetwork.
    I strongly disagree.
    They are an obvious and easy model used when the
    following characteristics of a system exist.
    - Different layers.
    - Related data items that are moved throughout the
    layers.
    - Different usage of the related data items by
    different layers.
    Yes, I agree. Note the qualification 'if you are not using a distributed architecture'.
    None of that has anything to do with remote method
    calls over a network. Point of fact the first time I
    used them was in a stand alone application with no
    network traffic except that needed by the database
    driver itself.
    Simply create your domain model objects as POJO's
    s (plain ole Java objects). Persist and retrieve
    your objects via DAO's (data access objects).Your
    service layer (facade) will sit on top of thedomain
    model, encapsulating method calls into logicalunits
    of work.
    And how exactly do you move the customer
    name/customer address from the DAO to the GUI level?I am assuming the dedicated remoting product the OP specifid, Hessian, will handle moving between the tiers, or at least between the controller/view and the business tier.
    - Saish

  • Facade and Session Facade

    All,
    Well this is the closet forum i could get to post my question so please excuse me if it is in wrong place.
    Can anyone mention the types of facade design pattern available ? Also what is the diff between Facade and Session Facade ?
    PS : My application is getting developed in ADF :)
    thnks

    in the line of fire wrote:
    All,
    Well this is the closet forum i could get to post my question so please excuse me if it is in wrong place.
    Can anyone mention the types of facade design pattern available ? Also what is the diff between Facade and Session Facade ?This is no really ADF specific. You may wish to consult both the "Gang of Four" book along with Fowler's "Patterns of Enterprise Architecture."
    A quick answer: the Facade pattern defines an object ( or method on an object) that executes a workflow involving other objects that you wish to hide from client applications or objects.
    A session facade is the same idea applied to JEE session beans, where a single call to a session bean may include interacting with other beans, entities, databases, etc.
    Hope that helps,
    Chad
    >
    PS : My application is getting developed in ADF :)
    thnks

  • Business Delegate and Session Facade

    Business Delegate as well as Session Facade are used to reduce coupling between presentation-tier clients and business services.
    Could someone provide the key differences between these two patterns.
    And one more, is Session Facade applicable(can be implemented) only to Enterprise Java Beans? Or even a POJO can be a Session Facade
    Thanks in Advance

    Business Delegate as well as Session Facade are used
    to reduce coupling between presentation-tier clients
    and business services.
    Yes. And also in EJB to overcome some of the deficiencies in distributed architectures.
    Could someone provide the key differences between
    these two patterns.
    Business Delegate is used by a client whereas the Session Facade is used to abstract a business service.
    And one more, is Session Facade applicable(can be
    implemented) only to Enterprise Java Beans? Or even a
    POJO can be a Session Facade
    Yes. Think of a session facade as your 'easy' or 'high-level' API. Your actual business tier may have its own 'low-level' API that callers should not have to interact with or understand.
    Thanks in AdvanceYou're welcome.
    - Saish

  • Value-list handler, value-list iterator and session-facade strategy

    Hello all,
    Further to an earlier post, I rewrote my post trying to me more accurate in my question.
    Here is my problem:
    I am trying to implement the value-list handler design pattern using the session facade strategy. In the pattern as it is described here
    (http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html) the client accesses the value-list handler AND the iterator directly.
    As I chose the session-facade strategy having my value-list handler as a stateful session ejb, I don't know how the client is going to access the iterator. I see only one option: Having the client access the iterator through the ejb value-list handler. This requires adding new methods to the ejb.
    Is this the correct way of doing it? Is there another way of doing this?
    Thanks in advance,
    Julien Martin.

    u can use project list handler as ur session facade.
    regarding ur second question ..session facade and value list handler session bean which is also a session facade( but there is difference between first and second) so u can use session facade and value listhandler

  • DAO and session Facade

    Hi
    I came across an design pattern where they call the DAO from Session facade. The purpose of session facade is to minimise the number of network calls. Even though there are no network calls involved why do they go for session facade to call the DAO. Wont a DAOFActory will help them doin this.
    Even if the requirement is to block the presentation layer of all the backend operations, we could have had any other , why session facade was used i could nt understand

    You might even discover that entity beans can get created even before you use them.
    Your application server creates "pools" of bean instances that it can use when it needs to. It is part of this role, and is done in order to optimize performances.
    You cannot force them to be garbage collected. Even if you stop referencing them, the app server will.
    When your create references to a bean, it (usually) won't create an instance. It will take an existing one, and load data into it, using ejbCreate or ejbActivate.
    Hope this helps.
    /Stephane

  • 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

  • JDev 1013 BUG? EJB, CMR, DTO and session facade.

    I've created two CMP Entity EJB's, CourseEJB and PupilEJB, and defined a M:N relationship between them. A course has many pupils and vice versa. Each bean has only two attributes, id (Long, part of PK) and name (String) for simplicity.
    1. Generated DTO's for the two beans won't compile
    I get error on:
    public void addcourseEJBLocalDTO(courseEJBLocalDTO courseEJBLocalDTO)
    coursesDTO.add(courseEJBLocalDTO);
    courseEJBLocalDTO.setPupilsDTO(this);
    and:
    public void addPupilEJBLocalDTO(PupilEJBLocalDTO pupilEJBLocalDTO)
    pupilsDTO.add(pupilEJBLocalDTO);
    pupilEJBLocalDTO.setCoursesDTO(this);
    because JDev has created definitions of the setCoursesDTO function like this:
    public void setCoursesDTO(Collection<courseEJBLocalDTO> coursesDTO)
    this.coursesDTO = coursesDTO;
    and ditto for the setPupilsDTO method, taking a Collection as argument too.
    I can fix this code manually, but next step, generating a session Facade with added methods for handling the entity beans isn't exactly any better...
    One M:N relation is pretty basic, am I doing something wrong here?
    Message was edited by:
    jonmarti

    Forgot to add, running on 1013

  • Flex and ColdFusion and session facade?

    I want to deploy a flex application on an existing ColdFusion
    server. This server is already in production and uses a root
    Application.cfc to set session variables as well as authenticate
    the user to AD with getAuthUser. When I deploy my flex application,
    it fails because of the OnRequestStart cfcomponent within
    Application.cfc. I am wondering if this would be proper use of
    session facade? How do I best encapsulate session variables from
    the root Application.cfc within my new flex application? Basically
    I will need to follow the same authentication and cfset session
    guidelines that all of my other CF applications use, and my flex
    app needs to have theses session variables available to it, but I
    am not sure the best approach. Any insight is welcome.

    Did you enable session management in the Application.cfc or
    Application.cfm?

  • Depenency Injection and Session Facade in WebDynpro DCs

    Hi all,
    for the sake of decoupeling the business logic and persistence from the view i introduced a session facade.
    I wonder how to acess the session facade bean from my webdynpro?
    am i right that dependency injection inside a wd dc is not working?
    does jndi work in a wd dc?
    regards,
    christian

    Hi Christian,
    First - welcome to SDN!
    To your questions:
    1) JNDI access to EJBs works from any client application, which means also from WD apps. <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/45/e692b2cfaa5591e10000000a1553f7/frameset.htm">Here</a> you can find more information on that.
    2) Dependency injection does not work within WD.
    3) I would suggest you to consider the <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/45/f7f744aea471fae10000000a1553f6/frameset.htm">EJB Model Importer</a> which is the easiest and recommended way for using session beans inside WD components. This is a new feature coming with <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/ce">SAP NW CE</a> aiming to increase developers productivity by reducing the need for manually written code for accessing and calling the EJB business methods.
    Please do not hesitate to come back should you have any further questions.
    Best regards,
    Vladimir
    Message was edited by:
            Vladimir Pavlov

  • Oracle Service Bus and Enterprise Integration Pattern

    Hey all,
    Do you know where I can found the list of eip supported by OSB ?
    Thanks,
    Yves

    Most of the stateless integration patterns can be implemented using OSB. Product is designed as stateless and I think it performs well if it is used for this purpose . So patterns like content based routing are very easily supported. You might need java code to make it support stateful patterns [ Example :Aggregator, Resequencer etc]. It could become quite messy and not recommended.

Maybe you are looking for

  • AUDIODG.EXE hogging 80-100% of CPU and sound not working in Vista . . .

    I posted this on a Microsoft Answers Forum but none of the techs or people reading have been able to help so far.  I'm dying to get to the bottom of this: Here is my computer: MSI K8N Neo4 Platinum AMD Athlon 64 3000+ 2GB RAM XFX GEFORCE 6600 GT 128M

  • Error while calling Computation process

    Hello Every Body I have a form for inserting informations . after the click on my submit button I redirect to another page on this page I have a textbox item called "P2_CODE_USER" In my first page i added a computation process that set in P2_CODE_USE

  • Issue with process order confirmation

    Hi,   I m doing the testing of SAP EHP4 To EHP6 up-gradation. I tried to confirm process order XXXXXX with T-code COR6N. In this process order there 2 phase for 2 activity. Now when I entered the order in COR6N I click on enter its automatically take

  • Java.libary.path  How to use it ?

    I wanted to access the windows registry from my java program. so i downloaded a jni package and set the classpath to it. i now get java.lang.Unsatisfiedlinkerror.no ICE_JNIRegistry in java.library.path ? How to rectify this ?

  • Table Sequence number

    Hi All, I have a scenario which goes like this: We have a common table(Table1) in our DB which maintains the sequence numbers(we are not using oracle supplied db sequence). For every transaction we are using the current sequence number from the table