1 7 8 package com.sun.corba.se.impl.interceptors; 9 10 import org.omg.IOP.Codec ; 11 import org.omg.IOP.CodecFactory ; 12 import org.omg.IOP.CodecFactoryPackage.UnknownEncoding ; 13 import org.omg.IOP.Encoding ; 14 import org.omg.IOP.ENCODING_CDR_ENCAPS ; 15 16 import com.sun.corba.se.spi.logging.CORBALogDomains; 17 18 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 19 20 import org.omg.CORBA.ORB ; 21 import org.omg.CORBA.LocalObject ; 22 23 27 public final class CodecFactoryImpl 28 extends org.omg.CORBA.LocalObject 29 implements CodecFactory 30 { 31 private ORB orb; 33 private ORBUtilSystemException wrapper ; 34 35 private static final int MAX_MINOR_VERSION_SUPPORTED = 2; 38 39 private Codec codecs[] = new Codec [MAX_MINOR_VERSION_SUPPORTED + 1]; 42 43 47 public CodecFactoryImpl( ORB orb ) { 48 this.orb = orb; 49 wrapper = ORBUtilSystemException.get( 50 (com.sun.corba.se.spi.orb.ORB)orb, 51 CORBALogDomains.RPC_PROTOCOL ) ; 52 53 for( int minor = 0; minor <= MAX_MINOR_VERSION_SUPPORTED; minor++ ) { 59 codecs[minor] = new CDREncapsCodec( orb, 1, minor ); 60 } 61 } 62 63 71 public Codec create_codec ( Encoding enc ) 72 throws UnknownEncoding 73 { 74 if( enc == null ) nullParam(); 75 76 Codec result = null; 77 78 if( (enc.format == ENCODING_CDR_ENCAPS.value) && 80 (enc.major_version == 1) ) 81 { 82 if( (enc.minor_version >= 0) && 83 (enc.minor_version <= MAX_MINOR_VERSION_SUPPORTED) ) 84 { 85 result = codecs[enc.minor_version]; 86 } 87 } 88 89 if( result == null ) { 90 throw new UnknownEncoding (); 91 } 92 93 return result; 94 } 95 96 100 private void nullParam() 101 { 102 throw wrapper.nullParam() ; 103 } 104 } 105 | Popular Tags |