KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > giop > BiDirPolicyFactory


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 package org.jacorb.orb.giop;
22
23 import org.omg.CORBA.Policy JavaDoc;
24 import org.omg.CORBA.Any JavaDoc;
25 import org.omg.CORBA.PolicyError JavaDoc;
26 import org.omg.CORBA.BAD_POLICY JavaDoc;
27 import org.omg.CORBA.BAD_POLICY_VALUE JavaDoc;
28 import org.omg.CORBA.LocalObject JavaDoc;
29
30 import org.omg.PortableInterceptor.PolicyFactory JavaDoc;
31 import org.omg.BiDirPolicy.*;
32
33
34 /**
35  * BiDirPolicyFactory.java
36  *
37  *
38  * Created: Mon Sep 3 18:32:16 2002
39  *
40  * @author Nicolas Noffke
41  * @version $Id: BiDirPolicyFactory.java,v 1.8 2004/05/06 12:40:00 nicolas Exp $
42  */

43
44 public class BiDirPolicyFactory
45     extends org.omg.CORBA.LocalObject JavaDoc
46     implements PolicyFactory JavaDoc
47 {
48     public BiDirPolicyFactory ()
49     {
50     }
51
52     public Policy JavaDoc create_policy( int type, Any JavaDoc any )
53         throws PolicyError JavaDoc
54     {
55         if( type != BIDIRECTIONAL_POLICY_TYPE.value )
56         {
57             throw new PolicyError JavaDoc("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 JavaDoc("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