THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
 
  Apache ServiceMix NMR #usernavbar() #printableicon() #pdficon() #feedicon()  
When you contribute content to this Wiki, you grant a license to the ASF for inclusion in ASF works (as per the Apache Software License).
  7. JNDI integration

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{scrollbar}

Anchor
top
top

7. JNDI integration

ServiceMix NMR includes a JNDI / OSGi integration based on OSGi RFC-0142.

Creating the InitialContext

No specific setup is need to create the InitialContext:

Code Block
Context ctx = new InitialContext();

The default context is a writable JNDI tree.

Accessing OSGi services

From the InitialContext, you can retrieve OSGi services using the following syntax:

Code Block
osgi:services/<interface>[/<filter>]

For example:

Code Block
InitialContext context = new InitialContext();
ExampleService = (ExampleService) context.lookup("osgi:services/com.example.ExampleService");

Naming SPI

The JNDI integration uses the OSGi registry to lookup a javax.naming.spi.InitialContextFactoryBuilder. If you want to use another provider for JNDI, you need to register such a service in the OSGi registry.

Note that in all cases, OSGi services will be available using the osgi:services/ URL.

#top