use of org.omg.PortableServer.POA in project ACS by ACS-Community.
the class AcsCorba method getPOAForOffshoots.
/**
* Creates (or reuses) the non-persistent POA for offshoot objects as a child of the given POA.
* In spite of the suggestive name 'componentPOA', this POA can actually be any kind of POA,
* so that also client application can use the offshoot mechanism.
* <p>
* This method is synchronized inside to avoid race conditions between several offshoot POA creation/retrievals,
* where otherwise the POA would fail to be created even though first it was not found for reuse.
*
* @param componentPOA the POA of the component that owns the offshoot object;
* will become the parent of the offshoot POA.
* @return POA non-persistent POA for offshoot objects for the current component.
*
* @throws AcsJContainerServicesEx
*/
public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
final String offshootPoaName = "offshootPoa";
POA offshootPoa = null;
synchronized (componentPOA) {
try {
// can we reuse it?
offshootPoa = componentPOA.find_POA(offshootPoaName, false);
} catch (AdapterNonExistent e) {
m_logger.finest("will have to create offshoot POA");
if (m_offshootPolicies == null) {
m_offshootPolicies = new Policy[4];
m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
}
try {
offshootPoa = componentPOA.create_POA(offshootPoaName, sharedPoaManager, m_offshootPolicies);
m_logger.finest("successfully created offshoot POA");
} catch (InvalidPolicy ex) {
AcsJContainerEx ex2 = new AcsJContainerEx(ex);
ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
throw ex2;
} catch (AdapterAlreadyExists ex) {
// we sync on componentPOA, so this should never happen
throw new AcsJUnexpectedExceptionEx(ex);
}
}
}
return offshootPoa;
}
use of org.omg.PortableServer.POA in project ACS by ACS-Community.
the class ACSRemoteAccess method initialize.
/**
* Initialize the connection.
*
* @param theORB The ORB.
* If it is null then a new CORBA connection is initialized.
* @param manager A reference to the Manager
* If it is null a reference is built by reading the properties.
*/
public void initialize(ORB theORB, Manager manager) {
isExternalORB = (theORB != null);
this.orb = theORB;
if (orb == null) {
listenersDispatcher.publishReport("Initializing CORBA...");
// ORB stanza
java.util.Properties orbprops = java.lang.System.getProperties();
orb = 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 poaManager = rootPOA.the_POAManager();
try {
poaManager.activate();
} catch (Exception e) {
throw new IllegalStateException("POAManager activation failed." + e);
}
// setup ORB profiling
try {
if (orb instanceof AcsProfilingORB) {
AcsORBProfiler profiler = new AcsORBProfilerImplBase(logger);
((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
logger.finer("Orb profiling set up, using class " + AcsORBProfilerImplBase.class.getName());
}
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
}
// end of CORBA stanza
listenersDispatcher.publishReport("CORBA initialized.");
}
Manager maciManager = manager;
if (maciManager == null) {
maciManager = resolveManagerReference();
if (maciManager == null) {
// HSO: Ale, should this not throw an exception?
return;
}
}
NamingContext namingContext = resolveNamingServiceContext(maciManager);
if (namingContext == null) {
return;
}
if (!resolveNotifyChannel(LOGGING_XML_CHANNEL, namingContext)) {
return;
}
boolean isConsumerAdminCreated = createConsumerAdmin();
if (!isConsumerAdminCreated) {
return;
}
isInitialized = createStructuredPushConsumer();
}
use of org.omg.PortableServer.POA in project ACS by ACS-Community.
the class BlockingPingClient 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.");
}
Aggregations