EJB 3.x business delegate & service locater

Hi all
are business delegate & service locater patterns still relevant when considering EJB 3.x? Why or why not?
Does dependency inversion replaces service locater? was there dependency inversion in EJB 2.x??
Thx a lot

Hello,
Business Delegate is still relevant while using EJB 3.0
Business Delegate reduces coupling between presentation-tier clients and business services, that does not change with EJB 3.0.
However, Service Locator can be avoided by the Dependency injection provided by java EE5.
But, remember, Dependency injection works only for object managed by the container, so, Service locator can yet be useful in ejb 3.0.
Regards,
Sebastien Degardin

Similar Messages

  • Busines delegate / service locator / session facade

    i dont understand how to combine all these patterns into one sequence diagram or class diagram. does anyone have a sample for this? thanks a tonne.

    i dont understand how to combine all these patterns
    into one sequence diagram or class diagram. does
    anyone have a sample for this? thanks a tonne.they are invloved with more than just a class. usually they work like this:
    client ->bd[locator] ->sessionFacade[locator]->bzObjs/ejbs
    and if there is a messageFacade, it goes in between bd and sessionFacade.
    hope this helps.

  • Business Delegate and Service Locator

    Hi all,
    I read the Business Delegate Pattern
    and my question is about how many Business Delegate
    I must write:
    a) one for every Session Beans ?
    (in a Session Facade Pattern)
    b) one for all Session Beans ?
    Is it right that I must have a single Business Delegate
    and different Service Locators if I need to
    call the same EJBs deployed inside different Application Servers ?
    Many thanks in advance,
    Moreno

    Please explaine your Question in more Detail?

  • 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 ?

  • Service Locator EJB Component - Clustering -oracle9iAS

    hi all,
    Anyone has idea on how to implement the service locator (EJBHomeCache) component to make it cluster aware. I am using the oracle9iAS server.
    thanks,
    Viral

    Anyone has idea on how to implement the service
    locator (EJBHomeCache) component to make it cluster
    aware. I am using the oracle9iAS server.What do you mean when you refer to cluster awareness?

  • === SESSION FACADE v/s BUSINESS DELEGATE ===

    Hi
    Can anyone help me with my design here - I am not sure whether to use a Session Facade or a Business Delegate in the following scenario:
    [Our application is pure J2EE and does not use EJBs]
    PRESENTATION-TIER
    I have a Command and Control strategy employed in my presentation tier where requests are intercepted by a controller and processed by helpers delegating to appropriate commands and dispatch appropriate responses.
    PRESENTATION-TIER - COMMANDS
    The Commands will invoke appropriate Business Methods in the business tier to retrieve data (mostly).
    BUSINESS-TIER
    Now - most of my business methods use the DAO pattern to retrieve data and are effectively dealing with Data Beans (Value Object beans) - passing them back to commands.
    I can clearly see the use of a generic Interface at the Business tier - i.e., rather than expose the Buiness Methods direcly leading to increased coupling between presentation and business tiers.
    BUT THE CONFUSING PART IS - DO I USE A SESSION FACADE OR A BUSINESS DELEGATE TO INTERFACE WITH MY COMMANDS??? What is the difference? I have looked at Sun's J2EE blueprint and cant make out the clear cut difference between the two.
    Can anyone help?
    thanks
    Aswin

    I agree with you, Business delegate and Session facade are quite alike.
    I believe that you could use the Business delegate pattern as a facade. Possibly, you could argue that the Business delegate is an extension of the Session facade pattern. However, I think that SUN thinks that a Business delegate should be a singleton while a Session facade is a session EJB. My firm belief is that you could create a business delegate that is a session EJB instead.
    But, you could also use both pattern as some one else suggested.
    In your case when you do not use EJBs, I would suggest that you use a facade which could be design like a business delegate. However, as there aren't any EJBs, you will not need a service locator. In this way, you will have a design that can be extended (without any impact on the the presentation tier) to use EJBs in the future.
    Remember, SUN's core J2EE patterns assume that you use EJBs. If you don't, they have to be adapter a little bit.

  • Business Delegate & Session Facade

    1 What is the need of Business delegate? For controlling the interactions between the presentation tier and business tier, session facade pattern can be used.
    2 Can a session facade have all the facade related methods. (i.e. entire application has only one session facade). In the pattern documentation, it is stated as this stratergy inefficient. Why is so?

    1 What is the need of Business delegate? The delegate provides a client-side business abstraction and acts as a proxy for the business service. Note that it is a proxy, not a facade. In other words, it is a "stand-in" for the biz service, but it is not aggregating several method invocations into one and controlling the processing flow. So, the delegate is not providing a higher-level interface to some underlying system, as would a facade.
    So what's the need, if it's just a proxy? Obviously, it adds a layer, so one must consider its benefits versus the drawback of writing, maintaining, and interacting with this extra layer. In a sophisticated system, the benefits are many and will usually outweigh the drawbacks. Following are some of the benefits of using a delegate in the web container as an access point for invocations to the business tier:
    - It hides the underlying implementation details of the business service (ie: lookup, creation, access details of EJB...The delegate may use the Service Locator pattern to achieve this goal).
    - The delegate translates exceptions as necessary. Service-level exceptions, such as java.rmi.Remote can be intercepted by the delegate and translated into application exceptions. This also helps shield web container clients, for example, from EJB and network-related implementation details, which they should not need to worry about.
    - The delegate can attempt retries/recovery efforts transparent to its clients, such that this code can be localized and reused, instead of being duplicated in numerous clients.
    - The delegate can also manage a cache of resources/results, limiting unecessary remote roundtrips
    - The delegate can be used as a control point for multi-threaded access into the business tier. For example, stateful beans are not to be invoked by multiple client threads simultaneously. The delegate can serialize access, or, as mentioned above, handle exceptions/retries, as necessary.
    For
    controlling the interactions between the presentation
    tier and business tier, session facade pattern can be
    used.If you decide to use a delegate in your system, based on considering its benefits, as described above, then you'll typically create a one-to-one mapping between a delegate and a session facade. The delegate is not controlling the processing flow per se, but rather serving as a single access point and proxy as described above. The facade acts as a controller, though, aggregating the interfaces of underlying components and subsystems into a higher-level interface. If you find that your using the delegate more as a facade, we recommend pushing this control code from the web container (where the delegate lives) back to the session bean in the ejb container, so that the logic can be reused across clients.
    >
    2 Can a session facade have all the facade related
    methods. (i.e. entire application has only one session
    facade). In the pattern documentation, it is stated
    as this stratergy inefficient. Why is so?Having a single facade for the entire system would prove to be quite a maintenance and manageability headache for a non-trivial application. Imagine that every time something changes in any subsystem of the service layer, developers are all making changes to the same file and the same class...Not desirable and not very elegant. At the same time, one does not want to go the other way and create too many facades by having a one-to-one mapping of session facades to use cases, for example. We recommend aggregating a group of related interactions into a session facade, so that it provides highly course-grained access and control to underlying components.
    Thanks,
    Dan

  • 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.

  • Is the Business Delegate a Singleton?

    I use the Business Delegate to hide the implementation details (lookup, EJB, etc.) of the Business Service from the client. The same Business Delegate is used in many different places in the client. Now I would like to avoid to pass around the object reference of the Business Delegate in the client.
    I wonder if the Business Delegate should be a Singleton. Is this reasonable?
    Thank you.

    excellent, thanks for your comments.
    so to the orginal question, would you agree with the comments below?
    The pattern catalog describes the business delegate as containing an instance of an EJBObject where as the service locator can optionally cache an EJBHome object. The former avoids repeated JNDI lookups and creating an EJB whilst the later just avoids repeated JNDI lookups.
    Using this strategy, the delegate looks up the home interface and creates an instance of an EJB on creation; it has a one-to-one relationship with it. You don�t really want the delegate to have to create an EJB from the home interface in every method so it should therefore contain an instance member.
    This all means the delegate can�t be a singleton, it can't share that EJBObject with multiple clients.

  • 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

  • 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

  • Business Delegate Pattern?

    What is the real use of Business Delegate pattern in a J2EE architecture design?
    I know it is to decouple the Presentation and Business Logic tiers. But all I can see is it just contains one method which basically accepts data (say Value Object) from Presentation tier (in an example I am looking, it is a Command class) in a method and the method in turn just calls a Session Facade Bean from the Model tier. So, why do we need a Business Delegate class in this scenario? And what are the drawbacks of calling the Session Facade Bean directly from the Command class?
    Thanks for helping me understand it better.
    Rgds,
    Tappori

    Business delegate typically is a presentation-tier object. It serves to shield the presentation-tier from business-tier implementation details. A Business Delegate can encapsulate business services from one or many Session Facade and could also delegate processing to web services as well.
    Here are some fancy links that talk about the Business Delegate guy-
    http://forum.java.sun.com/thread.jsp?forum=425&thread=535855
    http://forum.java.sun.com/thread.jsp?forum=425&thread=548634
    http://forum.java.sun.com/thread.jsp?forum=425&thread=523520
    http://forum.java.sun.com/thread.jsp?forum=425&thread=495578
    And what are the drawbacks of calling the Session Facade Bean directly from the Command class?You tie the presenation-tier object (Command) to business-tier implementation. The Command class should not have lookup code in it and it should not know that it is calling a remote object. Say you want to replace the EJB implementation with the XYZ implementation. Would you then have to recompile all of the Command classes and/or subclasses?

  • Business Delegate, Session Facade or both?

    Hi,
    I'm having some problems with figuring out the point of using both Business Delegate (BD) and Session Facade (SF). As far as I can see, you often have a 1-1 mapping between the BD and SF, so why not use the SF directly?
    Here's my scenario. I have a web application that uses WebWork for presentation and pageflow, a session facade implemented using an ejb, which aggregates calls to the businness objects into "business rule"-methods and business objects implemented using plain java objects. Is there really any need to have a business delegate here? I might as well use the session facade directly from the webwork actions? Or..?
    Any suggestions? Am I far off? ;-)

    As far as I can see, you often have a 1-1 mapping between the BD and SF, so why not use the SFYou can have one Business Delegate encapsulate all of the business methods that are exposed by one or more Session Facades. The benefit here is that you protect the web component from any details of the business tier. e.g. your business tier has five session facades and the web tier has a single Business Delegate. The BD can be extended to call web services as well.
    Here's my scenario. I have a web application that uses
    WebWork for presentation and pageflow, a session
    facade implemented using an ejb, which aggregates
    calls to the businness objects into "business
    rule"-methods and business objects implemented using
    plain java objects. Say you eliminate the EJB implementation. What effect will this have on the web tier objects? The Business Delegate will enable you to easily replace the business implementation with little impact on the web components.

  • Difference between Session Facade and Business Delegate??

    Hello,
    I am currently working on design patterns and I am confused what the difference is between the Session Facade and Business Delegate pattern. They look identical.
    What's the difference?
    Balteo.

    We implement Business Delegators (BD) as follows:
    1. The client always talks to the BD.
    2. The BD then talks to either our Session Facade, Session EJB, or Java Class, etc, etc directly.
    This allows the client end code to never change whilst allowing our BD to swap between different providers of the service we require.
    It's the good 'ole "layer of indirection" thingy.

  • 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

Maybe you are looking for