<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Folks,<br>
      <br>
      [<a href="https://issues.jboss.org/browse/AS7-1426">AS7-1426</a>]
      Provide injectable BundleContext in JNDI<br>
      <br>
      I currently use this code to bind the OSGi system BundleContext to
      java:global/osgi/BundleContext<br>
    </tt>
    <blockquote><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Register BundleContext in JNDI<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BinderService service = new
        BinderService(CONTEXT_LONG_NAME, context);<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service.getManagedObjectInjector().inject(new
        StaticManagedObject(context));<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServiceBuilder&lt;?&gt; builder =
        target.addService(CONTEXT_LONG_SERVICE_NAME, service);<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builder.addDependency(CONTEXT_BASE_SERVICE_NAME,
        NamingStore.class, service.getNamingStoreInjector());<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builder.install();<br>
      </tt></blockquote>
    <tt>is this the right code and JNDI context?<br>
      <br>
      The resource injection works like this<br>
    </tt>
    <blockquote><tt>&nbsp;&nbsp;&nbsp; @Resource(lookup =
        "java:global/osgi/BundleContext")<br>
        &nbsp;&nbsp;&nbsp; private BundleContext context;<br>
      </tt></blockquote>
    <tt>What needs to be done to get rid of the lookup attribute (i.e.
      injection by type)?<br>
      <br>
      cheers<br>
      -thomas<br>
    </tt>
    <blockquote><br>
    </blockquote>
    <blockquote><br>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thomas Diesler
JBoss OSGi Lead
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx 
</pre>
  </body>
</html>