You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Shash Chatterjee <sh...@hotmail.com> on 2003/06/03 00:34:01 UTC
ServiceManager for life-cycle extensions
Berin and others,
Used to be that life-cycle extentions got introduced to Fortress in the
container's initialize() method. Now, I've found, the
LifeCycleExtensionManager is provided in the container-manager context.
The problem is that the create(...) method of my extension needs a
ServiceManager. In the old way, by the time Container.initialize() was
called, the service amanger had been setup/configured already, and all
we had to do was:
if (creator instanceof Serviceable) {
creator.service(m_serviceManager);
}
This is no longer possible. I'm thinking that the
ContainerManagerConstants.SERVCIE_MANAGER somehow needs to be copied
from the container-manager context into the container context. For
that, I have to likely extend ContextManager.initializeServiceManager()
or DefaultContainerManager.createContainer(). Those do not look too
easy to extend, I'd have to duplicate most of the code.
Any ideas/suggestions on how best to provide
the extension with a ServiceManager?
Thanks,
Shash
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: ServiceManager for life-cycle extensions
Posted by Anton Tagunov <at...@mail.cnt.ru>.
Hello Shash!
SC> The problem is that the create(...) method of my extension needs a
SC> ServiceManager. In the old way, by the time Container.initialize() was
SC> called, the service amanger had been setup/configured already, and all
SC> we had to do was:
SC> if (creator instanceof Serviceable) {
SC> creator.service(m_serviceManager);
SC> }
SC> This is no longer possible.
errr.. what has happened? Why isn't this possible?
SC> Any ideas/suggestions on how best to provide
SC> the extension with a ServiceManager?
My idea is that it would be best to
move m_extManager.makeReadOnly()
from
AbstractContainer.setupExtensionManager()
to the top of
AbstractContainer.initialize()
(this change is in one of my pending patches)
Then it will be possible to do
initialize()
{
m_extManager.addCreatorExtension( new Foo( m_serviceManager ) );
super.initialize();
}
Unitll that is done (untill makeReadOnly() is moved) the closest
to the ideal that I can think of (yes, it's a temporary dirty
workaround) is override
AbstractContainer.setupExtensionManager( ServiceManager )
copy all the existing code from the original and add your
extensions there.
SC> can ContextManager have "final" taken out
[from ContextManager]
BL> I have both made ContextManager not final
Great :-))
SC> In looking at this further, can the following line be put at the bottom
SC> of ContextManager.initializeServiceManager():
SC> m_childContext.put( SERVICE_MANAGER, manager );
BL> and added that line to initializeServiceManager.
A little bit afraid to protest :-), but ..
this way we'll get not the ServiceManager that drives the
container, but only the DefaultServiceManager created by
ContextManager, a bootstrap ServiceManager I would call it.
It's probably going to have only LoggerManager, Sink, PoolManager,
InastrumentManager, parent LifecycleExtensionManager and
the default source resolver installed in it.
Berin, do you think we could remove the bootstrap service manager
from m_childContext and instead do this?
--- AbstractContainer.orig 2003-06-04 09:27:24.000000000 +0400
+++ AbstractContainer.java 2003-06-04 12:28:13.000000000 +0400
@@ -295,8 +295,7 @@
*/
m_extManager.addCreatorExtension( new InstrumentableCreator( m_instrumentManager ) );
- // just to be on the safe side
- m_extManager.makeReadOnly();
+ // m_extManager will be made readonly in initialize()
}
/**
@@ -615,6 +614,9 @@
public void initialize()
throws CompositeException, Exception
{
+ // just to be on the safe side
+ m_extManager.makeReadOnly();
+
// go over all components
final Iterator i = m_components.iterator();
final BoundedFifoBuffer buffer = new BoundedFifoBuffer( Math.max( m_components.size(), 1 ) );
WBR, Anton
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: ServiceManager for life-cycle extensions
Posted by Berin Loritsch <bl...@apache.org>.
Shash Chatterjee wrote:
> Berin,
>
> In looking at this further, can the following line be put at the bottom
> of ContextManager.initializeServiceManager():
> m_childContext.put( SERVICE_MANAGER, manager );
>
> If not, can ContextManager have "final" taken out so I can extend it and
> do the same in my extended class?
Ask and ye shall receive. This was a very minor thing to do (on both
counts). I have both made ContextManager not final, and added that line
to initializeServiceManager.
>
> Thanks,
> Shash
>
> Shash Chatterjee wrote:
>
>> Berin and others,
>>
>> Used to be that life-cycle extentions got introduced to Fortress in
>> the container's initialize() method. Now, I've found, the
>> LifeCycleExtensionManager is provided in the container-manager context.
>>
>> The problem is that the create(...) method of my extension needs a
>> ServiceManager. In the old way, by the time Container.initialize()
>> was called, the service amanger had been setup/configured already, and
>> all we had to do was:
>> if (creator instanceof Serviceable) {
>> creator.service(m_serviceManager);
>> }
>> This is no longer possible. I'm thinking that the
>> ContainerManagerConstants.SERVCIE_MANAGER somehow needs to be copied
>> from the container-manager context into the container context. For
>> that, I have to likely extend
>> ContextManager.initializeServiceManager() or
>> DefaultContainerManager.createContainer(). Those do not look too easy
>> to extend, I'd have to duplicate most of the code.
>>
>> Any ideas/suggestions on how best to provide
>> the extension with a ServiceManager?
>>
>> Thanks,
>> Shash
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org
>
>
>
--
"You know the world is going crazy when the best
rapper is a white guy, the best golfer is a black guy,
The Swiss hold the America's Cup, France is
accusing the US of arrogance, and Germany doesn't want
to go to war. And the 3 most powerful men in America
are named 'Bush', 'Dick', and 'Colon' (sic)".
-----Chris Rock
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: ServiceManager for life-cycle extensions
Posted by Shash Chatterjee <sh...@hotmail.com>.
Berin,
In looking at this further, can the following line be put at the bottom
of ContextManager.initializeServiceManager():
m_childContext.put( SERVICE_MANAGER, manager );
If not, can ContextManager have "final" taken out so I can extend it and
do the same in my extended class?
Thanks,
Shash
Shash Chatterjee wrote:
> Berin and others,
>
> Used to be that life-cycle extentions got introduced to Fortress in the
> container's initialize() method. Now, I've found, the
> LifeCycleExtensionManager is provided in the container-manager context.
>
> The problem is that the create(...) method of my extension needs a
> ServiceManager. In the old way, by the time Container.initialize() was
> called, the service amanger had been setup/configured already, and all
> we had to do was:
> if (creator instanceof Serviceable) {
> creator.service(m_serviceManager);
> }
> This is no longer possible. I'm thinking that the
> ContainerManagerConstants.SERVCIE_MANAGER somehow needs to be copied
> from the container-manager context into the container context. For
> that, I have to likely extend ContextManager.initializeServiceManager()
> or DefaultContainerManager.createContainer(). Those do not look too
> easy to extend, I'd have to duplicate most of the code.
>
> Any ideas/suggestions on how best to provide
> the extension with a ServiceManager?
>
> Thanks,
> Shash
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org