On 03/02/2011 06:44 PM, Vincent Massol wrote: > I forgot to menton the alternative which is to create a WebAppVelocityFactory > component impl (hint = "webapp"), in the same manner that I have already > created WebAppVelocityConfiguration and WebAppVelocityEngine. > > I think my preference foes to the API modification now.
I don't like either one. Adding the hint parameter to the API is nice if there ever will be a need to have different types of engines at runtime. Do we have this need at the moment? I don't think so, so IMO it's better to keep the API as simple as possible while still serving our needs. Implementing WebAppVelocityFactory somehow beats the definition of a factory, at least in my view. A factory usually is a single class that knows how to create objects of different types. Normally the preferred approach is indeed to add a "hint" parameter, but as I said we don't really need it at the moment. What if we just change the implementation of the factory so that the default hint is taken from a configuration? What we'll need to do is to provide a different configuration for use inside XWiki. > Thanks > -Vincent > > On Mar 2, 2011, at 4:49 PM, Vincent Massol wrote: > >> ok I have no added the following 2 new component impls: >> * WebAppVelocityConfiguration >> * WebAppVelocityEngine >> >> However it's not enough since DefaultVelocityEngine.createVelocityEngine() >> does a component lookup on VelocityEngine and we need a way for it to look >> up with a passed hint. >> >> I'm proposing to modify the current VelocityFactory API from: >> >> VelocityEngine createVelocityEngine(String key, Properties properties) >> throws XWikiVelocityException; >> >> to: >> >> VelocityEngine createVelocityEngine(String key, Properties properties, >> String engineType) throws XWikiVelocityException; >> >> where engineType is the hint corresponding to the engine to look up. >> >> Then DefaultVelocityManager can call VelocityFactory, passing the "webapp" >> hint to createVelocityEngine. >> >> WDYT? >> >> Thanks >> -Vincent >> >> On Mar 2, 2011, at 1:56 PM, Vincent Massol wrote: >> >>> Just a heads up of what I'm working on right now: cleaning up >>> xwiki-velocity dependencies. >>> >>> I'm going to split it into several submodules: >>> * xwiki-velocity-management (or xwiki-velocity-jmx) >>> * xwiki-velocity-default >>> * xwiki-velocity-webapp (implementation of VelocityEngine and >>> VelocityConfiguration with hint = "webapp", this is to use use velocity >>> with the WebappResourceLoader loading templates from the webapp's root dir) >>> >>> -Vincent >>> >> -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

