KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Components > CCMHomeWithPKImpl


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): Mathieu Vadet, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Components;
28
29 /**
30  * This class is a basic implementation of the CCMHome interface.
31  * It also implements all generic operations for CCM homes..
32  *
33  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
34  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
35  *
36  * @version 0.3
37  */

38
39 public abstract class CCMHomeWithPKImpl
40                 extends CCMHomeBase
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     // ==================================================================
49
//
50
// Constructor.
51
//
52
// ==================================================================
53

54     /**
55      ** The constructor.
56      **
57      **/

58     protected
59     CCMHomeWithPKImpl()
60     {
61     }
62
63     // ==================================================================
64
//
65
// Internal methods.
66
//
67
// ==================================================================
68

69     /**
70      **
71      **/

72     protected final java.lang.String JavaDoc
73     _component_uid_()
74     {
75         return _the_home_executor()._the_component_uid();
76     }
77
78     /**
79      **
80      **/

81     protected final java.lang.String JavaDoc
82     _home_uid_()
83     {
84         return _the_home_executor()._the_home_uid();
85     }
86
87     /**
88      **
89      **/

90     protected final org.objectweb.openccm.Containers.HomeServant
91     _home_servant_()
92     {
93         return _the_home_executor()._home_servant();
94     }
95
96     /**
97      ** Create a CCM component reference with a primary key.
98      **
99      ** @param key The associated primary key.
100      **
101      ** @return The CCM component reference.
102      **
103      ** @exception org.omg.Components.DuplicateKeyValue
104      ** The primary key is already used.
105      ** @exception org.omg.Components.InvalidKey
106      ** The primary key is invalid.
107      **/

108     protected final org.omg.Components.CCMObject
109     _create(org.omg.Components.PrimaryKeyBase key)
110     throws org.omg.Components.DuplicateKeyValue,
111            org.omg.Components.InvalidKey,
112            org.omg.Components.CreateFailure
113     {
114         org.omg.Components.CCMObject ref = null;
115
116         // create the reference
117
ref = _home_servant_().the_PCA().create_registered_component_reference(_home_servant_(), key);
118                 listener_.on_create(ref);
119
120         // add to the component list.
121
components_.add(ref);
122
123         return ref;
124     }
125
126     /**
127      **
128      **/

129     protected final org.omg.Components.CCMObject
130     _find_by_primary_key(org.omg.Components.PrimaryKeyBase key)
131     throws org.omg.Components.UnknownKeyValue,
132            org.omg.Components.InvalidKey,
133            org.omg.Components.FinderFailure
134     {
135         //
136
// TODO : check for the others exceptions
137
// TODO : retrieve the reference to the returned ::Components::EnterpriseComponent
138
//
139
throw new org.omg.Components.FinderFailure();
140 /*
141         try
142         {
143             return _the_home_executor()._find_by_primary_key_(key);
144         }
145         catch(org.omg.Components.CCMException ex)
146         {
147             throw new org.omg.Components.FinderFailure();
148         }
149  */

150     }
151
152     /**
153      **
154      **/

155     protected final void
156     _remove(org.omg.Components.PrimaryKeyBase key)
157     throws org.omg.Components.UnknownKeyValue,
158            org.omg.Components.InvalidKey,
159            org.omg.Components.RemoveFailure
160     {
161         //
162
// TODO : check for the others exceptions
163
// TODO : other things such as destroying the reference, deactivating the component,...
164
//
165
throw new org.omg.Components.RemoveFailure();
166 /*
167         try
168         {
169             _the_home_executor()._remove_(key);
170         }
171         catch(org.omg.Components.CCMException ex)
172         {
173             throw new org.omg.Components.RemoveFailure();
174         }
175  */

176     }
177
178     /**
179      **
180      **/

181     protected final org.omg.Components.PrimaryKeyBase
182     _get_primary_key(org.omg.Components.CCMObject comp)
183     {
184         try
185         {
186             return comp.get_primary_key();
187         }
188         catch(org.omg.Components.NoKeyAvailable ex)
189         {
190             // should never happen.
191
}
192         return null;
193     }
194
195     // ==================================================================
196
//
197
// Methods for the Components::CCMHome interface.
198
//
199
// ==================================================================
200

201     //
202
// IDL:omg.org/Components/CCMHome/remove_component:1.0
203
//
204
/**
205      ** Removes a component.
206      **
207      ** @param comp The reference to the component.
208      **/

209     public final void
210     remove_component(org.omg.Components.CCMObject comp)
211     throws org.omg.Components.RemoveFailure
212     {
213                 listener_.on_remove(comp);
214         components_.remove(comp);
215         try
216         {
217             _remove(_get_primary_key(comp));
218         }
219         catch(org.omg.Components.UnknownKeyValue ex)
220         {
221             // should not happen.
222
}
223         catch(org.omg.Components.InvalidKey ex)
224         {
225             // should not happen.
226
}
227     }
228
229     // ==================================================================
230
//
231
// Internal methods that must be implemented by subclasses.
232
//
233
// ==================================================================
234

235     /**
236      ** To obtain the home executor.
237      **/

238     protected abstract org.objectweb.openccm.Containers.HomeExecutorWithPK
239     _the_home_executor();
240 }
241
242
243
244
245
246
247
Popular Tags