Thanks for the response. I've filed a bug for this.
Looking at the codes in BlueprintRepository, looks like we're destroying
objects in reverse creation order.
public void destroy() {
// destroy objects in reverse creation order
List<String> order = new ArrayList<String>(creationOrder);
Collections.reverse(order);
for (String name : order) {
Recipe recipe = recipes.get(name);
if (recipe != null) {
recipe.destroy(instances.get(name));
}
}
instances.clear();
creationOrder.clear();
}
Not much consideration is made on dependency order (.component-1 is my
bean). This is what i got from debug variables from IDE:
creationOrder is: [blueprintContainer, blueprintBundle, blueprintConverter,
blueprintBundleContext, repositoryAdmin, .component-1]
So, it does feel like if we destroy in the order below, things will be ok,
right?:
order needs to be [blueprintContainer, blueprintBundle, blueprintConverter,
blueprintBundleContext, .component-1, repositoryAdmin]
I am not familiar with blueprint's codebase/concepts, any tips (i.e. key
classes to look at, etc.) on how to figure out the dependencies and order
the objects for destruction correctly?
On Wed, Mar 16, 2011 at 12:32 AM, Alasdair Nottingham <[email protected]>wrote:
> Hi,
>
> I believe this is a bug. The blueprint specification 121.3.11 says:
> "Destroying all component instances in reverse dependency order, see
> Reverse Dependency Order on page 200." and the code clearly does not
> do this.
>
> Please raise a bug on JIRA here:
> https://issues.apache.org/jira/browse/ARIES
>
> The message is not output by aries, I would guess it is out by the
> Gogo shell, so they would be best placed to explain the choice of info
> versus error.
>
> Alasdair
>
> On 15 March 2011 14:16, KcTang <[email protected]> wrote:
> > Hi,
> >
> > i've got a working blueprint bundle to register some default OBR
> > repositories on initialization of the bundle.
> >
> > The xml config looks like:
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
> >
> > <bean class="play.osgi.bundle.config.RepositoryRegistrationBean"
> > init-method="init" destroy-method="shutdown">
> > <argument index="0" ref="blueprintBundleContext"/>
> > <argument index="1" ref="repositoryAdmin"/>
> > </bean>
> >
> > <reference id="repositoryAdmin"
> >
> > interface="org.apache.felix.bundlerepository.RepositoryAdmin">
> > </reference>
> >
> > </blueprint>
> >
> > Both BundleContext & RepositoryAdmin are injected to
> > RepositoryRegistrationBean's constructor. The init() works.
> >
> > However, when i try to access the RepositoryAdmin during shutdown(), i
> got
> > this exception:
> >
> > 2011-03-15 22:06:49,899 INFO [Gogo shell]
> > [8/org.apache.aries.blueprint/0.3.0]
> > org.apache.aries.blueprint.container.BeanRecipe - Error invoking destroy
> > method
> > org.osgi.service.blueprint.container.ServiceUnavailableException: The
> > Blueprint container is being or has been destroyed
> > at
> >
> org.apache.aries.blueprint.container.ReferenceRecipe.getService(ReferenceRecipe.java:176)
> > at
> >
> org.apache.aries.blueprint.container.ReferenceRecipe.access$000(ReferenceRecipe.java:49)
> > at
> >
> org.apache.aries.blueprint.container.ReferenceRecipe$ServiceDispatcher.call(ReferenceRecipe.java:201)
> > at
> > org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
> > at
> > org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
> > at
> org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
> > at $Proxy6.removeRepository(Unknown Source)
> > at
> >
> play.osgi.bundle.config.RepositoryRegistrationBean.shutdown(RepositoryRegistrationBean.java:39)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)[:1.6.0_24]
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_24]
> >
> >
> > Does it mean that we cannot access referenced services in destroy-method?
> > Any place I can read up on these?
> >
> > A slightly unrelated question....how come INFO log is used instead of
> ERROR
> > log?
> >
> >
> >
>
>
>
> --
> Alasdair Nottingham
> [email protected]
>