db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stuart McGrigor" <Stuart.McGri...@kintore.co.nz>
Subject RE: Torque and jsp
Date Wed, 16 Mar 2005 22:54:17 GMT

and for extra bonus points...

Implement a struts PlugIn with a property torqueConfigFileName - you only
need two methods

   init() - which uses the servlet context to get the real path

       	// Figure out where the torque config file is
       	ServletContext servletContext = servlet.getServletContext();
		String fname = servletContext.getRealPath(this.getTorqueConfigFilename());
		log.info("Initializing Torque from " + fname);

		// Startup torque persistence layer

   destroy() - which shuts Torque down nicely

	    	// We've finished with Torque

which means you only have to add the plugin to your struts-config.xml

    <plug-in className="com.kintore.struts.TorqueDatabasePlugIn">
      <set-property property="torqueConfigFilename"

...and put a torque.properties in the right place whenever you want to use
torque in a struts project.

Stuart McGrigor

Guy Galil wrote...
> another alternative when you initiate Torque in  a servlet is to get the
> actual full path from the servlet:

> ServletContext ctxt = getServletContext();
> String path = ctxt.getRealPath("/")+"/WEB-INF/conf/";
> Torque.init(path+"Torque.properties");

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message