KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > component > ComponentParameters


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2004 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.core.component;
32
33 import org.apache.log4j.Logger;
34
35 import org.objectweb.fractal.api.type.ComponentType;
36 import org.objectweb.fractal.api.type.InterfaceType;
37
38 import org.objectweb.proactive.core.component.type.ProActiveComponentType;
39
40 import java.io.Serializable JavaDoc;
41
42 import java.util.Vector JavaDoc;
43
44
45 /** Contains the configuration of a component :
46  * - type
47  * - interfaces (server and client) --> in contained ControllerDescription object
48  * - name --> in contained ControllerDescription object
49  * - hierarchical type (primitive or composite) --> in contained ControllerDescription object
50  * - a ref on the stub on the base object
51  */

52 public class ComponentParameters implements Serializable JavaDoc {
53     protected static Logger logger = Logger.getLogger(ComponentParameters.class.getName());
54
55     private Object JavaDoc stubOnReifiedObject;
56     private ComponentType componentType;
57     private ControllerDescription controllerDesc;
58
59     /** Constructor for ComponentParameters.
60      * @param name the name of the component
61      * @param hierarchicalType the hierarchical type, either PRIMITIVE or COMPOSITE or PARALLEL
62      * @param componentType
63      */

64     public ComponentParameters(String JavaDoc name, String JavaDoc hierarchicalType,
65         ComponentType componentType) {
66         this(componentType, new ControllerDescription(name, hierarchicalType));
67     }
68
69     /**
70      * Constructor
71      * @param componentType the type of the component
72      * @param controllerDesc a ControllerDescription object
73      */

74     public ComponentParameters(ComponentType componentType,
75         ControllerDescription controllerDesc) {
76         this.componentType = componentType;
77         this.controllerDesc = controllerDesc;
78     }
79
80     /**
81      * overrides the clone method of Object
82      * @return a clone of this current object
83      */

84     public Object JavaDoc clone() {
85         return new ComponentParameters(new ProActiveComponentType(componentType),
86             new ControllerDescription(controllerDesc));
87     }
88
89     /**
90      * setter for the name
91      * @param name name of the component
92      */

93     public void setName(String JavaDoc name) {
94         controllerDesc.setName(name);
95     }
96
97     /**
98      * Returns the componentType.
99      * @return ComponentType
100      */

101     public ComponentType getComponentType() {
102         return componentType;
103     }
104
105     /**
106      * getter
107      * @return a ControllerDescription object
108      */

109     public ControllerDescription getControllerDescription() {
110         return controllerDesc;
111     }
112
113     /**
114      * setter
115      * @param componentType the type of the component
116      */

117     public void setComponentType(ComponentType componentType) {
118         this.componentType = componentType;
119     }
120
121     /**
122      * setter
123      * @param string the hierarchical type (primitive, composite or parallel)
124      */

125     public void setHierarchicalType(String JavaDoc string) {
126         controllerDesc.setHierarchicalType(string);
127     }
128
129     /**
130      * getter
131      * @return the name
132      */

133     public String JavaDoc getName() {
134         return controllerDesc.getName();
135     }
136
137     /**
138      * Returns the hierarchicalType.
139      * @return String
140      */

141     public String JavaDoc getHierarchicalType() {
142         return controllerDesc.getHierarchicalType();
143     }
144
145     /**
146      * @return the types of server interfaces
147      */

148     public InterfaceType[] getServerInterfaceTypes() {
149         Vector JavaDoc server_interfaces = new Vector JavaDoc();
150         InterfaceType[] interfaceTypes = componentType.getFcInterfaceTypes();
151         for (int i = 0; i < interfaceTypes.length; i++) {
152             if (!interfaceTypes[i].isFcClientItf()) {
153                 server_interfaces.add(interfaceTypes[i]);
154             }
155         }
156         return (InterfaceType[]) server_interfaces.toArray(new InterfaceType[server_interfaces.size()]);
157     }
158
159     /**
160      * @return the types of client interfacess
161      */

162     public InterfaceType[] getClientInterfaceTypes() {
163         Vector JavaDoc client_interfaces = new Vector JavaDoc();
164         InterfaceType[] interfaceTypes = componentType.getFcInterfaceTypes();
165         for (int i = 0; i < interfaceTypes.length; i++) {
166             if (interfaceTypes[i].isFcClientItf()) {
167                 client_interfaces.add(interfaceTypes[i]);
168             }
169         }
170         return (InterfaceType[]) client_interfaces.toArray(new InterfaceType[client_interfaces.size()]);
171     }
172
173     /**
174      * accessor on the standard ProActive stub
175      * @return standard ProActive stub on the reified object
176      */

177     public Object JavaDoc getStubOnReifiedObject() {
178         return stubOnReifiedObject;
179     }
180
181     /**
182      * keeps a reference on the standard ProActive stub
183      * @param ref on an instance of a standard ProActive stub on the reified object
184      */

185     public void setStubOnReifiedObject(Object JavaDoc object) {
186         stubOnReifiedObject = object;
187     }
188
189     /**
190      * getter
191      * @return a table of interface types
192      */

193     public InterfaceType[] getInterfaceTypes() {
194         return componentType.getFcInterfaceTypes();
195     }
196 }
197
Popular Tags