title: Getting started with bundle DI in an OSGi environment
body: <p>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. </p>
  
  <p>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. </p>
  
  <p>Given two bundles;</p>
  
  <p><em>Consumer bundle</em></p>
  
  <pre><code>package bundles.consumer;
  
  class Consumer implements BundleActivator{
      @Inject
      private Producer producer;
  
      public void bundleActivated(BundleContext con) {
          this.producer.getNextItem();
      }
  }
  </code></pre>
  
  <p><em>Producer Bundle</em> </p>
  
  <pre><code>package bundles.producer;
  
  @Singleton
  class Producer {
      public String getNextItem() {
          return "item x"; 
      }
  }
  </code></pre>
  
  <p>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 <em>really</em> want to avoid. </p>
  
  <p>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. </p>
  
  <p>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!</p>
  
  <hr>
  
  <p>edit, my attempt using SCR: <a href="http://tydus.net/codeExamples/mvnScr.tar" rel="nofollow">http://tydus.net/codeExamples/mvnScr.tar</a></p>