Skip to content

Commit

Permalink
IIOP Subsystem: export naming root reference with default value /JBos…
Browse files Browse the repository at this point in the history
…s/Naming/root
  • Loading branch information
tadamski committed Feb 27, 2015
1 parent 6112d1a commit 42325c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private Constants() {

// Configuration properties that are built and set by the ORB service.
public static final String NAME_SERVICE_INIT_REF = "NameService";
public static final String ROOT_CONTEXT_INIT_REF = "JBoss/Naming/root";

public static final String SSL_SOCKET_TYPE = "SSL";
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ public void execute(DeploymentProcessorTarget processorTarget) {
.setInitialMode(ServiceController.Mode.ACTIVE).install();

// create the CORBA naming service.
final String rootContext = props.getProperty(Constants.NAMING_ROOT_CONTEXT);
final CorbaNamingService namingService = new CorbaNamingService(rootContext);
final CorbaNamingService namingService = new CorbaNamingService(props);
context
.getServiceTarget()
.addService(CorbaNamingService.SERVICE_NAME, namingService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class NamingDefinition extends PersistentResourceDefinition {

protected static final AttributeDefinition ROOT_CONTEXT = new SimpleAttributeDefinitionBuilder(
Constants.NAMING_ROOT_CONTEXT, ModelType.STRING, true)
.setDefaultValue(new ModelNode().set(Constants.NAME_SERVICE_INIT_REF))
.setDefaultValue(new ModelNode().set(Constants.ROOT_CONTEXT_INIT_REF))
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).setAllowExpression(true).build();

protected static final AttributeDefinition EXPORT_CORBALOC = new SimpleAttributeDefinitionBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package org.wildfly.iiop.openjdk.service;

import java.util.Properties;

import org.jboss.msc.inject.Injector;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
Expand All @@ -33,6 +35,7 @@
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.PortableServer.POA;
import org.wildfly.iiop.openjdk.Constants;
import org.wildfly.iiop.openjdk.IIOPExtension;
import org.wildfly.iiop.openjdk.logging.IIOPLogger;
import org.wildfly.iiop.openjdk.naming.CorbaNamingContext;
Expand All @@ -49,18 +52,20 @@ public class CorbaNamingService implements Service<NamingContextExt> {

public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append(IIOPExtension.SUBSYSTEM_NAME, "naming-service");

private static final Properties properties = new Properties();

private final InjectedValue<POA> rootPOAInjector = new InjectedValue<POA>();

private final InjectedValue<POA> namingPOAInjector = new InjectedValue<POA>();

private final InjectedValue<ORB> orbInjector = new InjectedValue<ORB>();

private final String rootContext;

private volatile NamingContextExt namingService;

public CorbaNamingService(final String rootContext) {
this.rootContext = rootContext;
public CorbaNamingService(Properties props) {
if (props != null) {
properties.putAll(props);
}
}

@Override
Expand All @@ -85,10 +90,18 @@ public void start(StartContext context) throws StartException {
namingService = NamingContextExtHelper.narrow(namingPOA.create_reference_with_id(rootContextId,
"IDL:omg.org/CosNaming/NamingContextExt:1.0"));

//exporting the name service initial reference
((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(rootContext,
// exporting the NameService initial reference
((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(Constants.NAME_SERVICE_INIT_REF,
namingPOA.servant_to_reference(ns));

// exporting root-context initial reference
final boolean exportCorbaloc = properties.getProperty(Constants.NAMING_EXPORT_CORBALOC).equals("true");
if (exportCorbaloc) {
final String rootContext = properties.getProperty(Constants.NAMING_ROOT_CONTEXT);
((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(rootContext,
namingPOA.servant_to_reference(ns));
}

} catch (Exception e) {
throw IIOPLogger.ROOT_LOGGER.failedToStartJBossCOSNaming(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public static InitialContext getContext() throws NamingException {
System.setProperty("com.sun.CORBA.ORBUseDynamicStub", "true");
final Properties prope = new Properties();

prope.put(Context.PROVIDER_URL, "corbaloc::" + HOST + ":3628/NameService");
// prope.put(Context.PROVIDER_URL, "corbaloc::" + HOST + ":3528/JBoss/Naming/root");
prope.put(Context.PROVIDER_URL, "corbaloc::" + HOST + ":3628/JBoss/Naming/root");

prope.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.iiop.naming:org.jboss.naming.client");
prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
Expand Down

0 comments on commit 42325c1

Please sign in to comment.