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 import org.omg.CosTransactions.REQUIRES; 36 import org.omg.CosTransactions.ADAPTS; 37 import org.omg.CosTransactions.FORBIDS; 38 import org.omg.CosTransactions.OTS_POLICY_TYPE; 39 import org.omg.CosTransactions.OTSPolicyValueHelper; 40 import org.omg.PortableInterceptor.PolicyFactory ; 41 42 48 public class OTSPolicyFactory extends LocalObject implements PolicyFactory { 49 50 public OTSPolicyFactory() {} 51 52 public Policy create_policy(int type, Any value) throws PolicyError { 53 54 if (type != OTS_POLICY_TYPE.value) { 55 throw new PolicyError ("Invalid OTSPolicyType", (short) 0); 56 } 57 58 short policyValue = OTSPolicyValueHelper.extract(value); 59 60 switch (policyValue) { 61 case REQUIRES.value : 62 case ADAPTS.value : 63 case FORBIDS.value : 64 break; 65 default : 66 throw new PolicyError ("Invalid OTSPolicyValue", (short) 1); 67 } 68 69 return new OTSPolicyImpl(policyValue); 70 } 71 } 72 73 | Popular Tags |