KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > util > csiv2 > SasPolicyFactory


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: SasPolicyFactory.java,v 1.1 2004/12/13 16:24:13 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.carol.util.csiv2;
26
27 import org.omg.CORBA.Any JavaDoc;
28 import org.omg.CORBA.Policy JavaDoc;
29 import org.omg.CORBA.PolicyError JavaDoc;
30 import org.omg.PortableInterceptor.PolicyFactory JavaDoc;
31
32 /**
33  * Make csiv2 policy objects
34  * @author Florent Benoit
35  */

36 public class SasPolicyFactory extends org.omg.CORBA.LocalObject JavaDoc implements PolicyFactory JavaDoc {
37
38     /**
39      * Default constructor
40      */

41     public SasPolicyFactory() {
42     }
43
44     /**
45      * Returns an instance of the appropriate interface derived from
46      * <code>CORBA.Policy</code> whose value corresponds to the specified any.
47      * @param type An int specifying the type of policy being created.
48      * @param value An any containing data with which to construct the
49      * <code>CORBA.Policy</code>.
50      * @return A <code>CORBA.Policy<code> object of the specified type and
51      * value.
52      * @throws PolicyError if the policy type is invalid
53      */

54     public Policy JavaDoc create_policy(int type, Any JavaDoc value) throws PolicyError JavaDoc {
55         // Can create only known policy objects
56
if (type != SasPolicy.POLICY_TYPE) {
57             throw new PolicyError JavaDoc();
58         }
59
60         // Get component stored
61
SasComponent sasComponent = (SasComponent) value.extract_Value();
62
63         // build a new policy object
64
return new SasPolicy(sasComponent);
65
66     }
67 }
68
69
Popular Tags