KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > component > body > ComponentBodyImpl


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.body;
32
33 import org.apache.log4j.Logger;
34
35 import org.objectweb.proactive.core.body.BodyImpl;
36 import org.objectweb.proactive.core.body.MetaObjectFactory;
37 import org.objectweb.proactive.core.body.ProActiveMetaObjectFactory;
38 import org.objectweb.proactive.core.component.ComponentParameters;
39 import org.objectweb.proactive.core.component.identity.ProActiveComponent;
40
41 /**
42  * This class is placed in the hierarchy of bodies in order to provide access to the
43  * component metaobjects (through ProActiveComponentImpl)
44  *
45  * @author Matthieu Morel
46  */

47 import java.util.Hashtable JavaDoc;
48
49
50 /** This class has been inserted into the bodies hierarchy in order to instantiate the
51  * component metaobject (ProActiveComponent).
52  */

53 public class ComponentBodyImpl extends BodyImpl implements ComponentBody {
54     protected static Logger logger = Logger.getLogger(ComponentBodyImpl.class.getName());
55
56     //private static Category cat = Category.getInstance(ComponentBodyImpl.class.getName());
57
private ProActiveComponent componentIdentity = null;
58
59     /**
60      * Constructor for ComponentBodyImpl.
61      */

62     public ComponentBodyImpl() {
63         super();
64     }
65
66     /** Constructor for ComponentBodyImpl.
67      *
68      * It creates the component metaobject only if the MetaObjectFactory is parameterized
69      * with ComponentParameters (thus implicitely constructing components)
70      * @param reifiedObject a reference on the reified object
71      * @param nodeURL node url
72      * @param factory factory for the corresponding metaobjects
73      */

74     public ComponentBodyImpl(Object JavaDoc reifiedObject, String JavaDoc nodeURL,
75         MetaObjectFactory factory, String JavaDoc jobID) {
76         super(reifiedObject, nodeURL, factory, jobID);
77
78         // create the component metaobject if necessary
79
// --> check the value of the "parameters" field
80
Hashtable JavaDoc factory_parameters = factory.getParameters();
81         if ((factory_parameters != null)) {
82             if (factory_parameters.get(
83                         ProActiveMetaObjectFactory.COMPONENT_PARAMETERS_KEY) != null) {
84                 if (factory_parameters.get(
85                             ProActiveMetaObjectFactory.COMPONENT_PARAMETERS_KEY) instanceof ComponentParameters) {
86                     if (logger.isDebugEnabled()) {
87                         logger.debug("creating metaobject component identity");
88                     }
89                     componentIdentity = factory.newComponentFactory()
90                                                .newProActiveComponent(this);
91                 } else {
92                     logger.error(
93                         "component parameters for the components factory are not of type ComponentParameters");
94                 }
95             }
96         }
97     }
98
99     /**
100      * Returns the a reference on the Component meta object
101      * @return the ProActiveComponent meta-object
102      */

103     public ProActiveComponent getProActiveComponent() {
104         return componentIdentity;
105     }
106
107 }
108
Popular Tags