final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);
final ModelNode contextsNode = resultNode.get("java: contexts");
final ServiceController<?> jbossContextService = serviceRegistry.getService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
final NamingStore jbossContextNamingStore = NamingStore.class.cast(jbossContextService.getValue());
try {
addEntries(contextsNode.get("java:jboss"), new NamingContext(jbossContextNamingStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set("Failed to read java:jboss context entries."));
}
final ServiceController<?> globalContextService = serviceRegistry.getService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
final NamingStore globalContextNamingStore = NamingStore.class.cast(globalContextService.getValue());
try {
addEntries(contextsNode.get("java:global"), new NamingContext(globalContextNamingStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set("Failed to read java:global context entries."));
}