cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <>
Subject Re: Create your own configuration file
Date Wed, 07 Mar 2001 23:02:21 GMT
"Peter C. Verhage" <> wrote:
>I'm working on a logicsheet which loads a special class which will be 
>for use within other pages which use this class. This class has to read 
>configuration data to do certain stuff (create a database connection and
>other stuff).
>At the moment I've got a special Configuration class in which resides this
>configuration data. Ofcourse this is not easy to change, because you have 
>edit the class it's source and recompile the class before you can even 
>about reloading the servlet engine. Another disadvantage of this method is
>that I cannot create a nice JAR package of all the classes the system uses
>because the configuration class resides within one of the main packages.
>So as you may understand I was looking in a way to read this data from a
>configuration file. Ofcourse this doesn't have to be difficult if you
>exactly know where to find the configuration file. But I don't want to have
>a static location for it, it has go to be specified somewhere in another
>configuration file (probably or in the servlet zone file,
>I'm using Apache Jserv at the moment BTW).
>In other words I want my class(es) to have a special configuration file, 
>get the location of this file somewhere from within the servlet engine. I
>don't want to use dirty tricks that send the filename at constructor time 
>the class. I just want the class to ask some special (Servlet) class where
>the configuration file is. Is there some mechanism within Cocoon that makes
>this possible. And if it's possible, how? :) Maybe I can include the
>parameters somehow within, but as you may understand I
>don't want to mess with Cocoon it's source to do this because I want to 
>it portable for future Cocoon releases...

You don't have to. Here is one way:

* Create a dummy Producer or Processor whose only purpose is to read the 
configuration data from Add it to and 
it will be automatically be loaded. Example:

# Load a processor
processor.type.xsp = org.apache.cocoon.processor.xsp.XSPProcessor

# Give it a parameter
processor.xsp.encoding = UTF8

I did also implement another way (listed in Changes) but it was a while ago 
and, to be honest, the other way doesn't make much sense to me now! But this 
way should work fine.

Get Your Private, Free E-mail from MSN Hotmail at

View raw message