<not re-answering the stuff Steve answered :D> Stephen McConnell wrote:
figuring out what this interface should look like is extremely difficult (which is why the various containers don't share one (yet)). Steve already pointed at the appliance interface in the merlin project; fortress has a Container interface:If it is the second solution that has been choosen (in order to not impose too
much coopling between containers and framework), i can't find any interface for
that kind of service. As i need it, i try to specify it for it to be enough
general. Could you give me some advices ??
public interface ContainerAbstraction
{
public Object get(String implementationKey,
Context context, Logger logger, Configuration configuration);
public void release(Object object);
}
http://cvs.apache.org/viewcvs.cgi/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/Container.java
In phoenix a sort-of similar role is fulfilled by Kernel & Application:
http://cvs.apache.org/viewcvs.cgi/avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Kernel.java
http://cvs.apache.org/viewcvs.cgi/avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Application.java
my suggestion would be not to worry too much about what the exact interface should look like, and just put in the methods that you need as you write the app, though if you want to use an avalon-provided interface, fortress' Container interface might be the best one.
But it is not clear to me exactly what you want to do. It sounds like what you need is actually a single service/component which offers "pseudocomponents" that can do actual work. ie something like:
public interface MyServiceProvider
{
public MyServiceWorker get( Configuration config );
}
public interface MyServiceWorker
{
public void doSomethingSpecific();
}
class MyServiceProviderImpl
{
private Logger m_logger;
private Pool m_workers;
MyServiceWorker get( Configuration config )
{
final String name = config.getElem(
"name" ); // or something, can never remember
final MyServiceWorkerImpl w = m_workers.get();
ContainerUtil.enableLogging( w,
m_logger.getChildLogger( name ) );
// do other stuff
return w;
}
release( MyServiceWorker w )
{
m_workers.release( w );
}
}
// in client code
s = (MyServiceProvider)m_serviceManager.lookup( MyServiceManager.ROLE );
w = s.get( config );
w.doSomethingSpecific();
s.release( w );
when "do other stuff" becomes a lot of work you can think about putting in place an actual container implementation like fortress, but you often don't really need one. I guess it's obvious from the example I'm not too fond of ServiceSelector ;)
cheers,
- Leo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
