EJB design patterns


EJB design: EJB design patterns

  1. EJB design patterns (4 messages)

    Hello All,
    I have a typical problem, for which I don't know which design pattern to implement and why??
    I have a process which contain the following steps::

    1) I need to create a row in the database.
    2) On the basis of the new Id in the database I need to create a folder in the HDD and copy the file which was uploaded by the user to this folder.
    3) After saving the file in the particular location I need to update the database with the URL of the file.

    I cannot use an EJB to do File I/O so please suggest me some design patterns that will help me solve the above problem


    Threaded Messages (4)

  2. EJB design patterns[ Go to top ]


    First of all, you can use an EJB to write a file. The code will work. However, you are breaking the specification! And you will lose the app servers capabilities on clustering, transaction handling, etc.

    What you can do is to store the "file" in a BLOB in the database. On the other hand, if the file is shared with another (non-J2EE) application, this is not an option.

    So, the two solutions are:
    - Store data as a BLOB in the database.
    - Break the specification and write a file.

    If you go for the second option, communicate this to the architects and designers and document :-)

  3. EJB design patterns[ Go to top ]

    Okay then if I don't want to break the specs. Can I have servlet which will do every thing for me ie. right from the inserting data, creating folders and copying files to updating the data.

    OR is there some other patterns that u can suggest me.

  4. EJB design patterns[ Go to top ]


    Some application servers have special services for dealing with files, i.e. Weblogic has File T3 Service.

  5. EJB design patterns[ Go to top ]

    Why don't you implement an EJB to update the database and develop a servlet to write to the file and call EJB's routines from within the servlet according to the status of your upload.