use of org.omg.CORBA.Policy in project ACS by ACS-Community.
the class AcsCorba method initPOAForContainer.
private void initPOAForContainer() throws AcsJContainerEx {
if (m_containerPOA != null) {
return;
}
Policy[] contPolicies = null;
try {
contPolicies = new Policy[4];
contPolicies[0] = m_rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
contPolicies[1] = m_rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
contPolicies[2] = m_rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
contPolicies[3] = m_rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
m_containerPOA = m_rootPOA.create_POA("ContainerPOA", sharedPoaManager, contPolicies);
if (m_containerPOA == null) {
throw new NullPointerException("ContainerPOA reference == null");
}
m_logger.finest("ContainerPOA created.");
} catch (Throwable thr) {
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo("ContainerPOA creation failed");
throw ex;
} finally {
if (contPolicies != null) {
for (Policy policy : contPolicies) {
if (policy != null) {
policy.destroy();
}
}
}
}
}
use of org.omg.CORBA.Policy in project ACS by ACS-Community.
the class AcsCorba method wrapForRoundtripTimeout.
/**
* <p>
* Impl note: The corba spec (v 2.4, 4.3.8.1) describes the difference between
* SetOverrideType.SET_OVERRIDE and SetOverrideType.ADD_OVERRIDE. It is not clear to me (HSO)
* which one should be used, or if there is no practical difference.
* @param corbaRef
* @param timeoutSeconds
* @return
* @throws AcsJContainerServicesEx
* @see {@link #setORBLevelRoundtripTimeout(double)}
*/
public org.omg.CORBA.Object wrapForRoundtripTimeout(org.omg.CORBA.Object corbaRef, double timeoutSeconds) throws AcsJContainerServicesEx {
if (!isInitialized()) {
throw new IllegalStateException("Only call when this object has been initialized!");
}
org.omg.CORBA.Object ret = null;
try {
Any rrtPolicyAny = m_orb.create_any();
rrtPolicyAny.insert_ulonglong(UTCUtility.durationJavaMillisToOmg((long) timeoutSeconds * 1000));
Policy p = m_orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value, rrtPolicyAny);
ret = corbaRef._set_policy_override(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
p.destroy();
} catch (Throwable thr) {
AcsJContainerServicesEx ex2 = new AcsJContainerServicesEx(thr);
ex2.setContextInfo("Failed to set the object-level client-side corba roundtrip timeout to " + timeoutSeconds);
throw ex2;
}
return ret;
}
use of org.omg.CORBA.Policy 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;
}
Aggregations