// Need to indicate that this ORB can't be destroyed while we are using it
CorbaBindingHelper.keepORBAlive(location);
try {
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
POAManager poaManager = rootPOA.the_POAManager();
try {
bindingPOA = rootPOA.find_POA("BindingPOA", true);
} catch (org.omg.PortableServer.POAPackage.AdapterNonExistent ex) {
// An AdapterNonExistent exception will be thrown if the POA does not exist. If
// this is the case, then we'll create one.
Policy[] policies = new Policy[ orbConfig.isPersistentPoa() ? 3 : 2];
policies[0] = rootPOA
.create_id_uniqueness_policy(
org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[1] = rootPOA
.create_implicit_activation_policy(
org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
if (orbConfig.isPersistentPoa()) {
policies[2] = rootPOA
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
}
bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
}
if (bindingPOA == null) {
throw new CorbaBindingException("Unable to create CXF CORBA Binding POA");
}
CorbaDSIServant servant = new CorbaDSIServant();
servant.init(orb, bindingPOA, this, incomingObserver, typeMap);
objectId = bindingPOA.activate_object(servant);
obj = bindingPOA.id_to_reference(objectId);
if (location.startsWith("relfile:")) {
URI iorFile = new URI(location.substring(3));
CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
} else if (location.startsWith("file:")) {
URI uri = new URI(location);
CorbaUtils.exportObjectReferenceToFile(obj, orb, uri);
} else if (location.startsWith("corbaloc")) {
// Try add the key to the boot manager. This is required for a corbaloc
addKeyToBootManager(location, obj);
} else if (location.startsWith("corbaname")) {
addKeyToNameservice(location, obj);
} else {
String ior = orb.object_to_string(obj);
address.setLocation(ior);
URI uri = new URI("endpoint.ior");
CorbaUtils.exportObjectReferenceToFile(obj, orb, uri);
}
populateEpr(orb.object_to_string(obj));
LOG.info("Object Reference: " + orb.object_to_string(obj));
// TODO: Provide other export mechanisms?
poaManager.activate();
} catch (Exception ex) {
throw new CorbaBindingException("Unable to activate CORBA servant", ex);
}
}