How to combine Session Facade and Transfer object?

Hello All!
I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
I have problems with business logic architecture.
Here is the brief description of backend application architecture design:
1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
Questions:
1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
* Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
* Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
* So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
* So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
Thank you!
Astghik

Astghik wrote:
Hello All!
I'm working on an enterprise application. Presentation layer is a stand alone client, business logic is build on the Glassfish v2.1 and MySQL is used as a database. The client is connection to the GlassFishj server remotely using EJBs.
I have problems with business logic architecture.
Here is the brief description of backend application architecture design:
1. Session Facade pattern is used to simplify the client and application server interface and to provide application layers between backend (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).
I would simply recommend establishing a service tier. Your services should be stateless. You can go the extra mile and have a session facade, but in the majority of cases, coding to an interface for your service accomplishes the same goals.
2.Transfer Object pattern to define update transfer objects strategy in order to decrease network overhead during client and application server interactions and to provide version control for objects. Transfer objects are designed as simple java business serializable objects. (http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html)
The idea of the transfer object is very similar to the Command pattern. I think if you investigate that pattern, it will be more obvious. The transfer object reduces network latency by consolidating all the parameters into an object, ideally, this also consolidates multiple method calls. If you combine a transfer object (or command object) with a service tier, you get the best of both worlds. The service can delegate calls to helper objects (or other services or components) using the data in the transfer / command object.
3. Originally the backend application consisted of three modules: users, storage and orders, but at the end I have decided to divide my application into the following parts - assortments, map, menu, orders, transactions, users.
The is your domain. It will vary from application to application. The principles above are more general (e.g., patterns and architectural tiers) and should apply to most domains. However, your actual use case may require something different.
4. All MySQL database transactions are via JDBC using procedures. No use of entity beans.
Consider using something like iBatis or Spring's JDBC templating to make your life easier with JDBC.
Questions:
1. I have some doubts about using Session Facade and Transfer object patterns at the same time. At first I'd mike to cite the definitions of the patters from the SUN official web site.
* Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients.
* Use a Transfer Object to encapsulate the business data. A single method call is used to send and retrieve the Transfer Object. When the client requests the enterprise bean for the business data, the enterprise bean can construct the Transfer Object, populate it with its attribute values, and pass it by value to the client.
* So, if I use Transfer Object along with Session Facade, it makes some difficulties with object version control, because I 2 or
3 transfer objects controls with the 1 bean class. The best option for Transfer object Pattern is that each transfer object should have its own bean class to provide ability of object's version control. In the case it can bring the network overhead because of frequent remote calls caused by the large number of the bean classes.
* So, should I use the both patterns? If yes, how to manage the interaction the patterns. If no, which one to use.
Versioning is a separate issue. Generally, the more coarsely grained your transfer / command object is, the more changes are likely to impact dependent objects.
Your command or transfer object does not have to be a vanilla JavaBean, where you are basically creating a bean that has data from other objects. You can simply use your command / transfer object to encapsulate already existing domain objects. I see no need to map to a JavaBean with what you have described.
Generally, a method signature should be understandable. This means that many times it is better to pass the method, say, two coarsely grained objects than a signature with a dozen primitives. There are no hard and fast rules here. If you find a method signature getting large, consider a transfer / command object. If you want one service to delegate calls to a number of other services, you can also create a transfer / command object to furnish the controlling service with the data it needs to invoke the dependent services.
2. E.g. I have a huge list of the Order objects and each Order object consists of other complicated objects. So, would I have trouble to transfer that list over network? If yes, how to manage it.
This is a large, open-ended question. If you are going to display it to a user on a screen, I do not see how you avoid a network transfer with the data. The general answer is to not pass the data itself but rather a token (such as a primary key, or a primary key and a start and stop range such as you see on a Google search result). You do want to limit the data over the network, but this comes at a cost. Usually, the database will receive additional load. Once that becomes unacceptable, you might start putting things into session. Then you worry about memory concerns, etc. There is no silver bullet to the problem. It depends on what issues you are trying to address and what trade-offs are acceptable in your environment.
Thank you!
AstghikBest of luck.
- Saish

