struts plugin

Tue, Mar 1, 2005

Siva2 is progressing. I’ve implemented a Struts front end, where a Bootstrap PlugIn initialises things and stores a controller for JSPs to use. Got some funny behaviour from the PlugIn though, which a quick trip into log4j land shed some light on.

Consider the following PlugIn from struts-config.xml: <plug-in className=“org.Siva.Core.Bootstrap”>   <set-property property=“logFile” value=“/WWW/siva/WEB-INF/logs/bootstrap.log” />   <set-property property=“configFile” value=“/WEB-INF/config/siva.xml” /> </plug-in>

Now, there are two bean type methods to be called on the Bootstrap class by struts: setLogFile(String) setConfigFile(String)

now, I know I should just set the logfile in the config file but I’m doing this to illustrate the order of calling the PlugIn methods.

It seems that struts will call the methods in the Bootstrap.class in the following order:

  • setConfigFile
  • setLogFile
  • init

i.e. in the reverse order in which they appear in struts-config.xml and where init() of course is the standard PlugIn::init()

So, if you plan on logging from the bean setter methods, you’ll have to do some jiggery pokery ordering in struts-config.xml but that’s a bad idea. Best to let the setters do their work and do all config/initialisation in init

comments powered by Disqus