1 23 24 28 29 package com.sun.jts.pi; 30 31 import org.omg.IOP.Codec ; 32 import org.omg.IOP.TaggedComponent ; 33 import org.omg.IOP.CodecPackage.InvalidTypeForEncoding ; 34 35 import org.omg.CORBA.ORB ; 36 import org.omg.CORBA.Any ; 37 import org.omg.CORBA.LocalObject ; 38 import org.omg.CORBA.INV_POLICY ; 39 import org.omg.CORBA.INTERNAL ; 40 41 import org.omg.CosTransactions.*; 42 43 import org.omg.CosTSInteroperation.TAG_OTS_POLICY; 44 import org.omg.CosTSInteroperation.TAG_INV_POLICY; 45 46 import org.omg.PortableInterceptor.IORInfo ; 47 import org.omg.PortableInterceptor.IORInterceptor ; 48 49 58 public class IORInterceptorImpl extends LocalObject implements IORInterceptor { 59 60 62 private static final String name = "com.sun.jts.pi.IORInterceptor"; 63 64 66 private Codec codec = null; 67 68 public IORInterceptorImpl(Codec codec) { 69 this.codec = codec; 70 } 71 72 74 public void establish_components (IORInfo info) { 75 76 78 OTSPolicy otsPolicy = null; 79 80 try { 81 otsPolicy = (OTSPolicy) 82 info.get_effective_policy(OTS_POLICY_TYPE.value); 83 } catch (INV_POLICY e) { 84 } 87 88 InvocationPolicy invPolicy = null; 89 try { 90 invPolicy = (InvocationPolicy) 91 info.get_effective_policy(INVOCATION_POLICY_TYPE.value); 92 } catch (INV_POLICY e) { 93 } 96 97 99 short otsPolicyValue = FORBIDS.value; short invPolicyValue = EITHER.value; 102 if (otsPolicy != null) { 103 otsPolicyValue = otsPolicy.value(); 104 } 105 106 if (invPolicy != null) { 107 invPolicyValue = invPolicy.value(); 108 } 109 110 112 Any otsAny = ORB.init().create_any(); 113 Any invAny = ORB.init().create_any(); 114 115 otsAny.insert_short(otsPolicyValue); 116 invAny.insert_short(invPolicyValue); 117 118 byte[] otsCompValue = null; 119 byte[] invCompValue = null; 120 try { 121 otsCompValue = this.codec.encode_value(otsAny); 122 invCompValue = this.codec.encode_value(invAny); 123 } catch (InvalidTypeForEncoding e) { 124 throw new INTERNAL (); 125 } 126 127 129 TaggedComponent otsComp = new TaggedComponent (TAG_OTS_POLICY.value, 130 otsCompValue); 131 TaggedComponent invComp = new TaggedComponent (TAG_INV_POLICY.value, 132 invCompValue); 133 134 136 info.add_ior_component(otsComp); 137 info.add_ior_component(invComp); 138 } 139 140 142 public String name(){ 143 return IORInterceptorImpl.name; 144 } 145 146 public void destroy() {} 147 } 148 149 150 | Popular Tags |