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.

Similar Messages

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

  • 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

  • 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

  • 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

  • Bussiness Delegate vs Session Facade.

    Hi,
    Please any one tell me what are the differences between Bussiness Delegate and Session Facade.
    I read some documentation in online but not clear in above two design patterns.
    Any help I will appricate.
    Thanks,
    CDulla.

    A business delegate is generally thought of as a plug-in that is given to the client developer. This "plug-in" can do service lookups and searches on behalf of the client developer. Very smart if you have a Swing or Servlet Developer that doesn't know ejbs.
    A session facade is a session bean that is much like the delegate but resides on the server and is used to encapsulate course services so that network can be held to a minimum.
    A business-delegate can call a session facade which in turn can call an entity bean

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

  • 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

  • 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

  • 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

  • Business Delegate (remove session bean)

    HI all,
    I followed the code example of Business Delegate pattern
    as described in java.sun.com site.
    Everything is well, but I have only a doubt:
    in Business Delegate's constructor the Business Delegate object
    create the session bean reference that it will use.
    I don't see any call to session.remove() method.
    Is it a forgetfulness or there is no real need to call the remove method ?
    May developers rely on the Application Server for bean's removal ?
    (removal for Statfeul or pooling for Stateless)
    Many thanks in advance
    Moreno

    Yes, it's fine to rely on the ejb container to remove both stateful session bean and stateless session bean resources. Most ejb containers define a timeout period after which stateful session beans that have not been accessed will be removed. Similar settings typically control the amount of time a stateless session bean instance will be pooled within the container.
    If you'd like more predictable, programmatic control for stateful session bean removal, you can explicitly call EJBObject.remove(). In that case, the ejb container is required to call ejbRemove on the corresponding stateful session bean, assuming it hasn't already been removed. For stateless session beans, EJBObject.remove() is merely a hint to the container, and might not result in any specific action on the pooled instances. Hope this helps.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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

  • 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

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

  • 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

Maybe you are looking for