KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > installer > ComponentinstantiationDeployerContext


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Briclet Frédéric.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer;
27
28 import java.util.LinkedList JavaDoc;
29 import org.objectweb.openccm.descriptor.componentassembly.Componentinstantiation;
30 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentinstantiationBean;
31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*;
32 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.registrar.*;
33 import org.omg.Components.CCMObject;
34 import org.omg.Components.Cookie;
35 import org.omg.Components.ExceededConnectionLimit;
36
37 /**
38  * The componentinstantiation deployer context defines all the connection
39  * requires for the component instantiation/registration/configuration.
40  *
41  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
42  *
43  * @version 0.1
44  */

45 public class ComponentinstantiationDeployerContext
46        extends ChildDeployerContext
47     {
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53
private ComponentinstantiationBean componentInstantiation;
54     private ComponentinstantiationDeployInfo componentInstantiationDeployInfo;
55     private ComponentpropertiesDeployer properties;
56     private LinkedList JavaDoc registercomponentDeployers;
57     private Cookie cookie;
58     private CCMObject comp;
59     // ==================================================================
60
//
61
// Constructors.
62
//
63
// ==================================================================
64
public ComponentinstantiationDeployerContext()
65     {
66         registercomponentDeployers=new LinkedList JavaDoc();
67     }
68     // ==================================================================
69
//
70
// Internal methods.
71
//
72
// ==================================================================
73
// ==================================================================
74
//
75
// Public accessors methods.
76
//
77
// ==================================================================
78
public void
79     connectComponentinstantiation ( ComponentinstantiationBean componentInstantiation)
80     {
81         this.componentInstantiation=componentInstantiation;
82         connectDeployerDescription(componentInstantiation);
83     }
84     
85     public Componentinstantiation
86     getComponentinstantiation()
87     {
88         return componentInstantiation;
89     }
90     
91     public void
92     connectComponentpropertiesDeployer(ComponentpropertiesDeployer properties)
93     {
94        this.properties=properties;
95     }
96
97     public ComponentpropertiesDeployer
98     getComponentpropertiesDeployer()
99     {
100         return properties;
101     }
102     
103     public void
104     connectRegistercomponentDeployer(RegistercomponentDeployer reg)
105     {
106         this.registercomponentDeployers.addLast(reg);
107     }
108
109      public RegistercomponentDeployer[]
110      getRegisterwithcomponentDeployers()
111      {
112          return (RegistercomponentDeployer[])
113                  registercomponentDeployers.toArray
114                  (new RegistercomponentDeployer[registercomponentDeployers.size()]);
115      }
116      /**
117       * @return
118       */

119      public ComponentinstantiationDeployInfo getComponentInstantiationDeployInfo() {
120          return componentInstantiationDeployInfo;
121      }
122
123      /**
124       * @param info
125       */

126      public void connectComponentInstantiationDeployInfo(ComponentinstantiationDeployInfo info) {
127          componentInstantiationDeployInfo = info;
128      }
129      
130     /**
131      * This initialization method is used to check that all the services and
132      * information required to deploy are presents. If all is OK the deployer
133      * is put in inactive deployer state waiting for the deployment processing.
134      *
135      * @exception InitializationError is thrown if a problem is detected
136      */

137     public void initialize() throws InitializationError {
138         if (getComponentinstantiation() == null)
139             getErrorManager().submitException(
140                 new InitializationError(
141                     this,
142                     "Connection on componentinstantiation bean is required"
143                         + "check the handler code it must specify this connection"));
144         if (getComponentpropertiesDeployer() == null)
145             getLogger().log(
146                 "No componentproperties specified for this componentinstantiation");
147
148         getLifeCycleManager().stepEndedSuccessFully();
149     }
150  
151     /**
152      * This method provides the feature to register the component
153      * on the appollon tree and connect it to the current assembly manager.
154      *
155      * @param comp the component to register
156      */

157     public void
158     storeComponentReference(CCMObject comp)
159     {
160       // storing the reference in the DeployInfo extension of the descriptor
161
this.comp=comp;
162       getComponentInstantiationDeployInfo().setCorbaReference(comp);
163       getRootDeployerContext().connectComponent(comp);
164       if(getRootDeployerContext().getAssemblyManager()!=null)
165         try {
166             cookie=getRootDeployerContext().getAssemblyManager().connect_components(comp);
167         } catch (ExceededConnectionLimit e) {
168             getLogger().log("Connection of component on AssemblyManager failed.");
169         }
170     }
171     /**
172      * This method provides the feature to unregister the component
173      * on the appollon tree and disconnect it to the current assembly manager.
174      *
175      */

176     public void
177     unstoreComponentReference()
178     {
179         getRootDeployerContext().disconnectComponent(comp);
180         if(getRootDeployerContext().getAssemblyManager()!=null)
181             try
182             {
183                 getRootDeployerContext()
184                     .getAssemblyManager()
185                     .disconnect_components(cookie);
186             }
187             catch (ExceededConnectionLimit e)
188             {
189                 e.printStackTrace();
190             }
191     }
192
193 }
194
Popular Tags