Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Exceptions injecting reserved beans in Blueprint
Exceptions injecting reserved beans in Blueprint [message #900854] Wed, 08 August 2012 17:51 Go to next message
Anthony Bargnesi is currently offline Anthony BargnesiFriend
Messages: 5
Registered: August 2012
Junior Member
Hello,

I am having issues with 1.0.0.RELEASE of Gemini Blueprint in Virgo 3.5.0.

The blueprint specification states that blueprintContainer and blueprintBundleContext are reserved component ids in Blueprint. It mentions you can inject them into a managed bean using a 'ref'.

I've tried this and failed with:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'blueprintBundleContext' is defined

My blueprint is defined as:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="...1.0.0 namespace omitted to avoid spam message..."
  xmlns:xsi="...1.0.0 namespace omitted to avoid spam message..."
  xsi:schemaLocation="...1.0.0 namespace omitted to avoid spam message...
  ...1.0.0 namespace omitted to avoid spam message...">

    <bean id="referenceManager" class="com.acme.ReferenceManager">
        <property name="context" ref="blueprintBundleContext" />
        <property name="container" ref="blueprintContainer" />
    </bean>

    <reference id="acmeService" interface="com.acme.AcmeService" timeout="10000">
        <reference-listener ref="referenceManager" bind-method="bind" unbind-method="unbind" />
    </reference>
</blueprint>


The reference-listener ('referenceManager') is defined as:
public class ReferenceManager {

    private BundleContext ctx;
    private BlueprintContainer bc;

    public void setContext(BundleContext ctx) {
        this.ctx = ctx;
    }

    public void setContainer(BlueprintContainer bc) {
        this.bc = bc;
    }

    public void bind(ServiceReference ref) {
        System.out.println("<<< Binding service reference: " + ref + " >>>");
    }

    public void unbind(ServiceReference ref) {
        System.out.println("<<< Unbinding service reference: " + ref + " >>>");
    }
}


When I do not inject the two blueprint beans the reference listener binds/unbinds as expected.

Do I need to define additional beans to use blueprintContainer or blueprintBundleContext?

Thanks!
Anthony Bargnesi
Re: Exceptions injecting reserved beans in Blueprint [message #900915 is a reply to message #900854] Thu, 09 August 2012 03:23 Go to previous messageGo to next message
Anthony Bargnesi is currently offline Anthony BargnesiFriend
Messages: 5
Registered: August 2012
Junior Member
I've debugged Gemini to see the execution flow.

- A ChainActivator can be called if "Bundle-Activator" is set to that class (org.eclipse.gemini.blueprint.extender.internal.boot.ChainActivator).
- The ChainActivator runs two BundleActivator's ContextLoaderListener and BlueprintLoaderListener if blueprint is available.
- BlueprintLoaderListener creates a BlueprintContainerProcessor in the createContextProcessor() method.
- BlueprintContainerProcessor loads the reserved beans on context refresh.

I'm seeing my bundle use the NoOpOsgiContextProcessor instead of the BlueprintContainerProcessor so I imagine it is loaded with the ContextLoaderListener and not the BlueprintLoaderListener.

Should I force 'ChainActivator' in the manifest header:
Bundle-Activator: org.eclipse.gemini.blueprint.extender.internal.boot.ChainActivator


This seems awfully hacky so I assume I'm wrong somehow. Any nudge in the right direction would be greatly appreciated.

Thanks!
Anthony Bargnesi
Re: Exceptions injecting reserved beans in Blueprint [message #901140 is a reply to message #900915] Fri, 10 August 2012 01:52 Go to previous message
Anthony Bargnesi is currently offline Anthony BargnesiFriend
Messages: 5
Registered: August 2012
Junior Member
Debugging confirms my suspicions. The BlueprintLoaderListener needs to be used as a BundleActivator to get access to these beans. It is used by ChainActivator.

Both classes are in private packages (.internal) that are not exported.

Filed as an issue on Glyn's gemini repo (issue #7).
Previous Topic:Gemini Web 2.1.0 RELEASE is now available
Next Topic:Service/References status
Goto Forum:
  


Current Time: Thu Mar 28 15:17:57 GMT 2024

Powered by FUDForum. Page generated in 0.02257 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top