cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: Create your own configuration file
Date Wed, 07 Mar 2001 23:02:21 GMT
"Peter C. Verhage" <petercv@zeelandnet.nl> wrote:
>I'm working on a logicsheet which loads a special class which will be 
>cached
>for use within other pages which use this class. This class has to read 
>some
>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 
>to
>edit the class it's source and recompile the class before you can even 
>think
>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 cocoon.properties 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, 
>and
>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 
>of
>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 cocoon.properties, but as you may understand I
>don't want to mess with Cocoon it's source to do this because I want to 
>keep
>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 cocoon.properties. Add it to cocoon.properties 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 http://www.hotmail.com.


Mime
View raw message