KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Deployment > ComponentServerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): Romain Rouvoy.
23 Contributor(s): Briclet Fr?d?ric___________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Deployment;
28
29 /**
30  * This class implements the OMG IDL
31  * ::Components::Deployment::ComponentServer interface.
32  *
33  * @author <a HREF="mailto:Romain.Rouvoy@lifl.fr">Romain Rouvoy</a>
34  *
35  * @version 0.3
36  */

37 public class ComponentServerImpl
38     extends org.omg.Components.Deployment.ComponentServerPOA
39 {
40     // ==================================================================
41
//
42
// Internal state.
43
//
44
// ==================================================================
45

46     /**
47      **
48      **/

49     protected ComponentServerBase the_component_server_;
50     
51     
52     // -----> Fred adding begining:
53
// keep the corba facett reference
54
protected org.omg.Components.Deployment.ComponentServer component_server_ref_;
55     // -----> Fred adding ending:
56

57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      ** The constructor.
65      **
66      ** @param classLoader The class loader used to load home classes.
67      **/

68     public
69     ComponentServerImpl( // The server reference isn't needed anymore
70
/*ServerImpl server*/
71                         )
72     {
73         the_component_server_ = new ComponentServerBase (/*server*/) ;
74     }
75     
76     /**
77      * Fred Adding :
78      * Adding a new constructor supporting the ComponentServer configuration
79      * This constructore is used by ServerActivator
80      */

81     public ComponentServerImpl(org.omg.Components.ConfigValue[] config){
82         the_component_server_ = new ComponentServerBase(config);
83     }
84     
85     // ==================================================================
86
//
87
// Internal methods.
88
//
89
// ==================================================================
90

91     // ==================================================================
92
//
93
// Public methods.
94
//
95
// ==================================================================
96

97     public org.objectweb.openccm.Deployment.ComponentServerBase
98     _delegate()
99     {
100     return the_component_server_;
101     }
102
103     //-------> Fred modification begining
104
/**
105      **
106      **/

107     public org.omg.Components.Deployment.ComponentServer
108     asComponentServer()
109     {
110         
111         //Don't deleguate anymore the componentServer facette
112
// retrieving to server object.
113
//return the_component_server_.asComponentServer();
114

115       // Adding the server code
116
if( component_server_ref_==null)
117         {
118         org.omg.CORBA.Object JavaDoc ref = this._this_object(org.objectweb.openccm.corba.TheORB.getORB());
119         component_server_ref_ = org.omg.Components.Deployment.ComponentServerHelper.narrow(ref);
120       }
121     return component_server_ref_;
122     }
123     //-------> Fred modification eding
124

125     
126     // -------> Fred Adding begining:
127
/**
128      * To unregister a container.
129      *
130      * Added for Bug #306.
131      *
132      * Adding this public method according to the modification of
133      * ContainerBase. Now it unregiter itself to ComponentServerImpl
134      * instead of ComponentServerBase.
135      */

136     public void
137     unregister_container(org.omg.Components.Deployment.Container ref)
138     throws org.omg.Components.RemoveFailure
139     {
140         the_component_server_.unregister_container(ref);
141     }
142     
143     //-------> Fred Adding ending:
144

145     // ==================================================================
146
//
147
// Methods for the ::Components::Deployment::ComponentServer interface.
148
//
149
// ==================================================================
150

151     //
152
// IDL:omg.org/Components/Deployment/ComponentServer/configuration:1.0
153
//
154
/**
155      ** To obtain the component server configuration.
156      **
157      **/

158     public org.omg.Components.ConfigValue[]
159     configuration()
160     {
161         return the_component_server_.configuration () ;
162     }
163     
164     //
165
// IDL:omg.org/Components/Deployment/ComponentServer/configuration:1.0
166
//
167
/**
168      ** To set the component server configuration.
169      ** Note : configuration is a readonly attribute, but this allow us to
170      ** set the configuration later in the instanciation process
171      ** which can be useful as we don't have server activator yet.
172      **
173      **/

174     public void
175     configuration(org.omg.Components.ConfigValue[] config)
176     {
177         the_component_server_.configuration (config);
178     }
179     
180     //
181
// IDL:omg.org/Components/Deployment/ComponentServer/get_server_activator:1.0
182
//
183
/**
184      ** To obtain the server activator that has created this component server.
185      **
186      **/

187     public org.omg.Components.Deployment.ServerActivator
188     get_server_activator()
189     {
190         return the_component_server_.get_server_activator ();
191     }
192     
193     //
194
// IDL:omg.org/Components/Deployment/ComponentServer/create_container:1.0
195
//
196
/**
197      ** To create a container.
198      **
199      **/

200     public org.omg.Components.Deployment.Container
201     create_container(org.omg.Components.ConfigValue[] config)
202     throws org.omg.Components.CreateFailure,
203            org.omg.Components.Deployment.InvalidConfiguration
204     {
205         
206         return the_component_server_.create_container (this,config);
207     }
208     
209     //
210
// IDL:omg.org/Components/Deployment/ComponentServer/remove_container:1.0
211
//
212
/**
213      ** To remove a container.
214      **
215      **/

216     public void
217     remove_container(org.omg.Components.Deployment.Container ref)
218     throws org.omg.Components.RemoveFailure
219     {
220         the_component_server_.remove_container (ref);
221     }
222     
223     //
224
// IDL:omg.org/Components/Deployment/ComponentServer/get_containers:1.0
225
//
226
/**
227      ** To obtain all created containers references.
228      **
229      **/

230     public org.omg.Components.Deployment.Container[]
231     get_containers()
232     {
233         return the_component_server_.get_containers();
234     }
235
236     //
237
// IDL:omg.org/Components/Deployment/ComponentServer/remove:1.0
238
//
239
/**
240      ** To remove this component server.
241      **
242      **/

243     public void
244     remove()
245     throws org.omg.Components.RemoveFailure
246     {
247     
248         the_component_server_.remove ();
249
250         // -----> Fred adding begining :
251
// Supports the desactivation treatment moved form ComponentServerBase
252
try {
253         
254             org.objectweb.openccm.corba.TheRootPOA.getRootPOA()
255         .deactivate_object(
256                    org.objectweb.openccm.corba.TheRootPOA.
257                    getRootPOA().reference_to_id(asComponentServer()));
258         
259         } catch (org.omg.PortableServer.POAPackage.WrongAdapter JavaDoc ex) {
260             throw new org.omg.Components.RemoveFailure();
261         } catch (org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc ex) {
262             throw new org.omg.Components.RemoveFailure();
263         } catch (org.omg.PortableServer.POAPackage.ObjectNotActive JavaDoc ex) {
264             throw new org.omg.Components.RemoveFailure();
265         }
266         // Fred adding ending.
267
}
268 }
269
270
271
272
273
274
275
276
277
Popular Tags