// get hold of the codec instance to pass onto interceptors.
CodecFactory codecFactory = info.codec_factory();
Encoding enc = new Encoding(
ENCODING_CDR_ENCAPS.value, (byte) 1, (byte) 2);
Codec codec = null;
try {
codec = codecFactory.create_codec(enc);
} catch (UnknownEncoding e) {
throw new INTERNAL(MinorCode.TSCreateFailed,
CompletionStatus.COMPLETED_NO);
}
// get hold of PICurrent to allocate a slot for JTS service.
Current pic = null;
try {
pic = (Current) info.resolve_initial_references("PICurrent");
} catch (InvalidName e) {
throw new INTERNAL(MinorCode.TSCreateFailed,
CompletionStatus.COMPLETED_NO);
}
// allocate a PICurrent slotId for the transaction service.
int[] slotIds = new int[2];
try {
slotIds[0] = info.allocate_slot_id();
slotIds[1] = info.allocate_slot_id();
} catch (BAD_INV_ORDER e) {
throw new INTERNAL(MinorCode.TSCreateFailed,
CompletionStatus.COMPLETED_NO);
}
// get hold of the TSIdentification instance to pass onto interceptors.
TSIdentification tsi = null;
try {
tsi = (TSIdentification)
info.resolve_initial_references("TSIdentification");
} catch (InvalidName e) {
// the TransactionService is unavailable.
}
// register the policy factories.
try {
info.register_policy_factory(OTS_POLICY_TYPE.value,
new OTSPolicyFactory());
} catch (BAD_INV_ORDER e) {
// ignore, policy factory already exists.
}
try {
info.register_policy_factory(INVOCATION_POLICY_TYPE.value,
new InvocationPolicyFactory());
} catch (BAD_INV_ORDER e) {
// ignore, policy factory already exists.
}
// register the interceptors.
try {
info.add_ior_interceptor(new IORInterceptorImpl(codec));
InterceptorImpl interceptor =
new InterceptorImpl(pic, codec, slotIds, tsi);
info.add_client_request_interceptor(interceptor);
info.add_server_request_interceptor(interceptor);
} catch (DuplicateName e) {
throw new INTERNAL(MinorCode.TSCreateFailed,
CompletionStatus.COMPLETED_NO);
}