1 23 24 package com.sun.enterprise.iiop; 25 26 import org.omg.CORBA.Any ; 27 import org.omg.CORBA.ORB ; 28 import org.omg.CORBA.INV_POLICY ; 29 import org.omg.CORBA.INTERNAL ; 30 import org.omg.IOP.Codec ; 31 import org.omg.IOP.Encoding ; 32 import org.omg.IOP.TaggedComponent ; 33 import org.omg.PortableInterceptor.IORInfo ; 34 35 import com.sun.corba.ee.impl.util.SUNVMCID; 36 import com.sun.corba.ee.spi.legacy.connection.ORBSocketFactory; 37 import com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt; 38 import com.sun.corba.ee.impl.interceptors.IORInfoImpl; 39 40 import java.util.logging.*; 41 import com.sun.logging.*; 42 43 public class RequestDispatchInfoInterceptor extends org.omg.CORBA.LocalObject 44 implements org.omg.PortableInterceptor.IORInterceptor { 45 46 public static final int TAG_REQUEST_DISPATCH_INFO_ID = SUNVMCID.value + 30; 47 48 public static final String baseMsg = RequestDispatchInfoInterceptor.class.getName(); 49 private static Logger _logger=null; 50 static { 51 _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER); 52 } 53 54 private Codec codec; 55 56 57 58 public RequestDispatchInfoInterceptor(Codec c) { 59 codec = c; 60 } 61 62 63 80 public void destroy() { 81 } 82 83 104 public void establish_components(org.omg.PortableInterceptor.IORInfo iorInfo) { 105 try { 106 RequestDispatchPolicy rdPolicy = null; 107 try { 108 rdPolicy = (RequestDispatchPolicy)iorInfo.get_effective_policy( 109 POARemoteReferenceFactory.REQUEST_DISPATCH_POLICY_TYPE); 110 } catch ( INV_POLICY ex ) {return;} 111 112 if ( rdPolicy != null ) { 113 addDispatchInfoComponent(rdPolicy, iorInfo); 114 } 115 } catch (Exception e) { 116 _logger.log(Level.WARNING,"Exception in " + baseMsg, e); 117 } 118 } 119 120 132 public String name() { 133 return baseMsg; 134 } 135 136 137 private void addDispatchInfoComponent(RequestDispatchPolicy policy, 138 org.omg.PortableInterceptor.IORInfo iorInfo) 139 { 140 Any any = ORB.init().create_any(); 141 any.insert_long(policy.getDispatchId()); 142 143 byte[] dispatchValue = null; 144 try { 145 dispatchValue = codec.encode_value(any); 146 } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding e) { 147 throw new INTERNAL ("InvalidTypeForEncoding "+e.getMessage()); 148 } 149 TaggedComponent taggedComponent = new TaggedComponent ( 150 TAG_REQUEST_DISPATCH_INFO_ID, 151 dispatchValue); 152 iorInfo.add_ior_component(taggedComponent); 153 } 154 155 } 156 | Popular Tags |