Berin Loritsch wrote:
> > > The GeneratorManager would handle the release() method, or it would
> > > declare its semantics for use.
> > >
> > > Component use should not be a function of component lookup.
> >
> > Ok. What then will be contract between component manager and
> > user? When you call lookup(), what should you expect -
> > Component, ComponentSelector, ComponentGenerator, Pool,
> > something else?
> >
> > Or, I always will get XXXXXManager? Then, lifecycle
> > management will be moved to XXXXXManager, right?
>
> You will always get the XXXXXManager. So yes, lifecycle does
> move to XXXXXManager. However, the XXXXXXManager can act as a container
> for older components--that way we don't have to throw away the
> work we already have done.
This sounds like it will lead to something like:
class ComponentManagerHelper {
private ComponentManager cm;
private Map managers = new HashMap();
public ComponentManagerHelper( ComponentManager cm )
{
this.cm = cm;
}
public Object lookup( String role )
{
XXXXXManager manager = cm.lookup( role );
Object component = manager.lookup( role );
managers.put( component, manager );
return component;
}
public void release( component )
{
manager = managers.remove( component );
if ( manager instanceof Releasable )
((Releasable) manager).release( component );
}
}
and the typical use would be:
public void compose( ComponentManager cm )
{
ComponentManagerHelper cmh = new ComponentManagerHelper( cm );
myComponent = cmh.lookup( SomeComponent.ROLE )
// throw away reference to cm and use cmh instead
}
and
cmh.release( MyComponent );
in which case why don't we save the client this step and do something
like:
abstract class AbstractComponentManager implements ComponentManager
{
private Map managers = new HashMap();
public Object lookup( String role )
{
XXXXXManager manager = lookupManager( role );
Object component = manager.lookup( role );
managers.put( component, manager );
return component;
}
public void release( component )
{
manager = managers.remove( component );
if ( manager instanceof Releasable )
((Releasable) manager).release( component );
}
abstract protected XXXXXManager lookupManager( role );
}
The reason I suggest this (which may seem at odds with my postings in
other branches of this thread) is that I think forcing the XXXXXManager
makes the framework a little heavier -- and with the
AbstractComponentManager above you still get the benefits but the
components dont need to see it (e.g. you dont need to create an
XXXXXManager to do unit testing).
Robert.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>