use of org.omg.PortableServer.POAManager in project ACS by ACS-Community.
the class ManagerImplSerializationTest method testClientDie.
public void testClientDie() {
// should be something else then deafault because
// the default is in use by the Manager
Properties table = new Properties();
table.put("OAPort", "12121");
// new ORB instance
ORB ourOrb = ORB.init(new String[0], table);
try {
POA rootPOA = POAHelper.narrow(ourOrb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
} catch (Exception e) {
e.printStackTrace();
}
ClientProxyImpl client = new ClientProxyImpl(clientName, myManager.getManagerEngine().getLogger());
client.login(ourOrb, manager);
// just destroy its ORB
ourOrb.shutdown(true);
// get object as it is stored in recovery store
ManagerImpl newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
HandleDataStore clients = newManager.getClients();
// the client now is still in stored data
assertEquals(clients.first(), 1);
newManager.initialize(null, null, null, null, null);
// now wait for timer task to remove client
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
// since the client died the menager automaticaly log it out
clients = newManager.getClients();
// not any more
assertEquals(clients.first(), 0);
}
use of org.omg.PortableServer.POAManager in project ACS by ACS-Community.
the class DefaultCORBAService method internalInitialize.
/**
* Initializes the CORBA.
*/
private void internalInitialize() {
// ORB stanza
Properties orbprops = System.getProperties();
Properties serviceConfig = new Properties();
serviceConfig.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
serviceConfig.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
serviceConfig.put("jacorb.implname", "ORB");
serviceConfig.put("jacorb.orb.objectKeyMap.Manager", "ORB/ManagerPOA/Manager");
serviceConfig.put("jacorb.verbosity", "1");
serviceConfig.put("org.omg.PortableInterceptor.ORBInitializerClass.bidir_init", "org.jacorb.orb.giop.BiDirConnectionInitializer");
// add additional properties
if (serviceConfig != null)
orbprops.putAll(serviceConfig);
orb = ORB.init(new String[0], orbprops);
// POA stanza, use rootPOA
try {
// resolve RootPOA
rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
} catch (Throwable th) {
logger.log(Level.SEVERE, "Failed to initialize CORBA.", th);
}
// spawn ORB thread (to process incoming requests)
new Thread(this, "DefaultCORBAService").start();
}
use of org.omg.PortableServer.POAManager in project ACS by ACS-Community.
the class ManagerDynComponentTest method initializeCORBA.
/**
* Initializes CORBA.
*/
private void initializeCORBA() {
System.out.println("Initializing CORBA...");
// ORB stanza
java.util.Properties orbprops = java.lang.System.getProperties();
// to make code completely independed, properties have to be set using JVM -D mechanism
// ORBacus
//orbprops.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
//orbprops.put("org.omg.CORBA.ORBSingletonClass", "com.ooc.CORBA.ORBSingleton");
// JacORB
//orbprops.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
//orbprops.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
// Java JDK (none)
orb = org.omg.CORBA.ORB.init(new String[0], orbprops);
// POA stanza -- use RootPOA
POA rootPOA = null;
try {
rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
} catch (org.omg.CORBA.ORBPackage.InvalidName in) {
throw new IllegalStateException("Cannot resolve RootPOA: " + in);
}
POAManager manager = rootPOA.the_POAManager();
try {
// activate POA
manager.activate();
// start CORBA event-handler thread
orbThread = new Thread(this);
orbThread.start();
} catch (Exception e) {
throw new IllegalStateException("POAManager activation failed: " + e);
}
System.out.println("CORBA initialized.");
}
use of org.omg.PortableServer.POAManager in project cxf by apache.
the class CorbaDestination method activate.
public void activate() {
java.util.Properties props = new java.util.Properties();
Properties configSpecifiedOrbProperties = orbConfig.getOrbProperties();
props.putAll(configSpecifiedOrbProperties);
if (orbConfig.getOrbClass() != null) {
props.put("org.omg.CORBA.ORBClass", orbConfig.getOrbClass());
}
if (orbConfig.getOrbSingletonClass() != null) {
props.put("org.omg.CORBA.ORBSingletonClass", orbConfig.getOrbSingletonClass());
}
String location = getDestinationAddress();
if (!CorbaUtils.isValidURL(location)) {
throw new CorbaBindingException("Invalid addressing specified for CORBA port location");
}
LOG.info("Service address retrieved: " + location);
URI addressURI = null;
try {
addressURI = new URI(location);
} catch (java.net.URISyntaxException ex) {
throw new CorbaBindingException("Unable to create ORB with address " + address);
}
List<String> orbArgs = new ArrayList<>(orbConfig.getOrbArgs());
String scheme = addressURI.getScheme();
// host and port used when no preference has been specified.
if (poaName != null) {
poaName = poaName.replace('.', '_');
}
if ("corbaloc".equals(scheme)) {
if (poaName == null) {
poaName = getEndPointInfo().getName().getLocalPart().replace('.', '_');
}
setCorbaLocArgs(addressURI, orbArgs);
} else if ("corbaname".equals(scheme)) {
int idx = location.indexOf("#");
if (idx != -1) {
serviceId = location.substring(idx + 1);
}
}
if (isPersistent) {
if (poaName == null) {
throw new CorbaBindingException("POA name missing for corba port " + "with a persistent policy");
}
} else {
poaName = CorbaUtils.getUniquePOAName(getEndPointInfo().getService().getName(), getEndPointInfo().getName().getLocalPart(), poaName).replace('.', '_');
}
orb = getORB(orbArgs, location, props);
try {
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
POAManager poaManager = rootPOA.the_POAManager();
try {
bindingPOA = rootPOA.find_POA(poaName, false);
} catch (org.omg.PortableServer.POAPackage.AdapterNonExistent ex) {
// do nothing
}
// an activate two objects with the same servant ID instead.
if (bindingPOA != null && !isPersistent && serviceId == null) {
throw new CorbaBindingException("Corba Port activation failed because the poa " + poaName + " already exists");
} else if (bindingPOA == null) {
bindingPOA = createPOA(poaName, rootPOA, poaManager);
}
if (bindingPOA == null) {
throw new CorbaBindingException("Unable to create CXF CORBA Binding POA");
}
CorbaDSIServant servant = new CorbaDSIServant();
servant.init(orb, bindingPOA, this, incomingObserver, typeMap);
if (serviceId != null) {
objectId = serviceId.getBytes();
try {
bindingPOA.activate_object_with_id(objectId, servant);
} catch (org.omg.PortableServer.POAPackage.ObjectAlreadyActive ex) {
if (!isPersistent) {
throw new CorbaBindingException("Object " + serviceId + " already active for non-persistent poa");
}
}
} else {
objectId = bindingPOA.activate_object(servant);
}
bindingPOA.set_servant(servant);
obj = bindingPOA.id_to_reference(objectId);
orbConfig.exportObjectReference(orb, obj, location, address);
populateEpr(orb.object_to_string(obj));
LOG.info("Object Reference: " + orb.object_to_string(obj));
poaManager.activate();
} catch (Exception ex) {
throw new CorbaBindingException("Unable to activate CORBA servant", ex);
}
}
use of org.omg.PortableServer.POAManager in project ACS by ACS-Community.
the class PropertySeqTest method initCORBA.
/**
* Initialize CORBA.
*/
private void initCORBA() throws Exception {
orb = ORB.init(new String[0], System.getProperties());
// POA stanza, use rootPOA
try {
// resolve RootPOA
rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
// spawn ORB thread
new Thread(new Runnable() {
public void run() {
orb.run();
}
}, "CORBA").start();
} catch (Exception e) {
throw e;
}
}
Aggregations