Re: context
J Aaron Farr <[email protected]> Wed, 24 Nov 2004 09:44:42 -0500
| Newsgroups | gmane.comp.jakarta.avalon.user |
|---|---|
| Message-ID | <[email protected]> |
Samuel Ferrer wrote:
>
> Thank you very much ...
>
> I wander ... that mapping is a very simple class like a Hashtable isn't
> ... no need for anything else?
Under the covers, yes, it's a Map implementation. But the Context is
read-only for components.
> How does the container publish the properties ... via a documentation
> obtained some how ... ex like is done in web services?
For existing Avalon containers, the properties are only available via
the Context object, though one could write a JNDI adaptor. Here's a
typical example:
public class MyComponent
extends AbstractLogEnabled
implements MyService, Contextualizeable
{
public MyService(){
}
public void contextualize(Context context)
throws ContextException
{
File home = (File) context.get("impl.workDir");
...
}
...
}
This example would work in Excalibur Fortress. Getting context objects
is very similar to getting other components via the ServiceManager.
However, since there is no standard set of context entries, you need to
know what container you plan to use and program accordingly.
Consequently, using the context object is often discouraged because it
ties you to a container implementation.
jaaron