Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2012, 12:24 AM   PM User | #1
xconspirisist
Regular Coder

 
xconspirisist's Avatar
 
Join Date: Jun 2006
Location: Great Britain.
Posts: 137
Thanks: 1
Thanked 6 Times in 6 Posts
xconspirisist has a little shameless behaviour in the past
Getting started with bundle DI in an OSGi environement

Hey folks. I have been developing an application with Apache Felix as my OSGi runtime for a while and up until now progress has been great. However, I want to now adopt dependancy injection and the "default" mechanism with Apache Felix seems to be iPOJOs.

However, I've found that the documentation and tutorials around about Apache felix are too weak and I've not managed to get anywhere. So I am prepared to change, but first of all I'd better explain the (very simple) think I'm trying to do.

Given two bundles;

Consumer bundle
Code:
class Consumer implements BundleActivator{
    @Inject
    private Producer producer;

    public void bundleActivated(BundleContext con) {
        this.producer.getNextItem();
    }
}
Producer bundle
Code:
@Singleton
class Producer {
    public String getNextItem() {
        return "item x"; 
    }
}
I want the OSGi runtime to start up the Consumer bundle, realize that it needs a Producer to work, the framework then starts the Producer bundle and injects and instance into the Consumer. Simples. iPOJOs suggest that this is possible using annotations only (@Singleton, @Inject) or similar, but I simply can't get it to work. OSGi apparently has declarative services, but that means writing a lot of XML, which I really want to avoid.

Anywoo, I'm prepared to adapt JBoss, Equinox or alternative OSGi runtime and an alternative dependancy injection mechanism, be that Peaberry, Spring DM or something completly difference. I'm already using Maven.

What I'm asking, is can somebody create a Hello World using the Producer and Consumer idea to help me get started? I've really spent a tonne of time reading up and find the learning curve insurmountable!
__________________
If I have been helpful, use the "thank" button - It makes me happy!

xconspirisist.co.uk - homepage of my online alias
technowax.net - a community for people interested in all forms of modern technology.

Last edited by xconspirisist; 01-10-2012 at 12:38 AM..
xconspirisist is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:32 AM.


Advertisement
Log in to turn off these ads.