Search in sources :

Example 1 with PolicyManager

use of org.omg.CORBA.PolicyManager in project ACS by ACS-Community.

the class AcsCorba method setORBLevelRoundtripTimeout.

/**
	 * Sets the roundtrip timeout for all calls going out through the ORB that is encapsulated by this class.
	 * For example, this applies to all corba calls made by a container and any of its components.
	 * @param timeoutSeconds
	 * @throws AcsJContainerServicesEx
	 * @see {@link #wrapForRoundtripTimeout(Object, double)}
	 */
public void setORBLevelRoundtripTimeout(double timeoutSeconds) throws AcsJContainerServicesEx {
    if (!isInitialized()) {
        throw new IllegalStateException("Only call when this object has been initialized!");
    }
    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);
        // about PolicyManager, see Corba spec (2.4) section 4.9.1
        PolicyManager pm = PolicyManagerHelper.narrow(m_orb.resolve_initial_references("ORBPolicyManager"));
        pm.set_policy_overrides(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
        p.destroy();
    } catch (Throwable thr) {
        AcsJContainerServicesEx ex2 = new AcsJContainerServicesEx(thr);
        ex2.setContextInfo("Failed to set the ORB-level client-side corba roundtrip timeout to " + timeoutSeconds);
        throw ex2;
    }
    m_logger.fine("Set ORB level roundtrip timeout to " + timeoutSeconds + " seconds.");
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) PolicyManager(org.omg.CORBA.PolicyManager) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) Any(org.omg.CORBA.Any)

Aggregations

AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 Any (org.omg.CORBA.Any)1 Policy (org.omg.CORBA.Policy)1 PolicyManager (org.omg.CORBA.PolicyManager)1 InvalidPolicy (org.omg.PortableServer.POAPackage.InvalidPolicy)1