[opencms-dev] On how to integrate OpenCMS and velocity:

Michael Emmerich emmerich at german-navy.de
Mon Apr 1 17:43:58 CEST 2002


Alex,

> You still miss the point. The ResourceLoader is a Velocity class, it is
> not inteded to be accessible from Outside of Velocity and the way Werner
> has done it is a quick workaraound to get going. You will have no way to
> initialize the Velocity ResourceLoader in the launcher. Believe me, or
> better yet, look at the Velocity code.

Sure, the ResourceLoader cannot be accessed directly from outside of
Velocity. But you do not need that, and you do not need to inititalize
it form within an OpenCms Launcher since the ResourceLoader is some kind
of driver to access the normal filesystem or to hook into something else
(like Werners OpenCMSResourceLoader accesses the OpenCms VFS). As far as
I understood it, the ResourceLoader is initalized by the Velocity
engine, this is working in a similar way than OpenCms uses its
ResourceBroker. You later only access the templates directly via the
Velocity engine (e.g. Velocity.getTemplate(fileName)), without direct
access to the ResourceLoader.

So the general idea, of for a Velocity lanucher (and resource type)
could be the following:

1) Read the requested file header, its a Velocity recource, so use the
Velocity Launcher
2) Get an instance of the LC_Velocity_OpenCMS class
3) call the parseTemplate method of the LC_Velocity_OpenCMS class and
forward the requested URI, the current parameters and the current
CmsObject to it (similar to Werners code, except the template name would
be the URI)
4) the parseTemplate method will update the CmsObject in the
OpenCMSResourceLoader, load the requested template via the
OpenCMSResourceLoader and parse it (see Werners code).
5) fetch the created output and send it to the response stream.

1) must be done by OpenCms, 2)-5) by the Velocity Launcher. 

A problem of couse is synchronization (now I understand what Werner
wrote about it <grin>, I guess I missunderstood him first here), only
one request of this kind could be fulfilled simultanious. Configuration
would be something else.

 
Bye,
Michael


-- 
Home   : emmerich at german-navy.de
Work   : michael.emmerich at framfab.de
ICQ    : 18897063
WWW    : German Naval History http://www.german-navy.de





More information about the opencms-dev mailing list