avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen McConnell <mcconn...@apache.org>
Subject Re: avalon newbie: Innocent question, please don't hurt me -- services strategy with Avalon framework
Date Fri, 15 Nov 2002 21:02:39 GMT

Leo Simons wrote:

>Hi Adam,
>On Fri, 2002-11-15 at 19:39, Adam Rossi wrote:
>>Stephen, I found your summary descriptions helpful. On thing I am
>>struggling with is how to set a parameter in a component that is needed
>>during Initialiable. For example, if my Company component needs a
>>companyID set before it can initialize, how does the container set the
>>ID before initialize is called? It seems that a name/value pair should
>>be set in the context so that Contextualizable can supply the companyId
>>before it is initialized. I have tried to find an example of this but
>>could not find one. Is this beyond the lifecycle of the container and
>>something that should be done via a set method after I have my object?
>nah....it's something you need to do often and it can be easily done
>using the avalon lifecycle.
>we've got Parameterizable and Parameters for passing in property-like
>stuff, but the use of that in current container is not quite as easy as
>using Configuration and Configurable.
>What you do is provide a xml configuration file, and then that
>configuration is handed in as an object hierarchy (think DOM, but way
>easier to use) to the component by the container (it calls the
>configure() method on your component). This is guaranteed to happen
>before initialize() is called.
>(While it is of course possible to put stuff like this in a Context,
>using a Configuration is usually easier and more straightforward for
>data that is naturally represented in XML)
>How to do this exactly differs a little per container. If you are using
>phoenix, your best bet is to take a look at how the demo apps do it
>(somewhat out-of-date downloads from
>http://cvs.apache.org/~hammant/apps/, for the most recent stuff you'll
>have to get this from the jakarta-avalon-apps CVS) for clues.
>I'm CCing the avalon-user list as that's really the best place for talk
>about this. no worries though ;)

The above approach only works if the CompanyID value is a static (i.e. 
declared i a configuration, or context directive or whatever).  If you 
have a runtime value, you have to (a) create you own DefaultContext and 
handle a compoent deployment, (b) use a component lifecycle extension, 
or (c) roll-your-own container.

Cheer, Steve.

see - I can write short messages ;-)

>- Leo Simons
>To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Stephen J. McConnell

digital products for a global economy

To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message