Alen Ribic wrote:
Hi all

Where do you think is the best place to initialise your persistence, ORM,
system in Struts?
Action classes, etc.?
I would like to make the Struts framework least aware of my Persistence
system.

One place (easy to set up) is to just create a static initializer block in one of your classes that does this when the class is loaded. This is fine for a simple singleton but you might want more fine-grained control over it -- in which case you might want to implement ServletContextListener interface for context notifications.


I'm using OJB with PB API and Struts 1.1.

Apparently, best practice, when using OJB PB API is to create an instance of
Broker before executing business command and then close the Broker after
execution.


Any ideas as to what particular design I should implement here to get most out of role separation?

You can wrap this activity into a facade. I don't use OJB, but my approach has been to create an object to represent a business object in my application. The constructor of this object uses a DAO factory to create a DAO, to which it delegates all of the work. The DAO uses JDBC, but I could easily create a new DAO that uses OJB or JDO or Hibernate or even EJB. This way my Actions can simply refer to this facade object and the facade object handles the details -- yet I can always substitute a different DAO or even remove DAOs from the picture altogether without making changes to my Action code.


This seems to be a pretty common design, I have seen it described in many places and on this list.



Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to