1 22 package org.jboss.iiop.codebase; 23 24 import org.omg.CORBA.Any ; 25 import org.omg.CORBA.LocalObject ; 26 import org.omg.CORBA.ORB ; 27 import org.omg.IOP.Codec ; 28 import org.omg.IOP.CodecPackage.InvalidTypeForEncoding ; 29 import org.omg.IOP.TAG_JAVA_CODEBASE ; 30 import org.omg.IOP.TaggedComponent ; 31 import org.omg.PortableInterceptor.IORInfo ; 32 import org.omg.PortableInterceptor.IORInterceptor ; 33 34 41 public class CodebaseInterceptor 42 extends LocalObject 43 implements IORInterceptor 44 { 45 private Codec codec; 46 47 public CodebaseInterceptor(Codec codec) 48 { 49 this.codec = codec; 50 } 51 52 54 public String name() 55 { 56 return CodebaseInterceptor.class.getName(); 57 } 58 59 public void destroy() 60 { 61 } 62 63 public void establish_components(IORInfo info) 64 { 65 CodebasePolicy codebasePolicy= 67 (CodebasePolicy)info.get_effective_policy(CodebasePolicy.TYPE); 68 69 if (codebasePolicy != null) { 70 String codebase = codebasePolicy.getCodebase(); 72 73 Any any = ORB.init().create_any(); 75 any.insert_string(codebase); 76 byte[] taggedComponentData; 77 try { 78 taggedComponentData = codec.encode_value(any); 79 } 80 catch (InvalidTypeForEncoding e) { 81 throw new RuntimeException ("Exception establishing " + 82 "Java codebase component:" + e); 83 } 84 info.add_ior_component(new TaggedComponent (TAG_JAVA_CODEBASE.value, 85 taggedComponentData)); 86 } 87 } 88 89 } 90 | Popular Tags |