1 20 21 package org.jacorb.orb.giop; 22 23 import org.omg.CORBA.Policy ; 24 import org.omg.CORBA.Any ; 25 import org.omg.CORBA.PolicyError ; 26 import org.omg.CORBA.BAD_POLICY ; 27 import org.omg.CORBA.BAD_POLICY_VALUE ; 28 import org.omg.CORBA.LocalObject ; 29 30 import org.omg.PortableInterceptor.PolicyFactory ; 31 import org.omg.BiDirPolicy.*; 32 33 34 43 44 public class BiDirPolicyFactory 45 extends org.omg.CORBA.LocalObject 46 implements PolicyFactory 47 { 48 public BiDirPolicyFactory () 49 { 50 } 51 52 public Policy create_policy( int type, Any any ) 53 throws PolicyError 54 { 55 if( type != BIDIRECTIONAL_POLICY_TYPE.value ) 56 { 57 throw new PolicyError ("Invalid policy type of " + type, 58 BAD_POLICY.value ); 59 } 60 61 short value = BidirectionalPolicyValueHelper.extract( any ); 62 63 if( value != NORMAL.value && 64 value != BOTH.value ) 65 { 66 throw new PolicyError ("Invalid value for BiDir policy of " + value, 67 BAD_POLICY_VALUE.value); 68 } 69 70 return new BiDirPolicy( value ); 71 } 72 } 73 74 75 76 77 78 79 | Popular Tags |