}
org.omg.CORBA.Object obj = null;
try {
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
POAManager poaManager = rootPOA.the_POAManager();
Policy[] policies = new Policy[3];
policies[0] = rootPOA
.create_lifespan_policy(
org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = rootPOA
.create_implicit_activation_policy(
org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[2] = rootPOA
.create_id_uniqueness_policy(
org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
POA bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
CorbaDSIServant servant = new CorbaDSIServant(orb, bindingPOA, this, sbeCallback);
byte[] objectId = bindingPOA.activate_object(servant);
obj = bindingPOA.id_to_reference(objectId);
if (location.startsWith("relfile:")) {
String iorFile = location.substring("relfile:".length(), location.length());
// allow for up to 3 '/' to match common uses of relfile url format
for (int n = 0; n < 3; n++) {
if (iorFile.charAt(0) != '/') {
break;
} else {
iorFile = iorFile.substring(1);
}
}
CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
} else if (location.startsWith("file:")) {
String iorFile = location.substring("file:".length(), location.length());
// allow for up to 3 '/' to match common uses of file url format
for (int n = 0; n < 3; n++) {
if (iorFile.charAt(0) != '/') {
break;
} else {
iorFile = iorFile.substring(1);
}
}
// to match the ORB, file must have complete path information, therefore we add
// a '/' prefix to the address
//iorFile = "/" + iorFile;
CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
} else if (location.startsWith("corbaloc")) {
// Try add the key to the boot manager. This is required for a corbaloc
try {
int keyIndex = location.indexOf('/');
String key = location.substring(keyIndex + 1);
org.apache.yoko.orb.OB.BootManager bootManager =
org.apache.yoko.orb.OB.BootManagerHelper.narrow(
orb.resolve_initial_references("BootManager"));
bootManager.add_binding(key.getBytes(), obj);
LOG.info("Added key " + key + " to bootmanager");
} catch (Exception ex) {
// TODO: Continue without for now
}
String ior = orb.object_to_string(obj);
address.setLocation(ior);
String iorFile = "endpoint.ior";
CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
} else {
String ior = orb.object_to_string(obj);
address.setLocation(ior);
String iorFile = "endpoint.ior";
CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
LOG.info("Object Reference: " + orb.object_to_string(obj));
}
// TODO: Provide other export mechanisms?
poaManager.activate();
} catch (Exception ex) {
// TODO: Throw appropriate exception
throw new CorbaBindingException("Unable to active CORBA servant", ex);
}
}