You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robert Dale <rd...@digital-mission.com> on 2001/06/06 00:54:26 UTC

Re: [C2] Properties or Initargs for cocoon documents

On Tue, 5 Jun 2001, [ISO-8859-1] Lu�s[ISO-8859-1] G�is wrote:

> Hello, Robert!
> 
> I'm also interested in getting properties for cocoon logicsheets loaded at Cocoon startup. I'm using Cocoon 1, but do you already have any working solution or clue about how to make this work? 
> 
[snip]
> 
> >     How can I get some properties or initargs into documents being
> processed
> > > by Cocoon2 without haing to reload a properties file on every request?
> > > Since none of the files in my application except cocoon run as a
> servlet, I
> > > can't pass initargs, can I?  And since none of them stick around for
> more
> > > than a single request, I can't load a properties file once and stick
> with
> > > those values, right?  How are people setting properties for Cocoon2
> > > applications?

What I decided to do is have my properties file ina directory in the CLASSPATH.

CLASSPATH=$CLASSPATH:/etc/myapp

/etc/myapp:
  my.props


Then I can access it like so:

InputStream in = ClassLoader.getSystemResourceAsStream("my.props");
Properties props = new Properties();
props.load(in);
String foo = props.getProperty("my.foo");
String bar = props.getProperty("my.foo.bar");
String baz = props.getProperty("baz.baz.baz");

-- 
Robert Dale





---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>