KickJava   Java API By Example, From Geeks To Geeks.

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


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.objectweb.proactive.Active;
34 import org.objectweb.proactive.core.body.MetaObjectFactory;
35 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
36 import org.objectweb.proactive.core.node.Node;
37
38
39 /**
40  * Fractal implementation-specific description of the content of components.
41  * With ProActive, features such as activity, factory, virtual node or constructor parameters
42  * can be specified.
43  *
44  * @author Matthieu Morel
45  */

46 public class ContentDescription {
47     private String JavaDoc className;
48     private Object JavaDoc[] constructorParameters;
49     private Active activity;
50     private MetaObjectFactory factory;
51     private VirtualNode virtualNode = null;
52     private Node node = null;
53
54     /**
55      * constructor
56      * @param className the name of the base class of the component
57      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
58      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
59      * @param constructorParameters parameters of the constructor of the base class
60      * @param virtualNode virtual node where this component will be instantiated
61      * @param activity the activity as defined in the ProActive model
62      * @param factory overriden meta-object factory for the component. Can be null.
63      */

64     public ContentDescription(String JavaDoc className, Object JavaDoc[] constructorParameters,
65         VirtualNode virtualNode, Active activity, MetaObjectFactory factory) {
66         this.className = className;
67         this.constructorParameters = constructorParameters;
68         this.virtualNode = virtualNode;
69         this.activity = activity;
70         this.factory = factory;
71     }
72
73     /**
74      * constructor
75      * @param className the name of the base class of the component
76      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
77      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
78      * @param constructorParameters parameters of the constructor of the base class
79      * @param node node where this component will be instantiated
80      * @param activity the activity as defined in the ProActive model
81      * @param factory overriden meta-object factory for the component. Can be null.
82      */

83     public ContentDescription(String JavaDoc className, Object JavaDoc[] constructorParameters,
84         Node node, Active activity, MetaObjectFactory factory) {
85         this.className = className;
86         this.constructorParameters = constructorParameters;
87         this.node = node;
88         this.activity = activity;
89         this.factory = factory;
90     }
91
92     /**
93      * constructor
94      * @param className the name of the base class of the component
95      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
96      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
97      * @param constructorParameters parameters of the constructor of the base class
98      */

99     public ContentDescription(String JavaDoc className, Object JavaDoc[] constructorParameters) {
100         this(className, constructorParameters, (Node) null, null, null);
101     }
102
103     /**
104      * constructor
105      * @param className the name of the base class of the component
106      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
107      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
108      * @param constructorParameters parameters of the constructor of the base class
109      * @param virtualNode virtual node where this component will be instantiated
110      */

111     public ContentDescription(String JavaDoc className, Object JavaDoc[] constructorParameters,
112         VirtualNode virtualNode) {
113         this(className, constructorParameters, virtualNode, null, null);
114     }
115
116     /**
117      * constructor
118      * @param className the name of the base class of the component
119      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
120      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
121      * @param constructorParameters parameters of the constructor of the base class
122      * @param node node where this component will be instantiated
123      */

124     public ContentDescription(String JavaDoc className, Object JavaDoc[] constructorParameters,
125         Node node) {
126         this(className, constructorParameters, node, null, null);
127     }
128
129     /**
130      * constructor. As no node nor virtual node is specified, the component will be instantiated in the
131      * current virtual machine
132      * @param className the name of the base class of the component
133      * If the component is a composite component, this class is by default {@link org.objectweb.proactive.core.component.type.Composite}
134      * If the component is a parallel component, this class is by default {@link org.objectweb.proactive.core.component.type.ParallelComposite}
135      */

136     public ContentDescription(String JavaDoc className) {
137         this(className, null, (Node) null, null, null);
138     }
139
140     /**
141      * getter for the activity
142      * @return the activity of the active object
143      */

144     public Active getActivity() {
145         return activity;
146     }
147
148     /**
149      * getter for the classname
150      * @return the name of the class
151      */

152     public String JavaDoc getClassName() {
153         return className;
154     }
155
156     /**
157      * getter for the constructor parameters
158      * @return constructor parameters
159      */

160     public Object JavaDoc[] getConstructorParameters() {
161         return constructorParameters;
162     }
163
164     /**
165      * getter for the metaobjects factory
166      * @return metaobjects factory
167      */

168     public MetaObjectFactory getFactory() {
169         return factory;
170     }
171
172     /**
173      * gives deployment information
174      * @return true if the component is to be deployed on a virtual node
175      */

176     public boolean isLocalizedOnAVirtualNode() {
177         return ((virtualNode != null) && (node == null));
178     }
179
180     /**
181      * getter for the node
182      * @return the node where the component is to be deployed
183      */

184     public Node getNode() {
185         return node;
186     }
187
188     /**
189      * getter for the virtual node
190      * @return the virtual node where the component is to be deployed
191      */

192     public VirtualNode getVirtualNode() {
193         return virtualNode;
194     }
195
196     /**
197      * setter (one can only change the virtual node BEFORE instantiating the component)
198      * @param virtualNode the new virtual node
199      */

200     public void setVirtualNode(VirtualNode virtualNode) {
201         this.virtualNode = virtualNode;
202         node = null;
203     }
204
205     /**
206      * setter (one can only change the node BEFORE instantiating the component)
207      * @param node the new node
208      */

209     public void setNode(Node node) {
210         this.node = node;
211         virtualNode = null;
212     }
213
214     /**
215      * setter (visibility is reduced)
216      */

217     void setFactory(MetaObjectFactory factory) {
218         this.factory = factory;
219     }
220 }
221
Popular Tags