.addListener(verificationHandler)
.install());
// Create the java:global namespace
final ServiceBasedNamingStore globalNamingStore = new WritableServiceBasedNamingStore(context.getServiceRegistry(false), ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
newControllers.add(target.addService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, new NamingStoreService(globalNamingStore))
.setInitialMode(ServiceController.Mode.ACTIVE)
.addListener(verificationHandler)
.install());
// Create the java:jboss vendor namespace
final ServiceBasedNamingStore jbossNamingStore = new WritableServiceBasedNamingStore(context.getServiceRegistry(false), ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
newControllers.add(target.addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, new NamingStoreService(jbossNamingStore))
.setInitialMode(ServiceController.Mode.ACTIVE)
.addListener(verificationHandler)
.install());
NamespaceContextSelector.setDefault(new NamespaceContextSelector() {
public Context getContext(String identifier) {
final NamingStore namingStore;
if (identifier.equals("global")) {
namingStore = globalNamingStore;
} else if (identifier.equals("jboss")) {
namingStore = jbossNamingStore;
} else {
namingStore = null;
}
if (namingStore != null) {
try {
return (Context) namingStore.lookup(EMPTY_NAME);
} catch (NamingException e) {
throw new IllegalStateException(e);
}
} else {
return null;
}
}
});
// Register InitialContext and InitialContextFactoryBuilder as OSGi services
newControllers.add(NamingSubsystemOSGiService.addService(target,
InitialContext.class, InitialContext.class, verificationHandler));
newControllers.add(NamingSubsystemOSGiService.addService(target,
javax.naming.spi.InitialContextFactoryBuilder.class, InitialContextFactoryBuilder.class, verificationHandler));
newControllers.add(target.addService(JndiViewExtensionRegistry.SERVICE_NAME, new JndiViewExtensionRegistry()).install());
// Setup remote naming
final ServiceBasedNamingStore remoteExposedNamingStore = new WritableServiceBasedNamingStore(context.getServiceRegistry(false), ContextNames.EXPORTED_CONTEXT_SERVICE_NAME);
newControllers.add(target.addService(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, new NamingStoreService(remoteExposedNamingStore))
.setInitialMode(ServiceController.Mode.ACTIVE)
.addListener(verificationHandler)
.install());
final RemoteNamingServerService remoteNamingServerService = new RemoteNamingServerService();