7. JNDI integration has been created by Guillaume Nodet (Feb 18, 2009).

Content:

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:

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:

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

For example:

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 availebl using the osgi:services/ URL.

top

Reply via email to