1 23 24 28 29 package com.sun.jts.pi; 30 31 import org.omg.IOP.*; 32 import org.omg.IOP.CodecFactoryPackage.UnknownEncoding ; 33 34 import org.omg.CORBA.*; 35 36 import org.omg.CosTransactions.OTS_POLICY_TYPE; 37 import org.omg.CosTransactions.INVOCATION_POLICY_TYPE; 38 39 import org.omg.PortableInterceptor.Current ; 40 import org.omg.PortableInterceptor.*; 41 import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName ; 43 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ; 44 45 import com.sun.jts.CosTransactions.MinorCode; 46 47 55 public class ORBInitializerImpl extends LocalObject implements ORBInitializer { 56 57 public ORBInitializerImpl() {} 58 59 public void pre_init(ORBInitInfo info) {} 60 61 public void post_init(ORBInitInfo info) { 62 63 65 CodecFactory codecFactory = info.codec_factory(); 66 Encoding enc = new Encoding ( 67 ENCODING_CDR_ENCAPS.value, (byte) 1, (byte) 2); 68 Codec codec = null; 69 try { 70 codec = codecFactory.create_codec(enc); 71 } catch (UnknownEncoding e) { 72 throw new INTERNAL(MinorCode.TSCreateFailed, 73 CompletionStatus.COMPLETED_NO); 74 } 75 76 78 Current pic = null; 79 try { 80 pic = (Current ) info.resolve_initial_references("PICurrent"); 81 } catch (InvalidName e) { 82 throw new INTERNAL(MinorCode.TSCreateFailed, 83 CompletionStatus.COMPLETED_NO); 84 } 85 86 88 int[] slotIds = new int[2]; 89 try { 90 slotIds[0] = info.allocate_slot_id(); 91 slotIds[1] = info.allocate_slot_id(); 92 } catch (BAD_INV_ORDER e) { 93 throw new INTERNAL(MinorCode.TSCreateFailed, 94 CompletionStatus.COMPLETED_NO); 95 } 96 97 99 TSIdentification tsi = null; 100 try { 101 tsi = (TSIdentification) 102 info.resolve_initial_references("TSIdentification"); 103 } catch (InvalidName e) { 104 } 106 107 109 try { 110 info.register_policy_factory(OTS_POLICY_TYPE.value, 111 new OTSPolicyFactory()); 112 } catch (BAD_INV_ORDER e) { 113 } 115 116 try { 117 info.register_policy_factory(INVOCATION_POLICY_TYPE.value, 118 new InvocationPolicyFactory()); 119 } catch (BAD_INV_ORDER e) { 120 } 122 123 125 try { 126 info.add_ior_interceptor(new IORInterceptorImpl(codec)); 127 InterceptorImpl interceptor = 128 new InterceptorImpl(pic, codec, slotIds, tsi); 129 info.add_client_request_interceptor(interceptor); 130 info.add_server_request_interceptor(interceptor); 131 } catch (DuplicateName e) { 132 throw new INTERNAL(MinorCode.TSCreateFailed, 133 CompletionStatus.COMPLETED_NO); 134 } 135 } 136 } 137 | Popular Tags |