1 23 24 28 29 package com.sun.jts.pi; 30 31 import org.omg.CORBA.Any ; 32 import org.omg.CORBA.Policy ; 33 import org.omg.CORBA.PolicyError ; 34 import org.omg.CORBA.LocalObject ; 35 36 import org.omg.CosTransactions.SHARED; 37 import org.omg.CosTransactions.UNSHARED; 38 import org.omg.CosTransactions.EITHER; 39 import org.omg.CosTransactions.INVOCATION_POLICY_TYPE; 40 import org.omg.CosTransactions.InvocationPolicyValueHelper; 41 42 import org.omg.PortableInterceptor.PolicyFactory ; 43 44 50 public class InvocationPolicyFactory 51 extends LocalObject implements PolicyFactory { 52 53 public InvocationPolicyFactory() {} 54 55 public Policy create_policy(int type, Any value) throws PolicyError { 56 57 if (type != INVOCATION_POLICY_TYPE.value) { 58 throw new PolicyError ("Invalid InvocationPolicyType", (short) 0); 59 } 60 61 short policyValue = InvocationPolicyValueHelper.extract(value); 62 63 switch (policyValue) { 64 case SHARED.value : 65 case UNSHARED.value : 66 case EITHER.value : 67 break; 68 default : 69 throw new PolicyError ("Invalid InvocationPolicyValue", (short) 1); 70 } 71 72 return new InvocationPolicyImpl(policyValue); 73 } 74 } 75 76 | Popular Tags |