Just committed a fix for this. It should now be rethrowing the exceptions after logging them.1. as in subject: it seems that ExcaliburComponentManager.initialize() never throws Exception, there are just getLogger().error() statements. is that correct? how to check if initialization stage was successful? (i can check after that with lookup(), but i'd have to know the full component list)
This is how exceptions in the configure method were handled.
The ECM initializes components as they are needed. If there are no dependency problems, this2. what is loading components order and disposing? it seems that components are initialized according to components.xml (or roles.xml?). and disposing? let's say we have component A and B: a. if they dont use each other (are not composable) then loading is A, B and disposing is also A, B. b. if B lookups for A (in initialize()) and releases it in dispose(), then loading is A, B and disposing is B, A. am i correct? c. what about "crossreferencing": i need to lookup in init stage for other compo - B can lookup for A, but A cannot lookup for B? how to workaround this? only use lookups in doStuff() methods?
will often be in the order they appear in the config file.
If A uses B. Then B will be initialized before A as A's initialization can not complete until B
has been initialized. If B also tries to lookup A in its initialize method then you will get an
error caused by the loop. In cases like this, it is necessary to have B lookup A after
initialization has completed. This must be handled by your component as the ECM can not
do it for you. In general, I would reevaluate your design though if you are indeed running into
this case.
The ECM is careful about trying to only dispose components which are not referenced by
other components. So if A looks up B in its initialize method and releases B in its dispose
method, then B will never be disposed until A has first been disposed. If this was not handled
then A could encounter failures because B, which it had not yet released, had already been
disposed by the container.
If you did not initialize a component then you should never dispose it. If you do create3. do i ever have to call component.dispose() manually or let it for component manager?
and initialize a component manually, then you in effect are acting as a mini container
and it becomes your responsibility to always make sure that you call dispose.
It is important that if you lookup and components, you always make sure to release
them. In most cases, you do a lookup in the initialize method and a release in the
dispose method. If you only lookup and release a component when it is needed (as
with a poolable component for example) then you must be careful about exceptions.
If a poolable component is looked up but never released, that component will not be
available for use else where. Always try to use code like the following:
MyService myService = (MyService)manager.lookup( MyService.ROLE );
try
{
// Do something with the service
}
finally
{
manager.release( myService );
}
The ECM is a big component. The code which creates the ECM is acting as a container4. do i have to call ExcaliburComponentManager.initialize() at all? if not, lookup(A) return A correctly (with init stage, some kind of lazy init?). but i see warning "Looking up component on an uninitialized ComponentLocator". moreover, when i have data source components in roles (and even never lookups for them), ExcaliburComponentManager.dispose() shows some strange warning "Error decomissioning component: org.apache.avalon.excalibur. component.ExcaliburComponentSelector". if i have ExcaliburComponentManager.initialize() at start, everything works fine. so - why ExcaliburComponentManager allow for component lookup when it is not initialized and only shows warning?
for the ECM instance. It is responsible for performing all of the necessary initialization steps
as well as all of the shutdown steps for the ECM.
It looks like someone has done some work to make things work if initialize is not called, but
it really should be.
You might want to try taking a look at the ExcaliburComponentManagerCreator class in the
same package as the ECM. It will take care of all of this work for you. It has not yet been
released however and is only available in the CVS version. I have been using it for quite
some time though.
i think all of these problems are trivial for you, but i'm really the beginner with avalon. your help will be really appreciated.
Sorry for the slow reply. Hope this helps. Cheers, Leif -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>