Similar Messages

  • Difference between session facade and business delegate patterns

    Hi,
    How the session facade and business delegate patterns differ from each other, as both of them have similar and almost same forces to be addressed.
    Please address.
    Satya.

    BTW, in J2EE Core patterns :
    When the Business Delegate is udes with a Session Facade, typically there is a one-to-one relationship between the two. This one-to-one relationship exists because logic that might have been encapsulated in a Business Delegate relating to its interaction with multiple business services (creating a one-to-many relationship) will often be factored back into a Session Facade.[I/]

  • How to implement session varibles and how to use it

    how to implement session varibles and how to use it.ple help me

    Please see the below blog, Hope it helps!!!
    http://obieetraining11.blogspot.com/2012/06/create-initialization-block-for-session.html

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

  • Difference between Session Facade and Business Delegate design patterns

    Can someone tell me the differences between Session Facade and Business Delegate 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 ?

  • What is the best combination of read and write objects to binary files ...

    Hi everyone,
    what are the best combination of read and write objects to read/write a record of customers from a binary file. I should be able to use StringTokenizer. I am bit confused with all these Stream reader and writers.
    abdul

    You are, indeed, confused:
    o StreamTokenizer works on character input, not binary input.
    o Readers and Writers in general work on character streams, not binary.
    That leaves you various input streams and output streams for reading binary data.

  • How to combine Area chart and Line chart?

    Hi,
    I have to display Area chart with the Line chart in one graph.
    How can i do that,
    Please suggest.

    Pretty easy, just add series to your chart
    http://forums.arcgis.com/threads/73636-How-to-combine-line-chart-and-stacked-column-chart
    Dany

  • Session Facade and Business Delegate 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!!

    The session facade is borrowed from the facade pattern, so you could have a facade to almost anything.
    A session facade is usually against other beans...for example if you
    (Not deployed as CMR)
    1. Address bean
    2. Phone Bean
    3. Customer bean
    as entity beans then you can build a session facade such as
    CustomerFacadeBean which will CreateReadUpdateDelete(CRUD) address and phone as well when a customer is CRUD ed.
    In your case you said you have very complex sql's so one way would be
    Business Delegate -> Session Facade -> (Bean Managed) Entity Bean -> DataAccessObject.
    If you think this is a overkill then, write a custom pattern such as DataDelegate
    DataDelegate -> (Bean Managed) Entity Bean -> DataAccessObject.
    In the above scenario you should be quite sure that the system will not evolve into a case mentioned above such as when customer is deleted a phone and address object are also thrown away.
    You said this scenario
    Business Delegate -> DAO..
    I don't think this is a good idea because, a business delegate is a proxy against business objects....and usualy in J2EE business objects are session beans. Entity and DAO objects are data objects not business ones.
    Besides if you do the above scenario you will end up wiring all the transactions, etc etc in your DAO which is not a good idea.
    Although you could use BusinesDelegates against entity beans it will lead to a misnomer.

  • Session facade vs Command object pattern

    Hello,
    I am debating using the Command pattern as my primary strategy for implementing my J2EE enterprise app business logic and would like some advice.
    The general idea is to have only a few types of abstract commands (such as a ReadComand, an UpdateCommand -- I might have a slightly finer granularity than this, I don't know) and implement each use case as a command instance. For example, I might have a command called GetOrderItemsCommand which is a ReadCommand and returns the list of order items (i.e., has a getItems() method) when execute()'d.
    The result of my design will be a very small set of stateless session beans with an execute() interface. No entity beans (will use Hibernate) and may very well eventually implement a Message bean interface with a similar executeAsynchronously() type method, if eventually necessary.
    I guess the popular alternative (or, more correctly, the norm) is to implement session facades for this.
    However, I am attracted to the Command pattern because of its simplicity, it's rapid application development angle, its disconnected-ness from EJB (e.g., a modification to a command does not mean touching any EJB at all, just the command class), and the ability for implementing cross-cutting features (such as transactions or security, although I also plan to use an AOP solution at the POJO level). At the same time, it works as a delegate of an EJB, so it's accessible for all kinds of network clients.
    I am also familiar with it's drawbacks (e.g., maintainability for large numbers of commands, per the literature, such as the Marinescu 2002 EJB Patterns book).
    So, very few types of stateless session beans (though there may be many instances) -- mainly there for remote client acceessibility and the ability to leverage application-level transactions if needed.
    Nevertheless, I have never tried the command pattern approach and was curious if others had feedback or case studies.
    Best regards --

    You normally use Command to decouple your controller from the view and model tiers. Your take on making command objects 'polymorphic' is interesting, and an angle I had not thought of. In general, I implement command objects rather like the Action class in Struts.
    Each command has implements an execute() method declared in the ICommad interface. The constructor of the command object ensures that a given command has all the variables and data required to execute properly. I also create a likes() method that returns a boolean. That way, I can add all my commands to a handler and iterate until on returns true on likes().
    - Saish

  • Dataretrieval in hr abap  (how to combine both pa and om in hr abap)

    Hi Experts?
        My requirement is i wants to retrieve the data from HRP1000 table i.e get the long text from the field sc_text ,for this they have provided me some field values like PLVAR='01'  ,  OTYPE='O'  , OBJID -
    (not given)  ,ENDDA =9999.12.31. and also they have mentioned table PA0001-BUKRS(field).
          how to get objid field?
       Please provide me query ,how to combine Organizational data(hrp1000)  with Personnel administration data(pa0001-bukrs)
    Thanks in advance,
    mohan

    Hi mohan,
    1. Its very impractical,
       especially in SAP HR Tables,
       to directly get data from tables using joins.
    2. In your case,
       first read from infotype 0001
       using direct select statement,
       (or u can use HR_READ_INFOTYPE)
    3. After wards, LOOP / FOR ALL ENTRIES IN
       and then read from the other required tables HRP1000.
    regards,
    amit m.

  • How to replace hard drive and transfer everything over?

    I've looked everywhere but am unable to find a definitive guide on how to do this.
    Currently I have an early 2011 MBP that came with Snow Leopard and upgraded to Lion later. It has an HDD and I want to replace it with an SSD and transfer everything over to the SSD. Considering Lion created a Recovery partition (and there is also an EFI partition), I'm confused on how to do this the best way to basically copy my current hard drive to the new SSD.
    The best I've figured out is to connect the SSD with a SATA-USB cable, use the Lion Recovery Disk Assistant ( http://support.apple.com/kb/dl1433 ) to create a Recovery partition on the new SSD, then, booting into Recovery, install Lion on the new SSD, and then use Migration Assistant to transfer all my files over.
    Is there a simpler or better-explained way to basically copy my current hard drive over to a new SSD and then remove the HDD and use the SSD?

    How to replace or upgrade a drive in a laptop
    Step One: Repair the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Step Two: Remove the old drive and install the new drive.  Place the old drive in an external USB enclosure.  You can buy one at OWC who is also a good vendor for drives.
    Step Three: Boot from the external drive.  Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears.  Select the icon for the external drive then click on the downward pointing arrow button.
    Step Four: New Hard Drive Preparation
    1.  Open Disk Utility in your Utilities folder.
    2. After DU loads select your new hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID (for Intel Macs) or APM (for PPC Macs) then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Step Five: Clone the old drive to the new drive
    1. Open Disk Utility from the Utilities folder.
    2. Select the destination volume from the left side list.
    3. Click on the Restore tab in the DU main window.
    4. Check the box labeled Erase destination.
    5. Select the destination volume from the left side list and drag it to the Destination entry field.
    6. Select the source volume from the left side list and drag it to the Source entry field.
    7. Double-check you got it right, then click on the Restore button.
    Destination means the new internal drive. Source means the old external drive.
    Step Six: Open the Startup Disk preferences and select the new internal volume.  Click on the Restart button.  You should boot from the new drive.  Eject the external drive and disconnect it from the computer.

  • How to access the currentPage and currentNode Objects in a Sling Servlet

    I have a requirement to write a Sling Servlet instead of regular CQ5 JSP
    In a standard CQ5 JSP it's easy to use the currentPage and currentNode objects, as they are automatically added by the default includes
    <%@include file="/libs/foundation/global.jsp"%>
    <h2>currentPage</h2>
    Title: <%= currentPage.getTitle() %><br />
    Name: <%= currentPage.getName() %><br />
    Path: <%= currentPage.getPath() %><br />
    Depth: <%= currentPage.getDepth() %><br />
    <h2>currentNode</h2>
    Title: <%= currentNode.getProperty("jcr:title").getString() %><br />
    Name: <%= currentNode.getName() %><br />
    Path: <%= currentNode.getPath() %><br />
    Depth: <%= currentNode.getDepth() %><br />   
    </div>
    I would like to know how to do this in a sling servlet, and be able to use the currentNode and currentPage objects.
    Does anyone have any code samples they would like to share??
    Thanks
    Tyrone

    currentPage - request.getResource().adaptTo(Page.class)
    currentNode - request.getResource().adaptTo(Node.class)

  • How to combine a JFormattedTextField and a button in a cell editor

    Outside of a table we have a JFormattedTextField into which the user types an amount. Next to the field is a calculator button. If the user clicks the calculator button, we open a calculator, enable the user to type his calculations, and when he presses OK, we copy the result to the field.
    Now we want the field to be a cell editor and to display the button next to the field (in the table cell). How can we do this? Do I have to make the button a separate column, or can I combine the field and button in 1 column?
    Thanks,
    Eli

    Hi,
    Try like this:
    DATA: BEGIN OF line,
          col1 TYPE i,
          col2 TYPE i,
          END OF line.
    DATA itab LIKE STANDARD TABLE OF line.
    data ch(1) type c.
    PERFORM fill CHANGING itab.
    PERFORM out USING itab.
    FORM fill CHANGING f_itab LIKE itab.
      DATA f_fill LIKE LINE OF f_itab.
      DO 3 TIMES.
        f_fill-col1 = sy-index.
        f_fill-col2 = sy-index ** 2.
        APPEND f_fill TO f_itab.
      ENDDO.
    ENDFORM.                    "FILL
    FORM out USING value(f_itab) LIKE itab.
      DATA f_fill LIKE LINE OF f_itab.
    write ch as checkbox.
      LOOP AT f_itab INTO f_fill.
        WRITE:/ f_fill-col1, f_fill-col2.
      ENDLOOP.
    Regards,
    Bhaskar
    ENDFORM.                    "OUT

  • How to combine a doSubmit and a f?p call ?

    Hello,
    I've got an updateable report with a link column. That column is defined in my SQL query (select '<a href="f?p=&APP_ID.:4:' ||:APP_SESSION || ' ...) . That link is an image.
    When the user click on that image, I'd like to simulate the doSubmit('MyButton') function, but I can't manage to combine the doSubmit and the f?p call.
    If I write <a href=javascript:doSubmit('MyButton');f?p=...
    => it only executes the doSubmit.
    If I write <a href=f?p=.... ;javascript:doSubmit('MyButton');
    =>It only executes the f?p.
    Have you got an idea to combine both f?p and doSubmit ?
    Thanks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Cyril,
    You can either submit a page, or you can go to another page by clicking on a link. In HTML DB those links start with f?p. Your after-submit computations, validations and processes are only executed if you actually submit a page. If you want to submit a page by clicking on a report link, you need to use some Java Script that submits the page and a branch to specify where to go next, e.g. return to the same page. The following thread contains more detailed information about how to do this, and how to keep track of which column link the user actually clicked on:
    Submit page before launching report link
    Regards,
    Marc

  • How to get subject text and Reference Object both Screens at the Header lev

    Dear Experts ,
                    I am getting only Notification Header Screen ( Subject Text, Notification system and User Status) at the Header of Notification and different Tabs under that screen.
                    I want Subject Text and Reference Object screens at header Level so that any screen Tab selected at a time I can see the Subject and Reference Object of the Notification.
                    Pls tell me is there any way so I can Include 2 screens( Subject and Reference Object at the Header Level.)
    With best regards,
    Narendra

    Narendra,
    You can't in the standard system.
    Only the tabs are configurable.
    PeteA

Maybe you are looking for

  • Workflow for Creating Encore Menu in Photoshop

    This question deals with working between Encore and Photoshop CS5... I hope this is the proper Forum to post. I'll post in the Photoshop Forum as well... I'm creating a DVD menu from scratch in Photoshop CS5 to be used in authoring a DVD in Encore. 

  • Pc to mac transfer ........ almost there -please HELP me complete!

    Successfully have moved all music, artwork, vids, podcasts from PC to MAC... moved the iTunes files across, and my playlists are present, but in name only..the associated music to playlist didn't connect.... Two different questions.. 1) do I need to

  • Date format (YYMMDD ) for the file

    HI All, I need to place a file with file name that should include the date in the format YYMMDD. Currently the format is DDMMYY. How can i do that? Thanks In advance!!

  • ITunes/iCloud Backup nexus?

    If I've set my iPhone to be backed up to iCloud, but then I do a manual backup to iTunes, does iTunes push the backup to the Cloud? Or must I backup directly from the iPhone for it to go to the Cloud? I'm wondering if that's a faster way to backup to

  • Tab control with a case structure

    I am having trouble getting my tab control to work with case structure. I have 4 tabs that i want displayed on my front panel, each with a separate graph. When I click on any tab besides the first one there is nothing shown on the graph. I think i ha