• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where do Factories in Struts go?

 
Andrew Leer
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any particular place where factories, which create business deligates, in a Struts application should be initalized?

Thanks,
Andy
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite often in a Struts application you have objects that need to be initialized only once when the application starts up. One good way to initialize these objects is to write a class that implements org.apache.struts.action.Plugin and put the initialization code in its init() method. You would then declare this plugin class in the struts-config.xml file with a <plug-in> tag. If you do this, the Struts ActionServlet will execute your logic when it initializes.

Many developers have found this a convenient way to initialize a Hibernate Session Factory, for example.
[ September 06, 2006: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic