Hi there,
After following the recent discussion on defining a minimal set of core
interfaces for A5 (which is nice), I tried to gather some of the ideas
and further simplify the concept.
1. Context
Definition: the operational context of a specific component. There is no
need for the component to modify its context (think EJB and JNDI env
ctx). Management should happen elsewhere.
The lookups can be represented simply as strings (URN/URI syntax), which
gives us the following interface:
public interface Context
{
Object lookup( String name ) throws AppropriateException;
}
Naturally, we also need to define a method for setting the context that
a component can implement (see further below).
2. Logger, LogEnabled & Co.
I wouldn't include these in the core interfaces. Logger is just another
component that could be acquired through the context. This might also
help to reduce friction between different projects, as using Avalon
wouldn't force them to use a specific logging interface.
The same applies to Configuration, Parameters, etc. (it would be of
course possible to implement a base/utility class that takes care of the
"standard" lookup operations).
3. Lifecycle
I think we should only include the lifecycle interfaces for which there
exists a clear contract, i.e. the ones that make sense in the
container-component relationship. This basically leaves us the following
operations:
initialize(Context?) / dispose() (~ create() / destroy())
These make sense and should be included. The initialize method could
well take the context as an argument eliminating the need for an
additional interface (a separate setContext method would basically
say: here's your context, but don't use it before I call
initialize).
suspend() / resume() (~ stop() / start())
The necessity of these is subject to some debate. I suppose, the
component could have use for them, but the contract would have to be
clear (see below).
Now, to ensure performance and consistent client access, we should also
have a 'service handle' interface (Resource in Merlin):
public interface Handle
{
Object access() throws AppropriateException;
void release( Object instance );
}
This would also give clear semantics to suspend() and resume(). To
summarize, here's a crude example:
public class MyComponent implements ...
{
void initialize( Context ctx ) throws AppropriateException
{
Logger logger = (Logger) ctx.lookup("...");
Configuration conf = (Configuration) ctx.lookup("...");
serviceHandle = (Handle) ctx.lookup("...");
// etc...
}
void doSomething() throws Exception
{
Service service = null;
try {
service = (Service) serviceHandle.access();
// do something
} finally {
if (service != null) {
serviceHandle.release( service );
}
}
}
}
I think that's about it. Your turn :)
BTW, it's been a while since my previous posting, but I'm glad to see
everyone's been busy ;) I still have some catching up to do, but I hope
to be able to help with A5 (and Cocoon) implementation.
(: A ;)
--
Antti Koivunen (Mr.) <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
- Re: Avalon 5 Core Interfaces Antti Koivunen
- Re: Avalon 5 Core Interfaces Stephen McConnell
- Re: Avalon 5 Core Interfaces Antti Koivunen
- Re: Avalon 5 Core Interfaces Stephen McConnell
- Re: Avalon 5 Core Interfaces Antti Koivunen
- Re: Avalon 5 Core Interfaces Stephen McConnell
- Re: Avalon 5 Core Interface... Antti Koivunen
- Cornerstone doesn't bui... Greg Steuck
- Re: Cornerstone doesn't... Stephen McConnell
- Re: Avalon 5 Core Interfaces Andrzej Jan Taramina
- Re: Avalon 5 Core Interfaces Antti Koivunen
