Henning, I do two kinds of cactus tests. 1) I start up turbine in my web.xml so taht it is running for all my cactus tests that need it (mostly testing actions etc). 2) I start up turbine in my cactus test by doing a Turbine.init() in the setUp mehthod (mostly testing services etc).
It looks actually like I can do: rundata = TurbineRunDataService.getRunData(request,response,config) in place of my old rundata = RunDataFactory.getRunData(...); However, based on this, I think I can drop my concern! I think the cleanup work you have been doing is fantastic, and the less code, the better! I will change to TurbineRunDataService and see how it goes, and then update the Wiki page. Eric Pugh -----Original Message----- From: Henning P. Schmiedehausen [mailto:[EMAIL PROTECTED] Sent: Friday, March 14, 2003 6:20 AM To: [EMAIL PROTECTED] Subject: Re: cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/ser [EMAIL PROTECTED] writes: >------_=_NextPart_001_01C2E970.BA7DC9D0 >Content-Type: text/plain; > charset="iso-8859-1" >Henning, >I use the RunDataFactory in the cactus tests to create my runData object. >Check out the section on cactus tests on the wiki >(http://nagoya.apache.org/wiki/apachewiki.cgi?JakartaTurbine2Faq) for an >example. >Now that it is deprecated, what would be the right way of creating a rundata >object? This is not yet set in stone. :-) Do you start up Turbine or just run small unit tests? If you start up Turbine, you can simply use TurbineRunData.getRunData(...) instead of RunDataFactory.getRunData(...) The whole RunDataFactory is trying to do exactly this and faking up a RunData object if the Service is not running. If you can start up the Service, this is simple. If you don't run the Service, please contact me again and I will think about this even more. But I want to get rid of the code duplication in RunDataFactory and TurbineRunDataService. I can factor this out but deprecating the Factory was the easiest way. ;-) As the factory needs the pool service, you might have to start some other turbine services anyway, is there no way you can start the RunData Service? Regards Henning >Eric Pugh >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >Sent: Thursday, March 13, 2003 9:58 AM >To: [EMAIL PROTECTED] >Subject: cvs commit: >jakarta-turbine-2/src/java/org/apache/turbine/services/rundata >TurbineRunDataService.java >henning 2003/03/13 06:57:29 > Modified: src/java/org/apache/turbine Turbine.java > src/java/org/apache/turbine/util RunDataFactory.java > src/java/org/apache/turbine/services/rundata > TurbineRunDataService.java > Log: > Remove RunDataFactory from Turbine Servlet, replace direct TemplateService > usage in Turbine by using a reference. > > Deprecate the RunDataFactory. It sucks. :-) > > Revision Changes Path > 1.35 +25 -5 >jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java > > Index: Turbine.java > =================================================================== > RCS file: >/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v > retrieving revision 1.34 > retrieving revision 1.35 > diff -u -r1.34 -r1.35 > --- Turbine.java 9 Mar 2003 06:33:43 -0000 1.34 > +++ Turbine.java 13 Mar 2003 14:57:15 -0000 1.35 > @@ -91,14 +91,18 @@ > > import org.apache.turbine.services.component.ComponentService; > > +import org.apache.turbine.services.template.TemplateService; > import org.apache.turbine.services.template.TurbineTemplate; > > +import org.apache.turbine.services.rundata.RunDataService; > +import org.apache.turbine.services.rundata.TurbineRunDataFacade; > + > import org.apache.turbine.services.velocity.VelocityService; > > import org.apache.turbine.util.RunData; > -import org.apache.turbine.util.RunDataFactory; > import org.apache.turbine.util.ServerData; > import org.apache.turbine.util.TurbineConfig; > +import org.apache.turbine.util.TurbineException; > > import org.apache.turbine.util.security.AccessControlList; > > @@ -198,6 +202,12 @@ > /** Our internal configuration object */ > private static Configuration configuration = null; > > + /** A reference to the Template Service */ > + private TemplateService templateService = null; > + > + /** A reference to the RunData Service */ > + private RunDataService rundataService = null; > + > /** Logging class from commons.logging */ > private static Log log = LogFactory.getLog(Turbine.class); > > @@ -234,6 +244,15 @@ > >TurbineConfig.PROPERTIES_PATH_DEFAULT); > > configure(config, context, trProps); > + > + templateService = TurbineTemplate.getService(); > + rundataService = TurbineRunDataFacade.getService(); > + > + if (rundataService == null) > + { > + throw new TurbineException("No RunData Service >configured!"); > + } > + > } > catch (Exception e) > { > @@ -633,7 +652,7 @@ > > // Get general RunData here... > // Perform turbine specific initialization below. > - data = RunDataFactory.getRunData(req, res, >getServletConfig()); > + data = rundataService.getRunData(req, res, >getServletConfig()); > > // If this is the first invocation, perform some > // initialization. Certain services need RunData to >initialize > @@ -717,7 +736,8 @@ > // than just the default page. If you do, add logic to > // DefaultPage to do what you want. > > - String defaultPage = >TurbineTemplate.getDefaultPageName(data); > + String defaultPage = (templateService == null) > + ? null :templateService.getDefaultPageName(data); > > if (defaultPage == null) > { > @@ -816,7 +836,7 @@ > finally > { > // Return the used RunData to the factory for recycling. > - RunDataFactory.putRunData(data); > + rundataService.putRunData(data); > } > } > > > > > 1.5 +11 -10 >jakarta-turbine-2/src/java/org/apache/turbine/util/RunDataFactory.java > > Index: RunDataFactory.java > =================================================================== > RCS file: >/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/RunDataFactory . >java,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -u -r1.4 -r1.5 > --- RunDataFactory.java 9 Mar 2003 02:54:11 -0000 1.4 > +++ RunDataFactory.java 13 Mar 2003 14:57:15 -0000 1.5 > @@ -74,6 +74,9 @@ > * @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a> > * @author <a href="mailto:[EMAIL PROTECTED]">John D. McNally</a> > * @version $Id$ > + * @deprecated This factory tries to be the RunData Service if no RunData >Service is > + * configured. RunData Service is now mandatory for Turbine so use it >directly without > + * this factory. > */ > public class RunDataFactory > { > @@ -96,15 +99,13 @@ > throws TurbineException, > IllegalArgumentException > { > - /* > - * NOTE: getRunData( HttpServletRequest req, > - * HttpServletResponse res ) has been deprecated 3-3-2000. > - * Wait a couple months (before Turbine 1.0) and remove this > - * method. Also don't allow null for req, res, or config as > - * these are now required by Turbine. Uncomment the below as > - * this should include the necessary functionality when we are > - * ready. > - */ > + // NOTE: getRunData( HttpServletRequest req, > + // HttpServletResponse res ) has been deprecated 3-3-2000. > + // Wait a couple months (before Turbine 1.0) and remove this > + // method. Also don't allow null for req, res, or config as > + // these are now required by Turbine. Uncomment the below as > + // this should include the necessary functionality when we are > + // ready. > if (req == null || > res == null || > config == null) > > > > 1.9 +2 -3 >jakarta-turbine-2/src/java/org/apache/turbine/services/rundata/TurbineRunDa t >aService.java > > Index: TurbineRunDataService.java > =================================================================== > RCS file: >/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/rundata/Tu r >bineRunDataService.java,v > retrieving revision 1.8 > retrieving revision 1.9 > diff -u -r1.8 -r1.9 > --- TurbineRunDataService.java 13 Mar 2003 14:03:48 -0000 1.8 > +++ TurbineRunDataService.java 13 Mar 2003 14:57:28 -0000 1.9 > @@ -240,8 +240,7 @@ > || (res == null) > || (config == null)) > { > - throw new IllegalArgumentException( > - "RunDataFactory fatal error: HttpServletRequest, " > + throw new IllegalArgumentException("HttpServletRequest, " > + "HttpServletResponse or ServletConfig was null."); > } > > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >------_=_NextPart_001_01C2E970.BA7DC9D0-- -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/ Java, perl, Solaris, Linux, xSP Consulting, Web Services freelance consultant -- Jakarta Turbine Development -- hero for hire --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
