You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Wil Bierbaum <WB...@scme.com> on 2004/03/30 19:20:52 UTC

Re: Extension class in .application. Howto obtain a context relative file

Use Class.getResourceAsStream and load the properties file.

>>> mech@tngtech.com 3/30/2004 9:07:16 AM >>>
Hi all,

I'd like to use an extension class to do some basic initialization
stuff while
Tapestry starts up as it was recommended in an earlier thread.

To do so, I'd prefer to get some properties from either an property
file, the
.application or web.xml. I don't like to hardcode any paths. 
Unfortunately in the extension class I don't have a RequestCycle or
HttpServlet-similar interface to read properties from .application or
web.xml.

Is there a way still to avoid reading hardcoded property files at this
early
stage of Tapestry bootstrap? Anything context relative would suffice.
For
example directly in /WEB-INF/config.properties etc.

Thx
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org 
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Extension class in .application. Howto obtain a context relative file

Posted by Michael Echerer <Mi...@tngtech.com>.
Possible, of course. But this would be relative to the extension class itself
instead of the context as far as I know. Means it could change during
refactoring (e.g. you change the package structure and your relative
ResourceStream path needs to be adjusted then) and it goes a bit against the
idea of a web app initialization.
But if it's not possible to do it better, I'll take this alternative.

IMHO it would be nicer if you had extension classes subclass some Tapestry class
so that you have some servlet specifics available here, too. Is there really no
way to have a hook to the Tapestry app in extension classes and are the really
completely separated from the framework?

If extensions can be immediately instanciated during Tapestry webapp start, it
should be possible to make use of parts of the framework immediately, too.
Reading properties from .application etc. would be nice to have if one of the
proposed purposes of extensions is init stuff etc. What else than setting up
loggers, resource connections and so on would you do there? All things you
usually have some configuration files for. Class.getResourceAsStream() doesn't
seem to be the ideal way.


Michael

> Use Class.getResourceAsStream and load the properties file.
> 
> >>> mech@tngtech.com 3/30/2004 9:07:16 AM >>>
> Hi all,
> 
> I'd like to use an extension class to do some basic initialization
> stuff while
> Tapestry starts up as it was recommended in an earlier thread.
> 
> To do so, I'd prefer to get some properties from either an property
> file, the
> .application or web.xml. I don't like to hardcode any paths. 
> Unfortunately in the extension class I don't have a RequestCycle or
> HttpServlet-similar interface to read properties from .application or
> web.xml.
> 
> Is there a way still to avoid reading hardcoded property files at this
> early
> stage of Tapestry bootstrap? Anything context relative would suffice.
> For
> example directly in /WEB-INF/config.properties etc.
> 
> Thx
> Michael
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org 
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org