// get the OTSPolicy and InvocationPolicy objects
OTSPolicy otsPolicy = null;
try {
otsPolicy = (OTSPolicy)
info.get_effective_policy(OTS_POLICY_TYPE.value);
} catch (INV_POLICY e) {
// ignore. This implies an policy was not explicitly set.
// A default value will be used instead.
}
InvocationPolicy invPolicy = null;
try {
invPolicy = (InvocationPolicy)
info.get_effective_policy(INVOCATION_POLICY_TYPE.value);
} catch (INV_POLICY e) {
// ignore. This implies an policy was not explicitly set.
// A default value will be used instead.
}
// get OTSPolicyValue and InvocationPolicyValue from policy objects.
short otsPolicyValue = FORBIDS.value; // default value
short invPolicyValue = EITHER.value; // default value
if (otsPolicy != null) {
otsPolicyValue = otsPolicy.value();
}
if (invPolicy != null) {
invPolicyValue = invPolicy.value();
}
// use codec to encode policy value into an CDR encapsulation.
Any otsAny = ORB.init().create_any();
Any invAny = ORB.init().create_any();
otsAny.insert_short(otsPolicyValue);
invAny.insert_short(invPolicyValue);
byte[] otsCompValue = null;
byte[] invCompValue = null;
try {
otsCompValue = this.codec.encode_value(otsAny);
invCompValue = this.codec.encode_value(invAny);
} catch (InvalidTypeForEncoding e) {
throw new INTERNAL();
}
// create IOR TaggedComponents for OTSPolicy and InvocationPolicy.
TaggedComponent otsComp = new TaggedComponent(TAG_OTS_POLICY.value,
otsCompValue);
TaggedComponent invComp = new TaggedComponent(TAG_INV_POLICY.value,
invCompValue);
// add ior components.
info.add_ior_component(otsComp);
info.add_ior_component(invComp);