Lines 1-11
Link Here
|
1 |
/* |
1 |
/* |
2 |
* Sun Public License Notice |
2 |
* Sun Public License Notice |
3 |
* |
3 |
* |
4 |
* The contents of this file are subject to the Sun Public License |
4 |
* The contents of this file are subject to the Sun Public License |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
6 |
* compliance with the License. A copy of the License is available at |
6 |
* compliance with the License. A copy of the License is available at |
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
Lines 42-49
Link Here
|
42 |
/* -------------------------------------------------------------------- */ |
42 |
/* -------------------------------------------------------------------- */ |
43 |
/* -- Private static constants ---------------------------------------- */ |
43 |
/* -- Private static constants ---------------------------------------- */ |
44 |
/* -------------------------------------------------------------------- */ |
44 |
/* -------------------------------------------------------------------- */ |
45 |
|
45 |
|
46 |
// private static final Collection instances = new HashSet(); |
46 |
// private static final Collection instances = new HashSet(); |
47 |
|
47 |
|
48 |
private static final URL MOF_XML_URL = ModelPackage.class.getResource("resources/mof.xml"); |
48 |
private static final URL MOF_XML_URL = ModelPackage.class.getResource("resources/mof.xml"); |
49 |
private static final URL BOOTMOF_XML_URL = ModelPackage.class.getResource("resources/mof.xml"); |
49 |
private static final URL BOOTMOF_XML_URL = ModelPackage.class.getResource("resources/mof.xml"); |
Lines 55-76
Link Here
|
55 |
private static final String INTERCEPTABLE_TAG_ID = "org.netbeans.mdr.interceptable"; |
55 |
private static final String INTERCEPTABLE_TAG_ID = "org.netbeans.mdr.interceptable"; |
56 |
private static final String TRANSIENT_TAG_ID = "org.netbeans.mdr.transient"; |
56 |
private static final String TRANSIENT_TAG_ID = "org.netbeans.mdr.transient"; |
57 |
private static final String TAG_VALUE_TRUE = "true"; |
57 |
private static final String TAG_VALUE_TRUE = "true"; |
58 |
|
58 |
|
59 |
public static final String BOOT_MOF = "BootMOF"; |
59 |
public static final String BOOT_MOF = "BootMOF"; |
60 |
public static final String PURE_MOF = "MOF"; |
60 |
public static final String PURE_MOF = "MOF"; |
61 |
|
61 |
|
62 |
/* -------------------------------------------------------------------- */ |
62 |
/* -------------------------------------------------------------------- */ |
63 |
/* -- Private attributes ---------------------------------------------- */ |
63 |
/* -- Private attributes ---------------------------------------------- */ |
64 |
/* -------------------------------------------------------------------- */ |
64 |
/* -------------------------------------------------------------------- */ |
65 |
|
65 |
|
66 |
private MdrStorage mdrStorage = null; |
66 |
private MdrStorage mdrStorage = null; |
67 |
|
67 |
|
68 |
private Map classProxies = null; |
68 |
private Map classProxies = null; |
69 |
private Map associationProxies = null; |
69 |
private Map associationProxies = null; |
70 |
private Map classProxiesMofIds = null; |
70 |
private Map classProxiesMofIds = null; |
71 |
|
71 |
|
72 |
private final Map parameters; |
72 |
private final Map parameters; |
73 |
|
73 |
|
74 |
/* --------------------------------------------------------------------- */ |
74 |
/* --------------------------------------------------------------------- */ |
75 |
/* -- Constructors ----------------------------------------------------- */ |
75 |
/* -- Constructors ----------------------------------------------------- */ |
76 |
/* --------------------------------------------------------------------- */ |
76 |
/* --------------------------------------------------------------------- */ |
Lines 95-112
Link Here
|
95 |
* <td>storage location</td> |
95 |
* <td>storage location</td> |
96 |
* </tr> |
96 |
* </tr> |
97 |
* </table> |
97 |
* </table> |
98 |
* |
|
|
99 |
*/ |
98 |
*/ |
100 |
public NBMDRepositoryImpl () { |
99 |
// * <p>Additionally the following properties allow to replace parts |
|
|
100 |
// * of the MDR implementation by tailor-made classes, namely the base classes |
101 |
// * for generated handler classes. This is an experimental feature, use |
102 |
// * it with care. Currently no documentation is available about the features |
103 |
// * the replacing classes must provide in order to cooperate with the generated code:</p> |
104 |
// * |
105 |
// * <table border cellspacing="1" cellpadding="2"> |
106 |
// * <tr> |
107 |
// * <td><code>org.netbeans.mdr.handlers.PackageProxyHandler</code></td> |
108 |
// * <td>(no default)</td> |
109 |
// * <td>fully qualified name of the class replacing <code>PackageProxyHandler</code> |
110 |
// * as base class for package proxy implementations</td> |
111 |
// * </tr> |
112 |
// * <tr> |
113 |
// * <td><code>org.netbeans.mdr.handlers.ClassProxyHandler</code></td> |
114 |
// * <td>(no default)</td> |
115 |
// * <td>fully qualified name of the class replacing <code>ClassProxyHandler</code> |
116 |
// * as default base class for class proxy implementations</td> |
117 |
// * </tr> |
118 |
// * <tr> |
119 |
// * <td><code>org.netbeans.mdr.handlers.InstanceHandler</code></td> |
120 |
// * <td>(no default)</td> |
121 |
// * <td>fully qualified name of the class replacing <code>InstanceHandler</code> |
122 |
// * as default base class for instance implementations</td> |
123 |
// * </tr> |
124 |
// * <tr> |
125 |
// * <td><code>org.netbeans.mdr.handlers.AssociationHandler</code></td> |
126 |
// * <td>(no default)</td> |
127 |
// * <td>fully qualified name of the class replacing <code>AssociationHandler</code> |
128 |
// * as default base class for association implementations</td> |
129 |
// * </tr> |
130 |
// * <tr> |
131 |
// * <td><code>org.netbeans.mdr.handlers.StructureHandler</code></td> |
132 |
// * <td>(no default)</td> |
133 |
// * <td>fully qualified name of the class replacing <code>StructImpl</code> |
134 |
// * as base class for structure implementations</td> |
135 |
// * </tr> |
136 |
// * </table> |
137 |
// * |
138 |
// */ |
139 |
public NBMDRepositoryImpl() { |
101 |
System.out.println("using default values..."); |
140 |
System.out.println("using default values..."); |
102 |
|
141 |
|
103 |
String storageClass = System.getProperty("org.netbeans.mdr.storagemodel.StorageFactoryClassName", "org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory"); |
142 |
String storageClass = System.getProperty("org.netbeans.mdr.storagemodel.StorageFactoryClassName", "org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory"); |
104 |
String storageFile = System.getProperty("org.netbeans.mdr.persistence.Dir"); |
143 |
String storageFile = System.getProperty("org.netbeans.mdr.persistence.Dir"); |
105 |
|
144 |
// String packageProxyHandler = System.getProperty("org.netbeans.mdr.handlers.PackageProxyHandler"); |
|
|
145 |
// String classProxyHandler = System.getProperty("org.netbeans.mdr.handlers.ClassProxyHandler"); |
146 |
// String instanceHandler = System.getProperty("org.netbeans.mdr.handlers.InstanceHandler"); |
147 |
// String associationHandler = System.getProperty("org.netbeans.mdr.handlers.AssociationHandler"); |
148 |
// String structureHandler = System.getProperty("org.netbeans.mdr.handlers.StructureHandler"); |
149 |
|
106 |
parameters = new HashMap(); |
150 |
parameters = new HashMap(); |
107 |
parameters.put("storage", storageClass); |
151 |
parameters.put("storage", storageClass); |
108 |
parameters.put(org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory.STORAGE_FILE_NAME, storageFile); |
152 |
parameters.put(org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory.STORAGE_FILE_NAME, storageFile); |
109 |
// instances.add(this); |
153 |
// if ( packageProxyHandler != null ) parameters.put("PackageProxyHandler", packageProxyHandler); |
|
|
154 |
// if ( classProxyHandler != null ) parameters.put("ClassProxyHandler", classProxyHandler); |
155 |
// if ( instanceHandler != null ) parameters.put("InstanceHandler", instanceHandler); |
156 |
// if ( associationHandler != null ) parameters.put("AssociationHandler", associationHandler); |
157 |
// if ( structureHandler != null ) parameters.put("StructureHandler", structureHandler); |
158 |
// instances.add(this); |
110 |
} |
159 |
} |
111 |
|
160 |
|
112 |
/** Creates new {@link org.netbeans.api.mdr.MDRepository} with given parameters. |
161 |
/** Creates new {@link org.netbeans.api.mdr.MDRepository} with given parameters. |
Lines 116-150
Link Here
|
116 |
* <li><code>storage</code>: name of a class implementing {@link |
165 |
* <li><code>storage</code>: name of a class implementing {@link |
117 |
* org.netbeans.mdr.persistence.StorageFactory}</li> |
166 |
* org.netbeans.mdr.persistence.StorageFactory}</li> |
118 |
* <li><code>fileName</code>: storage location</li> |
167 |
* <li><code>fileName</code>: storage location</li> |
119 |
* </ol> |
168 |
* </ol></p> |
120 |
* |
|
|
121 |
*/ |
169 |
*/ |
|
|
170 |
// * <p>Additionally the following parameters allow to replace parts |
171 |
// * of the MDR implementation by tailor-made classes, namely the base classes |
172 |
// * for generated handler classes. This is an experimental feature, use |
173 |
// * it with care. Currently no documentation is available about the features |
174 |
// * the replacing classes must provide in order to cooperate with the generated code:</p> |
175 |
// * |
176 |
// * <p><ol> |
177 |
// * <li><code>PackageProxyHandler</code>: fully qualified name of the super-class |
178 |
// * for package proxy implementations (default: |
179 |
// * <code>org.netbeans.mdr.handler.PackageProxyHandler</code>)</li> |
180 |
// * <li><code>ClassProxyHandler</code>: fully qualified name of the default super-class |
181 |
// * for class proxy implementations (default: |
182 |
// * <code>org.netbeans.mdr.handler.ClassProxyHandler</code>)</li> |
183 |
// * <li><code>InstanceHandler</code>: fully qualified name of the default super-class |
184 |
// * for instance implementations (default: |
185 |
// * <code>org.netbeans.mdr.handler.InstanceHandler</code>)</li> |
186 |
// * <li><code>AssociationHandler</code>: fully qualified name of the default super-class |
187 |
// * for assocation proxy implementations (default: |
188 |
// * <code>org.netbeans.mdr.handler.AssociationHandler</code>)</li> |
189 |
// * <li><code>StructureHandler</code>: fully qualified name of the super-class |
190 |
// * for structure implementations (default: |
191 |
// * <code>org.netbeans.mdr.handler.StructImpl</code>)</li> |
192 |
// * </ol></p> |
193 |
// * |
194 |
// */ |
122 |
public NBMDRepositoryImpl(Map parameters) { |
195 |
public NBMDRepositoryImpl(Map parameters) { |
123 |
Log.out.println("Creating MDRepository implementation ..."); |
196 |
Log.out.println("Creating MDRepository implementation ..."); |
124 |
this.parameters = parameters; |
197 |
this.parameters = parameters; |
125 |
// instances.add(this); |
198 |
// instances.add(this); |
126 |
} |
199 |
} |
127 |
|
200 |
|
128 |
/* -------------------------------------------------------------------- */ |
201 |
/* -------------------------------------------------------------------- */ |
129 |
/* -- Implementation of org.netbeans.api.mdr.event.MDRChangeSource ---- */ |
202 |
/* -- Implementation of org.netbeans.api.mdr.events.MDRChangeSource --- */ |
130 |
/* -------------------------------------------------------------------- */ |
203 |
/* -------------------------------------------------------------------- */ |
131 |
|
204 |
|
132 |
/** Registers a listener for receiving event notifications. |
205 |
/** Registers a listener for receiving event notifications with are |
133 |
* @param listener Object that implements {@link Listener} interface. |
206 |
* initially fired on this object. |
|
|
207 |
* @param listener Object that implements {@link MDRChangeListener} interface. |
134 |
*/ |
208 |
*/ |
135 |
public void addListener(MDRChangeListener listener) { |
209 |
public void addListener(MDRChangeListener listener) { |
|
|
210 |
addListener(listener, MDRChangeEvent.EVENTMASK_ALL); |
211 |
} |
212 |
|
213 |
/** Registers a listener for receiving event notifications. |
214 |
* @param listener Object that implements {@link MDRChangeListener} interface. |
215 |
* @param mask bitmask to filter types of events the listener listens on |
216 |
*/ |
217 |
public void addListener(MDRChangeListener listener, int mask) { |
136 |
initCheck(); |
218 |
initCheck(); |
137 |
mdrStorage.getEventNotifier().REPOSITORY.addListener(listener, mdrStorage); |
219 |
mdrStorage.getEventNotifier().REPOSITORY.addListener(listener, mask, mdrStorage); |
138 |
} |
220 |
} |
139 |
|
221 |
|
140 |
/** Removes listener from the list of objects registered for events notifications. |
222 |
/** Removes listener from the list of objects registered for event notifications. |
141 |
* @param listener Object that implements {@link Listener} interface. |
223 |
* @param listener Object that implements {@link MDRChangeListener} interface. |
142 |
*/ |
224 |
*/ |
143 |
public void removeListener(MDRChangeListener listener) { |
225 |
public void removeListener(MDRChangeListener listener) { |
144 |
initCheck(); |
226 |
initCheck(); |
145 |
mdrStorage.getEventNotifier().REPOSITORY.removeListener(listener, mdrStorage); |
227 |
mdrStorage.getEventNotifier().REPOSITORY.removeListener(listener, mdrStorage); |
146 |
} |
228 |
} |
147 |
|
229 |
|
|
|
230 |
/** Removes listener from the list of objects registered for event notifications. |
231 |
* @param listener Object that implements {@link MDRChangeListener} interface. |
232 |
* @param mask determines type of the events the listeners stops to listen on |
233 |
*/ |
234 |
public void removeListener(MDRChangeListener listener, int mask) { |
235 |
initCheck(); |
236 |
mdrStorage.getEventNotifier().REPOSITORY.removeListener(listener, mask, mdrStorage); |
237 |
} |
238 |
|
148 |
/* -------------------------------------------------------------------- */ |
239 |
/* -------------------------------------------------------------------- */ |
149 |
/* -- Implementation of org.netbeans.api.mdr.MDRepositry -------------- */ |
240 |
/* -- Implementation of org.netbeans.api.mdr.MDRepositry -------------- */ |
150 |
/* -------------------------------------------------------------------- */ |
241 |
/* -------------------------------------------------------------------- */ |
Lines 163-174
Link Here
|
163 |
initCheck(); |
254 |
initCheck(); |
164 |
mdrStorage.getRepositoryMutex().leave(rollback); |
255 |
mdrStorage.getRepositoryMutex().leave(rollback); |
165 |
} |
256 |
} |
166 |
|
257 |
|
167 |
/** Instantiates the MOF model package. |
258 |
/** Instantiates the MOF model package. |
168 |
* |
259 |
* |
169 |
* @param substName the name of the new model |
260 |
* @param substName the name of the new model |
170 |
*/ |
261 |
*/ |
171 |
public RefPackage createExtent(String substName) throws CreationFailedException { |
262 |
public RefPackage createExtent(String substName) throws CreationFailedException { |
172 |
return createExtent(substName, null); |
263 |
return createExtent(substName, null); |
173 |
} |
264 |
} |
174 |
|
265 |
|
Lines 191-199
Link Here
|
191 |
* package. |
282 |
* package. |
192 |
* @param existingInstances |
283 |
* @param existingInstances |
193 |
*/ |
284 |
*/ |
194 |
public RefPackage createExtent (String substName, RefObject metaPackage, RefPackage[] existingInstances) throws CreationFailedException { |
285 |
public RefPackage createExtent(String substName, RefObject metaPackage, RefPackage[] existingInstances) throws CreationFailedException { |
195 |
return createExtent (substName, metaPackage, existingInstances, null); |
286 |
return createExtent(substName, metaPackage, existingInstances, null); |
196 |
} |
287 |
} |
197 |
|
288 |
|
198 |
/** Returns reference to an outermost package instance of a given name. |
289 |
/** Returns reference to an outermost package instance of a given name. |
199 |
* @param name name of package instance to be returned |
290 |
* @param name name of package instance to be returned |
Lines 202-213
Link Here
|
202 |
*/ |
293 |
*/ |
203 |
public RefPackage getExtent(String name) { |
294 |
public RefPackage getExtent(String name) { |
204 |
StorablePackage pkg; |
295 |
StorablePackage pkg; |
205 |
|
296 |
|
206 |
initCheck(); |
297 |
initCheck(); |
207 |
|
298 |
|
208 |
try { |
299 |
try { |
209 |
beginTrans(false); |
300 |
beginTrans(false); |
210 |
|
301 |
|
211 |
try { |
302 |
try { |
212 |
// retrieve the package |
303 |
// retrieve the package |
213 |
pkg = (StorablePackage) mdrStorage.getContextOutermostPackage(name); |
304 |
pkg = (StorablePackage) mdrStorage.getContextOutermostPackage(name); |
Lines 233-239
Link Here
|
233 |
*/ |
324 |
*/ |
234 |
public String[] getExtentNames() { |
325 |
public String[] getExtentNames() { |
235 |
initCheck(); |
326 |
initCheck(); |
236 |
|
327 |
|
237 |
String result[] = new String[0]; |
328 |
String result[] = new String[0]; |
238 |
try { |
329 |
try { |
239 |
beginTrans(false); |
330 |
beginTrans(false); |
Lines 246-252
Link Here
|
246 |
endTrans(); |
337 |
endTrans(); |
247 |
} |
338 |
} |
248 |
} |
339 |
} |
249 |
|
340 |
|
|
|
341 |
/** |
342 |
* Returns the object with the given <code>mofId</code>. |
343 |
*/ |
344 |
public RefBaseObject getByMofId(String mofId) { |
345 |
initCheck(); |
346 |
try { |
347 |
beginTrans(false); |
348 |
StorableBaseObject storable = mdrStorage.getObject(mofId); |
349 |
if ( storable == null ) { |
350 |
throw new NoSuchElementException("No object with MOF ID: " + mofId); |
351 |
} else { |
352 |
return BaseObjectHandler.getHandler(storable); |
353 |
} |
354 |
} catch (StorageException e) { |
355 |
e.printStackTrace(); |
356 |
throw new DebugException(); |
357 |
} finally { |
358 |
endTrans(); |
359 |
} |
360 |
} |
361 |
|
250 |
/** |
362 |
/** |
251 |
* Called on repository exit. Should perform all needed finalization actions. |
363 |
* Called on repository exit. Should perform all needed finalization actions. |
252 |
*/ |
364 |
*/ |
Lines 261-276
Link Here
|
261 |
} |
373 |
} |
262 |
} |
374 |
} |
263 |
} |
375 |
} |
264 |
|
376 |
|
265 |
/* -------------------------------------------------------------------- */ |
377 |
/* -------------------------------------------------------------------- */ |
266 |
/* -- Extending java.lang.Object -------------------------------------- */ |
378 |
/* -- Extending java.lang.Object -------------------------------------- */ |
267 |
/* -------------------------------------------------------------------- */ |
379 |
/* -------------------------------------------------------------------- */ |
268 |
|
380 |
|
269 |
public String toString() { |
381 |
public String toString() { |
270 |
StringBuffer sb = new StringBuffer("IDE MOF Repository"); |
382 |
StringBuffer sb = new StringBuffer("IDE MOF Repository"); |
271 |
return sb.toString(); |
383 |
return sb.toString(); |
272 |
} |
384 |
} |
273 |
|
385 |
|
274 |
/* -------------------------------------------------------------------- */ |
386 |
/* -------------------------------------------------------------------- */ |
275 |
/* -- Create an outermost package instance ---------------------------- */ |
387 |
/* -- Create an outermost package instance ---------------------------- */ |
276 |
/* -------------------------------------------------------------------- */ |
388 |
/* -------------------------------------------------------------------- */ |
Lines 288-363
Link Here
|
288 |
initCheck(); |
400 |
initCheck(); |
289 |
|
401 |
|
290 |
RefPackage result; |
402 |
RefPackage result; |
291 |
|
403 |
|
292 |
if (substName.equals(BOOT_MOF) && mdrStorage.isBooting()) { |
404 |
boolean fail = true; |
293 |
// instantiate BootMOF |
405 |
if (metaPackage == null) { |
294 |
// this piece of code does not need to be locked because it can be invoked |
406 |
metaPackage = getMOFModelPackage(); |
295 |
// only during booting and the booting process itself runs in a locked session |
407 |
} |
296 |
// [PENDING] probably this code should be removed from here and put |
408 |
ExtentEvent event = new ExtentEvent( |
297 |
// directly into installFakeMof() |
409 |
this, |
298 |
createBootMOF(); |
410 |
ExtentEvent.EVENT_EXTENT_CREATE, |
299 |
result = getExtent(substName); |
411 |
substName, |
300 |
if (result == null) { |
412 |
metaPackage, |
301 |
throw new CreationFailedException("Fatal error during bootstrapping."); |
413 |
new ImmutableList(existingInstances) |
|
|
414 |
); |
415 |
|
416 |
try { |
417 |
beginTrans(true); |
418 |
mdrStorage.getEventNotifier().REPOSITORY.firePlannedChange(mdrStorage, event); |
419 |
Map instancesToCluster = new HashMap(); |
420 |
|
421 |
// Traverse the metamodel containtment |
422 |
classProxies = new HashMap(); |
423 |
associationProxies = new HashMap(); |
424 |
classProxiesMofIds = new HashMap(); |
425 |
|
426 |
if (existingInstances != null) { |
427 |
for (int i = 0; i < existingInstances.length; i++) { |
428 |
collectPackageInstances(existingInstances[i], instancesToCluster); |
429 |
} |
302 |
} |
430 |
} |
303 |
} else { |
|
|
304 |
boolean fail = true; |
305 |
if (metaPackage == null) { |
306 |
metaPackage = getMOFModelPackage(); |
307 |
} |
308 |
ExtentEvent event = new ExtentEvent( |
309 |
this, |
310 |
ExtentEvent.EVENT_EXTENT_CREATE, |
311 |
substName, |
312 |
metaPackage, |
313 |
new ImmutableList(existingInstances) |
314 |
); |
315 |
|
316 |
try { |
431 |
try { |
317 |
beginTrans(true); |
432 |
instantiatePackage(substName, null, (MofPackage) metaPackage, instancesToCluster, storageId, false); |
318 |
mdrStorage.getEventNotifier().REPOSITORY.firePlannedChange(mdrStorage, event); |
433 |
} catch (RuntimeException e) { |
319 |
Map instancesToCluster = new HashMap(); |
434 |
e.printStackTrace(); |
320 |
|
435 |
throw new CreationFailedException("Cannot instantiate package because of unexpected exception: " + e); |
321 |
// Traverse the metamodel containtment |
436 |
} |
322 |
classProxies = new HashMap(); |
437 |
|
323 |
associationProxies = new HashMap(); |
438 |
classProxies = null; |
324 |
classProxiesMofIds = new HashMap(); |
439 |
associationProxies = null; |
325 |
|
440 |
classProxiesMofIds = null; |
326 |
if (existingInstances != null) { |
441 |
|
327 |
for (int i = 0; i < existingInstances.length; i++) { |
442 |
result = getExtent(substName); |
328 |
collectPackageInstances(existingInstances[i], instancesToCluster); |
443 |
if (result == null) { |
329 |
} |
444 |
throw new CreationFailedException("Cannot find created package."); |
330 |
} |
|
|
331 |
try { |
332 |
instantiatePackage(substName, null, (MofPackage) metaPackage, instancesToCluster, storageId, false); |
333 |
} catch (RuntimeException e) { |
334 |
e.printStackTrace(); |
335 |
throw new CreationFailedException("Cannot instantiate package because of unexpected exception: " + e); |
336 |
} |
337 |
|
338 |
classProxies = null; |
339 |
associationProxies = null; |
340 |
classProxiesMofIds = null; |
341 |
|
342 |
result = getExtent(substName); |
343 |
if (result == null) { |
344 |
throw new CreationFailedException("Cannot find created package."); |
345 |
} |
346 |
|
347 |
fail = false; |
348 |
} finally { |
349 |
endTrans(fail); |
350 |
} |
445 |
} |
|
|
446 |
|
447 |
fail = false; |
448 |
} finally { |
449 |
endTrans(fail); |
351 |
} |
450 |
} |
352 |
|
451 |
|
353 |
return result; |
452 |
return result; |
354 |
} |
453 |
} |
355 |
|
454 |
|
356 |
/* -------------------------------------------------------------------- */ |
455 |
/* -------------------------------------------------------------------- */ |
357 |
/* -- Storage partitions ---------------------------------------------- */ |
456 |
/* -- Storage partitions ---------------------------------------------- */ |
358 |
/* -------------------------------------------------------------------- */ |
457 |
/* -------------------------------------------------------------------- */ |
359 |
|
458 |
|
360 |
/** |
459 |
/** |
361 |
* Mounts new partition into current repository, |
460 |
* Mounts new partition into current repository, |
362 |
* The partition is created and initialized, if it does not exist. |
461 |
* The partition is created and initialized, if it does not exist. |
363 |
* @param String storageFactoryClass, name of storage factory class, which will create a new storage. |
462 |
* @param String storageFactoryClass, name of storage factory class, which will create a new storage. |
Lines 365-412
Link Here
|
365 |
* @return String id. |
464 |
* @return String id. |
366 |
* @exception MountFailedException thrown when mounting fails. |
465 |
* @exception MountFailedException thrown when mounting fails. |
367 |
*/ |
466 |
*/ |
368 |
public String mountStorage (String storageFactoryClass, Map properties) throws MountFailedException { |
467 |
public String mountStorage(String storageFactoryClass, Map properties) throws MountFailedException { |
369 |
boolean failed = true; |
468 |
boolean failed = true; |
370 |
try { |
469 |
try { |
371 |
beginTrans (true); |
470 |
beginTrans(true); |
372 |
// Firing of event is done inside a MdrStorage mountStorage method |
471 |
// Firing of event is done inside a MdrStorage mountStorage method |
373 |
String storageId = this.mdrStorage.mountStorage (storageFactoryClass, properties); |
472 |
String storageId = this.mdrStorage.mountStorage(storageFactoryClass, properties); |
374 |
failed = false; |
473 |
failed = false; |
375 |
return storageId; |
474 |
return storageId; |
376 |
}catch (Exception e) { |
475 |
}catch (Exception e) { |
377 |
throw new MountFailedException ("Partition mount failed.", e); |
476 |
throw new MountFailedException("Partition mount failed.", e); |
378 |
} |
477 |
} |
379 |
finally { |
478 |
finally { |
380 |
endTrans (failed); |
479 |
endTrans(failed); |
381 |
} |
480 |
} |
382 |
} |
481 |
} |
383 |
|
482 |
|
384 |
/** |
483 |
/** |
385 |
* Umounts partition from current repository. |
484 |
* Umounts partition from current repository. |
386 |
* Umounting partition can affect validity of association links |
485 |
* Umounting partition can affect validity of association links |
387 |
* which cross partitions. Module developer is responsible for |
486 |
* which cross partitions. Module developer is responsible for |
388 |
* either removing cross partition links or handling exceptions |
487 |
* either removing cross partition links or handling exceptions |
389 |
* caused by accessing these links. |
488 |
* caused by accessing these links. |
390 |
* @param String storageId, id of storage. |
489 |
* @param String storageId, id of storage. |
391 |
*/ |
490 |
*/ |
392 |
public void umountStorage (String storageId) { |
491 |
public void umountStorage(String storageId) { |
393 |
boolean failed = true; |
492 |
boolean failed = true; |
394 |
try { |
493 |
try { |
395 |
beginTrans (true); |
494 |
beginTrans(true); |
396 |
Collection c = mdrStorage.getContexts (storageId); |
495 |
Collection c = mdrStorage.getContexts(storageId); |
397 |
for (Iterator it = c.iterator(); it.hasNext();) { |
496 |
for (Iterator it = c.iterator(); it.hasNext();) { |
398 |
String extentName = (String)it.next(); |
497 |
String extentName = (String)it.next(); |
399 |
RefPackage pkg = this.getExtent (extentName); |
498 |
RefPackage pkg = this.getExtent(extentName); |
400 |
ExtentEvent event = new ExtentEvent (pkg, ExtentEvent.EVENT_EXTENT_DELETE, extentName, pkg.refMetaObject(), null); |
499 |
ExtentEvent event = new ExtentEvent(pkg, ExtentEvent.EVENT_EXTENT_DELETE, extentName, pkg.refMetaObject(), null); |
401 |
this.mdrStorage.getEventNotifier().PACKAGE.firePlannedChange (pkg, event); |
500 |
this.mdrStorage.getEventNotifier().PACKAGE.firePlannedChange(pkg, event); |
402 |
} |
501 |
} |
403 |
this.mdrStorage.umountStorage (storageId); |
502 |
this.mdrStorage.umountStorage(storageId); |
404 |
failed = false; |
503 |
failed = false; |
405 |
}catch (StorageException e) { |
504 |
}catch (StorageException e) { |
406 |
throw new DebugException ("Umounting failed: "+e.toString()); |
505 |
throw new DebugException("Umounting failed: "+e.toString()); |
407 |
} |
506 |
} |
408 |
finally { |
507 |
finally { |
409 |
endTrans (failed); |
508 |
endTrans(failed); |
410 |
} |
509 |
} |
411 |
} |
510 |
} |
412 |
/* -------------------------------------------------------------------- */ |
511 |
/* -------------------------------------------------------------------- */ |
Lines 419-425
Link Here
|
419 |
public String getMOFInstanceName() { |
518 |
public String getMOFInstanceName() { |
420 |
return PURE_MOF; |
519 |
return PURE_MOF; |
421 |
} |
520 |
} |
422 |
|
521 |
|
423 |
/* -------------------------------------------------------------------- */ |
522 |
/* -------------------------------------------------------------------- */ |
424 |
/* -- Private helper methods ------------------------------------------ */ |
523 |
/* -- Private helper methods ------------------------------------------ */ |
425 |
/* -------------------------------------------------------------------- */ |
524 |
/* -------------------------------------------------------------------- */ |
Lines 429-435
Link Here
|
429 |
private MofPackage getMOFModelPackage() { |
528 |
private MofPackage getMOFModelPackage() { |
430 |
ModelPackage mofPackage = (ModelPackage) getExtent(getMOFInstanceName()); |
529 |
ModelPackage mofPackage = (ModelPackage) getExtent(getMOFInstanceName()); |
431 |
MofPackage result; |
530 |
MofPackage result; |
432 |
|
531 |
|
433 |
for (Iterator it = mofPackage.getMofPackage().refAllOfClass().iterator(); it.hasNext();) { |
532 |
for (Iterator it = mofPackage.getMofPackage().refAllOfClass().iterator(); it.hasNext();) { |
434 |
result = (MofPackage) it.next(); |
533 |
result = (MofPackage) it.next(); |
435 |
if (result.getName().equals("Model")) { |
534 |
if (result.getName().equals("Model")) { |
Lines 440-446
Link Here
|
440 |
return null; |
539 |
return null; |
441 |
} |
540 |
} |
442 |
|
541 |
|
443 |
/** |
542 |
/** |
444 |
* Initializes the repository, if not already initialized: creates and |
543 |
* Initializes the repository, if not already initialized: creates and |
445 |
* initializes the {@link org.netbeans.mdr.storagemodel.MDRStorage}. If |
544 |
* initializes the {@link org.netbeans.mdr.storagemodel.MDRStorage}. If |
446 |
* necessary the repository is bootstrapped. |
545 |
* necessary the repository is bootstrapped. |
Lines 448-454
Link Here
|
448 |
private synchronized void initCheck() { |
547 |
private synchronized void initCheck() { |
449 |
if (mdrStorage == null) { |
548 |
if (mdrStorage == null) { |
450 |
String storageClass = (String) parameters.get(PARAM_STORAGE_CLASS); |
549 |
String storageClass = (String) parameters.get(PARAM_STORAGE_CLASS); |
451 |
|
550 |
|
452 |
mdrStorage = new MdrStorage(this, storageClass, this.parameters); |
551 |
mdrStorage = new MdrStorage(this, storageClass, this.parameters); |
453 |
try { |
552 |
try { |
454 |
System.out.println("initializing..."); |
553 |
System.out.println("initializing..."); |
Lines 465-475
Link Here
|
465 |
} |
564 |
} |
466 |
} |
565 |
} |
467 |
} |
566 |
} |
468 |
|
567 |
|
469 |
/* -------------------------------------------------------------------- */ |
568 |
/* -------------------------------------------------------------------- */ |
470 |
/* -- Helper methods for extent creation (private) -------------------- */ |
569 |
/* -- Helper methods for extent creation (private) -------------------- */ |
471 |
/* -------------------------------------------------------------------- */ |
570 |
/* -------------------------------------------------------------------- */ |
472 |
|
571 |
|
473 |
/** |
572 |
/** |
474 |
* Helper method needed for the creation of a new outermost package instance. |
573 |
* Helper method needed for the creation of a new outermost package instance. |
475 |
* Puts <code>pkg</code> and, recursively, all its nested packages |
574 |
* Puts <code>pkg</code> and, recursively, all its nested packages |
Lines 480-488
Link Here
|
480 |
* of their meta-objects as key |
579 |
* of their meta-objects as key |
481 |
* @exception CreationFailedException if two different packages with the |
580 |
* @exception CreationFailedException if two different packages with the |
482 |
* same keys are added to <code>packages</code> |
581 |
* same keys are added to <code>packages</code> |
483 |
* |
582 |
* |
484 |
*/ |
583 |
*/ |
485 |
private void collectPackageInstances(RefPackage pkg, Map packages) throws CreationFailedException { |
584 |
private void collectPackageInstances(RefPackage pkg, Map packages) throws CreationFailedException { |
486 |
Object result = packages.put(pkg.refMetaObject().refMofId(), pkg); |
585 |
Object result = packages.put(pkg.refMetaObject().refMofId(), pkg); |
487 |
if (result != null && !result.equals(pkg)) { |
586 |
if (result != null && !result.equals(pkg)) { |
488 |
throw new CreationFailedException("The provided list of existing package instances contains duplicities."); |
587 |
throw new CreationFailedException("The provided list of existing package instances contains duplicities."); |
Lines 492-498
Link Here
|
492 |
collectPackageInstances(nested, packages); |
591 |
collectPackageInstances(nested, packages); |
493 |
} |
592 |
} |
494 |
} |
593 |
} |
495 |
|
594 |
|
496 |
/** Instantiates given package, i.e. packageProxies, classProxies, |
595 |
/** Instantiates given package, i.e. packageProxies, classProxies, |
497 |
* associationProxies. |
596 |
* associationProxies. |
498 |
* |
597 |
* |
Lines 500-517
Link Here
|
500 |
* @param metaPackage outermost M2 package |
599 |
* @param metaPackage outermost M2 package |
501 |
* @param clusteredInstances maps MOF IDs of M2 packages to M1 package instances |
600 |
* @param clusteredInstances maps MOF IDs of M2 packages to M1 package instances |
502 |
* @param storageId ID of the storage partition |
601 |
* @param storageId ID of the storage partition |
503 |
*/ |
602 |
*/ |
504 |
private RefPackage instantiatePackage(String substName, StorablePackage immediatePackage, MofPackage metaPackage, Map clusteredInstances, String storageId, boolean clustered) { |
603 |
private RefPackage instantiatePackage(String substName, StorablePackage immediatePackage, MofPackage metaPackage, Map clusteredInstances, String storageId, boolean clustered) { |
505 |
// Create package proxy |
604 |
// Create package proxy |
506 |
StorablePackage newPackage = createPackageHandler(metaPackage, immediatePackage, substName, storageId, clustered); |
605 |
StorablePackage newPackage = createPackageHandler(metaPackage, immediatePackage, substName, storageId, clustered); |
507 |
System.out.println("new package: " + newPackage.getMofId() + ", metapackage: " + metaPackage.refMofId()); |
606 |
System.out.println("new package: " + newPackage.getMofId() + ", metapackage: " + metaPackage.refMofId()); |
508 |
|
607 |
|
509 |
Log.out.indent(); |
608 |
Log.out.indent(); |
510 |
|
609 |
|
511 |
Set localAssocProxies = new HashSet(); |
610 |
Set localAssocProxies = new HashSet(); |
512 |
Map localClassProxies = new HashMap(); |
611 |
Map localClassProxies = new HashMap(); |
513 |
instantiatePackageContent(metaPackage, newPackage, clusteredInstances, localClassProxies, localAssocProxies); |
612 |
instantiatePackageContent(metaPackage, newPackage, clusteredInstances, localClassProxies, localAssocProxies); |
514 |
resolveSuperclasses(localClassProxies); |
613 |
resolveSuperclasses(localClassProxies); |
515 |
|
614 |
|
516 |
// [PENDING] need to fix the mutex ordering and NPE and then uncomment this |
615 |
// [PENDING] need to fix the mutex ordering and NPE and then uncomment this |
517 |
/* |
616 |
/* |
Lines 525-531
Link Here
|
525 |
return (RefPackage) BaseObjectHandler.getHandler(newPackage); |
624 |
return (RefPackage) BaseObjectHandler.getHandler(newPackage); |
526 |
} |
625 |
} |
527 |
|
626 |
|
528 |
|
627 |
|
529 |
/** |
628 |
/** |
530 |
* @param localClassProxies |
629 |
* @param localClassProxies |
531 |
*/ |
630 |
*/ |
Lines 586-592
Link Here
|
586 |
} |
685 |
} |
587 |
sc.addSuperclass(current.getMofId()); |
686 |
sc.addSuperclass(current.getMofId()); |
588 |
current.addSubclass(sc.getMofId()); |
687 |
current.addSubclass(sc.getMofId()); |
589 |
} |
688 |
} |
590 |
for (Iterator contents = cls.getContents().iterator(); contents.hasNext();) { |
689 |
for (Iterator contents = cls.getContents().iterator(); contents.hasNext();) { |
591 |
me = (ModelElement) contents.next(); |
690 |
me = (ModelElement) contents.next(); |
592 |
if (me instanceof Reference) { |
691 |
if (me instanceof Reference) { |
Lines 614-629
Link Here
|
614 |
} |
713 |
} |
615 |
if (indexTags.size() > 0) { |
714 |
if (indexTags.size() > 0) { |
616 |
try { |
715 |
try { |
617 |
sc.buildAdditionalIndexes (indexTags, associationProxies); |
716 |
sc.buildAdditionalIndexes(indexTags, associationProxies); |
618 |
} catch (StorageException e) { |
717 |
} catch (StorageException e) { |
619 |
throw new DebugException ("Storage exception: " + e); |
718 |
throw new DebugException("Storage exception: " + e); |
620 |
} |
719 |
} |
621 |
} |
720 |
} |
622 |
*/ |
721 |
*/ |
623 |
} // for |
722 |
} // for |
624 |
|
723 |
|
625 |
} |
724 |
} |
626 |
|
725 |
|
627 |
/** |
726 |
/** |
628 |
* @param metaPackage |
727 |
* @param metaPackage |
629 |
* @param newPackage |
728 |
* @param newPackage |
Lines 633-656
Link Here
|
633 |
*/ |
732 |
*/ |
634 |
private void instantiatePackageContent(MofPackage metaPackage, StorablePackage newPackage, Map clusteredInstances, Map localClassProxies, Set localAssocProxies) { |
733 |
private void instantiatePackageContent(MofPackage metaPackage, StorablePackage newPackage, Map clusteredInstances, Map localClassProxies, Set localAssocProxies) { |
635 |
Iterator superTypes = metaPackage.allSupertypes().iterator(); |
734 |
Iterator superTypes = metaPackage.allSupertypes().iterator(); |
636 |
boolean thisTypeNotProcessed = true; |
735 |
boolean thisTypeNotProcessed = true; |
637 |
while (thisTypeNotProcessed || superTypes.hasNext()) { |
736 |
while (thisTypeNotProcessed || superTypes.hasNext()) { |
638 |
Iterator it; |
737 |
Iterator it; |
639 |
if (thisTypeNotProcessed) { |
738 |
if (thisTypeNotProcessed) { |
640 |
it = metaPackage.getContents().iterator(); |
739 |
it = metaPackage.getContents().iterator(); |
641 |
thisTypeNotProcessed = false; |
740 |
thisTypeNotProcessed = false; |
642 |
} else |
741 |
} else |
643 |
it = ((MofPackage) superTypes.next ()).getContents().iterator(); |
742 |
it = ((MofPackage) superTypes.next()).getContents().iterator(); |
644 |
|
743 |
|
645 |
while (it.hasNext()) { |
744 |
while (it.hasNext()) { |
646 |
Object o = it.next(); |
745 |
Object o = it.next(); |
647 |
ModelElement element = (ModelElement) o; |
746 |
ModelElement element = (ModelElement) o; |
648 |
|
747 |
|
649 |
if (element instanceof javax.jmi.model.MofClass) { |
748 |
if (element instanceof javax.jmi.model.MofClass) { |
650 |
createClassProxyHandler((javax.jmi.model.MofClass) element, newPackage, localClassProxies); |
749 |
createClassProxyHandler((javax.jmi.model.MofClass) element, newPackage, localClassProxies); |
651 |
} else if (element instanceof javax.jmi.model.Association) { |
750 |
} else if (element instanceof javax.jmi.model.Association) { |
652 |
Association assoc = (Association) element; |
751 |
Association assoc = (Association) element; |
653 |
|
752 |
|
654 |
Collection content = assoc.getContents(); |
753 |
Collection content = assoc.getContents(); |
655 |
int i = 0; |
754 |
int i = 0; |
656 |
AssociationEnd ends[] = new AssociationEnd[2]; |
755 |
AssociationEnd ends[] = new AssociationEnd[2]; |
Lines 664-670
Link Here
|
664 |
boolean orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, indexedA, indexedB; |
763 |
boolean orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, indexedA, indexedB; |
665 |
int minA, maxA, minB, maxB; |
764 |
int minA, maxA, minB, maxB; |
666 |
Class typeA, typeB; |
765 |
Class typeA, typeB; |
667 |
|
766 |
|
668 |
minA = ends[0].getMultiplicity().getLower(); |
767 |
minA = ends[0].getMultiplicity().getLower(); |
669 |
maxA = ends[0].getMultiplicity().getUpper(); |
768 |
maxA = ends[0].getMultiplicity().getUpper(); |
670 |
minB = ends[1].getMultiplicity().getLower(); |
769 |
minB = ends[1].getMultiplicity().getLower(); |
Lines 680-715
Link Here
|
680 |
orderB = (ends[1].getMultiplicity().isOrdered()); |
779 |
orderB = (ends[1].getMultiplicity().isOrdered()); |
681 |
uniqueA = (ends[0].getMultiplicity().isUnique()); |
780 |
uniqueA = (ends[0].getMultiplicity().isUnique()); |
682 |
uniqueB = (ends[1].getMultiplicity().isUnique()); |
781 |
uniqueB = (ends[1].getMultiplicity().isUnique()); |
683 |
|
782 |
|
684 |
aggrA = ends[0].getAggregation().equals(AggregationKindEnum.COMPOSITE); |
783 |
aggrA = ends[0].getAggregation().equals(AggregationKindEnum.COMPOSITE); |
685 |
aggrB = ends[1].getAggregation().equals(AggregationKindEnum.COMPOSITE); |
784 |
aggrB = ends[1].getAggregation().equals(AggregationKindEnum.COMPOSITE); |
686 |
|
785 |
|
687 |
indexedA = TagSupport.getTagValue ((StorableObject) ((BaseObjectHandler) ends[0])._getDelegate(), TAGID_INDEX) != null; |
786 |
indexedA = TagSupport.getTagValue((StorableObject) ((BaseObjectHandler) ends[0])._getDelegate(), TAGID_INDEX) != null; |
688 |
indexedB = TagSupport.getTagValue ((StorableObject) ((BaseObjectHandler) ends[1])._getDelegate(), TAGID_INDEX) != null; |
787 |
indexedB = TagSupport.getTagValue((StorableObject) ((BaseObjectHandler) ends[1])._getDelegate(), TAGID_INDEX) != null; |
689 |
if (TagProvider.getTagValue (ends[0].getType (), TRANSIENT_TAG_ID, "").equals (TAG_VALUE_TRUE) |
788 |
if (TagProvider.getTagValue(ends[0].getType(), TRANSIENT_TAG_ID, "").equals(TAG_VALUE_TRUE) |
690 |
|| TagProvider.getTagValue (ends[1].getType (), TRANSIENT_TAG_ID, "").equals (TAG_VALUE_TRUE)) { |
789 |
|| TagProvider.getTagValue(ends[1].getType(), TRANSIENT_TAG_ID, "").equals(TAG_VALUE_TRUE)) { |
691 |
createTransientAssociationHandler((javax.jmi.model.Association) element, newPackage, ends[0].getName(), ends[0].refMofId(), ends[1].getName(), ends[1].refMofId(), typeA, typeB, minA, maxA, minB, maxB, orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, localAssocProxies); |
790 |
createTransientAssociationHandler((javax.jmi.model.Association) element, newPackage, ends[0].getName(), ends[0].refMofId(), ends[1].getName(), ends[1].refMofId(), typeA, typeB, minA, maxA, minB, maxB, orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, localAssocProxies); |
692 |
} |
791 |
} |
693 |
else { |
792 |
else { |
694 |
createAssociationHandler((javax.jmi.model.Association) element, newPackage, ends[0].getName(), ends[0].refMofId(), ends[1].getName(), ends[1].refMofId(), typeA, typeB, minA, maxA, minB, maxB, orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, indexedA, indexedB, localAssocProxies); |
793 |
createAssociationHandler((javax.jmi.model.Association) element, newPackage, ends[0].getName(), ends[0].refMofId(), ends[1].getName(), ends[1].refMofId(), typeA, typeB, minA, maxA, minB, maxB, orderA, orderB, uniqueA, uniqueB, aggrA, aggrB, indexedA, indexedB, localAssocProxies); |
695 |
} |
794 |
} |
696 |
|
795 |
|
697 |
} else if (element instanceof MofPackage) { |
796 |
} else if (element instanceof MofPackage) { |
698 |
// System.out.println("found inner package"); |
797 |
// System.out.println("found inner package"); |
699 |
// System.out.println("creating: META: " + element.refMofId() + ", IMMEDIATE: " + newPackage.refMofId() + ", CONTEXT: " + context); |
798 |
// System.out.println("creating: META: " + element.refMofId() + ", IMMEDIATE: " + newPackage.refMofId() + ", CONTEXT: " + context); |
700 |
String storageId = MdrStorage.getStorageIdFromMofId (newPackage.getMofId()); |
799 |
String storageId = MdrStorage.getStorageIdFromMofId(newPackage.getMofId()); |
701 |
StorablePackage pkg = createPackageHandler((MofPackage) element, newPackage, null, storageId, false); |
800 |
StorablePackage pkg = createPackageHandler((MofPackage) element, newPackage, null, storageId, false); |
702 |
instantiatePackageContent((MofPackage) element, pkg, clusteredInstances, localClassProxies, localAssocProxies); |
801 |
instantiatePackageContent((MofPackage) element, pkg, clusteredInstances, localClassProxies, localAssocProxies); |
703 |
} else if (element instanceof Import) { |
802 |
} else if (element instanceof Import) { |
704 |
Import imp = (Import) element; |
803 |
Import imp = (Import) element; |
705 |
|
804 |
|
706 |
if (imp.isClustered()) { |
805 |
if (imp.isClustered()) { |
707 |
ModelElement metaElement = imp.getImportedNamespace(); |
806 |
ModelElement metaElement = imp.getImportedNamespace(); |
708 |
if (metaElement instanceof MofPackage) { |
807 |
if (metaElement instanceof MofPackage) { |
709 |
MofPackage metaPkg = (MofPackage) metaElement; |
808 |
MofPackage metaPkg = (MofPackage) metaElement; |
710 |
RefPackage pkg = (RefPackage) clusteredInstances.get(metaPkg.refMofId()); |
809 |
RefPackage pkg = (RefPackage) clusteredInstances.get(metaPkg.refMofId()); |
711 |
if (pkg == null) { |
810 |
if (pkg == null) { |
712 |
String storageId = MdrStorage.getStorageIdFromMofId (newPackage.getMofId()); |
811 |
String storageId = MdrStorage.getStorageIdFromMofId(newPackage.getMofId()); |
713 |
pkg = instantiatePackage(null, newPackage, metaPkg, clusteredInstances, storageId, true); |
812 |
pkg = instantiatePackage(null, newPackage, metaPkg, clusteredInstances, storageId, true); |
714 |
clusteredInstances.put(metaPkg.refMofId(), pkg); |
813 |
clusteredInstances.put(metaPkg.refMofId(), pkg); |
715 |
} else { |
814 |
} else { |
Lines 750-763
Link Here
|
750 |
// this package was already collected |
849 |
// this package was already collected |
751 |
return; |
850 |
return; |
752 |
} |
851 |
} |
753 |
classProxies.put((MofClass) cls.refMetaObject(), ((BaseObjectHandler) cls)._getDelegate()); |
852 |
classProxies.put((MofClass) cls.refMetaObject(), ((BaseObjectHandler) cls)._getDelegate()); |
754 |
} |
853 |
} |
755 |
|
854 |
|
756 |
for (Iterator it = pkg.refAllPackages().iterator(); it.hasNext();) { |
855 |
for (Iterator it = pkg.refAllPackages().iterator(); it.hasNext();) { |
757 |
collectAllProxies((RefPackage) it.next()); |
856 |
collectAllProxies((RefPackage) it.next()); |
758 |
} |
857 |
} |
759 |
} |
858 |
} |
760 |
|
859 |
|
761 |
/* -------------------------------------------------------------------- */ |
860 |
/* -------------------------------------------------------------------- */ |
762 |
/* -- Helper methods for handler creation (private) ------------------- */ |
861 |
/* -- Helper methods for handler creation (private) ------------------- */ |
763 |
/* -------------------------------------------------------------------- */ |
862 |
/* -------------------------------------------------------------------- */ |
Lines 778-784
Link Here
|
778 |
ModelElement me; |
877 |
ModelElement me; |
779 |
List members = new ArrayList(); |
878 |
List members = new ArrayList(); |
780 |
List memberTypes = new ArrayList(); |
879 |
List memberTypes = new ArrayList(); |
781 |
|
880 |
|
782 |
for (Iterator it2 = ((StructureType) element).getContents().iterator(); it2.hasNext();) { |
881 |
for (Iterator it2 = ((StructureType) element).getContents().iterator(); it2.hasNext();) { |
783 |
me = (ModelElement) it2.next(); |
882 |
me = (ModelElement) it2.next(); |
784 |
if (me instanceof StructureField) { |
883 |
if (me instanceof StructureField) { |
Lines 795-801
Link Here
|
795 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, element.getQualifiedName(), members, memberTypes, ifcName, storageId)); |
894 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, element.getQualifiedName(), members, memberTypes, ifcName, storageId)); |
796 |
} |
895 |
} |
797 |
} |
896 |
} |
798 |
|
897 |
|
799 |
StorablePackage result = null; |
898 |
StorablePackage result = null; |
800 |
if (storageId != null) { |
899 |
if (storageId != null) { |
801 |
result = new StorablePackage(mdrStorage, immediatePackage == null ? null : immediatePackage.getMofId(), metaObject.refMofId(), context, datatypes, storageId); |
900 |
result = new StorablePackage(mdrStorage, immediatePackage == null ? null : immediatePackage.getMofId(), metaObject.refMofId(), context, datatypes, storageId); |
Lines 806-818
Link Here
|
806 |
if (immediatePackage != null && !clustered) { |
905 |
if (immediatePackage != null && !clustered) { |
807 |
immediatePackage.addPackage(metaObject.getName(), result.getMofId()); |
906 |
immediatePackage.addPackage(metaObject.getName(), result.getMofId()); |
808 |
} |
907 |
} |
809 |
|
908 |
|
810 |
return result; |
909 |
return result; |
811 |
} catch ( StorageException e ) { |
910 |
} catch ( StorageException e ) { |
812 |
throw new DebugException("Storage exception: " + e.getMessage()); |
911 |
throw new DebugException("Storage exception: " + e.getMessage()); |
813 |
} |
912 |
} |
814 |
} |
913 |
} |
815 |
|
914 |
|
816 |
/** Creates handler for Class Proxy */ |
915 |
/** Creates handler for Class Proxy */ |
817 |
private StorableClass createClassProxyHandler(javax.jmi.model.MofClass metaObject, StorablePackage immediatePackage, Map localClassProxies) { |
916 |
private StorableClass createClassProxyHandler(javax.jmi.model.MofClass metaObject, StorablePackage immediatePackage, Map localClassProxies) { |
818 |
ModelElement element; |
917 |
ModelElement element; |
Lines 854-865
Link Here
|
854 |
if (element instanceof EnumerationType) { |
953 |
if (element instanceof EnumerationType) { |
855 |
List members = new ArrayList(((EnumerationType) element).getLabels()); |
954 |
List members = new ArrayList(((EnumerationType) element).getLabels()); |
856 |
String ifcName = TagSupport.getTypeFullName((StorableObject) ((BaseObjectHandler) element)._getDelegate()); |
955 |
String ifcName = TagSupport.getTypeFullName((StorableObject) ((BaseObjectHandler) element)._getDelegate()); |
857 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, members, ifcName, MdrStorage.getStorageIdFromMofId (immediatePackage.getMofId()))); |
956 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, members, ifcName, MdrStorage.getStorageIdFromMofId(immediatePackage.getMofId()))); |
858 |
} else if (element instanceof StructureType) { |
957 |
} else if (element instanceof StructureType) { |
859 |
ModelElement me; |
958 |
ModelElement me; |
860 |
List members = new ArrayList(); |
959 |
List members = new ArrayList(); |
861 |
List memberTypes = new ArrayList(); |
960 |
List memberTypes = new ArrayList(); |
862 |
|
961 |
|
863 |
for (Iterator it2 = ((StructureType) element).getContents().iterator(); it2.hasNext();) { |
962 |
for (Iterator it2 = ((StructureType) element).getContents().iterator(); it2.hasNext();) { |
864 |
me = (ModelElement) it2.next(); |
963 |
me = (ModelElement) it2.next(); |
865 |
if (me instanceof StructureField) { |
964 |
if (me instanceof StructureField) { |
Lines 873-879
Link Here
|
873 |
} |
972 |
} |
874 |
} |
973 |
} |
875 |
String ifcName = TagSupport.getTypeFullName((StorableObject) ((BaseObjectHandler) element)._getDelegate()); |
974 |
String ifcName = TagSupport.getTypeFullName((StorableObject) ((BaseObjectHandler) element)._getDelegate()); |
876 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, element.getQualifiedName(), members, memberTypes, ifcName, MdrStorage.getStorageIdFromMofId (immediatePackage.getMofId()))); |
975 |
datatypes.put(element.getName(), new DatatypeDescriptor(mdrStorage, element.getQualifiedName(), members, memberTypes, ifcName, MdrStorage.getStorageIdFromMofId(immediatePackage.getMofId()))); |
877 |
} |
976 |
} |
878 |
isDerived = false; |
977 |
isDerived = false; |
879 |
isInterceptable = false; |
978 |
isInterceptable = false; |
Lines 888-947
Link Here
|
888 |
} |
987 |
} |
889 |
} |
988 |
} |
890 |
|
989 |
|
891 |
String tagValue = TagProvider.getTagValue (metaObject, TRANSIENT_TAG_ID, ""); |
990 |
String tagValue = TagProvider.getTagValue(metaObject, TRANSIENT_TAG_ID, ""); |
892 |
if (tagValue.equals (TAG_VALUE_TRUE)) { |
991 |
if (tagValue.equals(TAG_VALUE_TRUE)) { |
893 |
storable = new TransientStorableClass(mdrStorage, immediatePackage.getMofId(), |
992 |
storable = new TransientStorableClass(mdrStorage, immediatePackage.getMofId(), |
894 |
metaObject.refMofId(), attrDescs, clAttrDescs, datatypes, classDerived, |
993 |
metaObject.refMofId(), attrDescs, clAttrDescs, datatypes, classDerived, |
895 |
instanceDerived, metaObject.isSingleton(), metaObject.isAbstract()); |
994 |
instanceDerived, metaObject.isSingleton(), metaObject.isAbstract()); |
896 |
} |
995 |
} |
897 |
else { |
996 |
else { |
898 |
storable = new StorableClass(mdrStorage, immediatePackage.getMofId(), |
997 |
storable = new StorableClass(mdrStorage, immediatePackage.getMofId(), |
899 |
metaObject.refMofId(), attrDescs, clAttrDescs, datatypes, classDerived, |
998 |
metaObject.refMofId(), attrDescs, clAttrDescs, datatypes, classDerived, |
900 |
instanceDerived, metaObject.isSingleton(), metaObject.isAbstract()); |
999 |
instanceDerived, metaObject.isSingleton(), metaObject.isAbstract()); |
901 |
} |
1000 |
} |
902 |
|
1001 |
|
903 |
immediatePackage.addClass(metaObject.getName(), storable.getMofId()); |
1002 |
immediatePackage.addClass(metaObject.getName(), storable.getMofId()); |
904 |
classProxies.put(metaObject, storable); |
1003 |
classProxies.put(metaObject, storable); |
905 |
classProxiesMofIds.put(metaObject.refMofId(), storable.getMofId()); |
1004 |
classProxiesMofIds.put(metaObject.refMofId(), storable.getMofId()); |
906 |
localClassProxies.put(metaObject, storable); |
1005 |
localClassProxies.put(metaObject, storable); |
907 |
return storable; |
1006 |
return storable; |
908 |
} catch ( StorageException e ) { |
1007 |
} catch ( StorageException e ) { |
909 |
e.printStackTrace (); |
1008 |
e.printStackTrace(); |
910 |
throw new DebugException("Storage exception: " + e.getMessage()); |
1009 |
throw new DebugException("Storage exception: " + e.getMessage()); |
911 |
} |
1010 |
} |
912 |
} |
1011 |
} |
913 |
|
1012 |
|
914 |
/** Creates handler for Association */ |
1013 |
/** Creates handler for Association */ |
915 |
private StorableAssociation createAssociationHandler( |
1014 |
private StorableAssociation createAssociationHandler( |
916 |
javax.jmi.model.Association metaObject, |
1015 |
javax.jmi.model.Association metaObject, |
917 |
StorablePackage immediatePackage, |
1016 |
StorablePackage immediatePackage, |
918 |
String assocationEnd1, String assocEnd1MofId, |
1017 |
String assocationEnd1, String assocEnd1MofId, |
919 |
String assocationEnd2, String assocEnd2MofId, |
1018 |
String assocationEnd2, String assocEnd2MofId, |
920 |
Class type1, Class type2, |
1019 |
Class type1, Class type2, |
921 |
int min1, int max1, |
1020 |
int min1, int max1, |
922 |
int min2, int max2, |
1021 |
int min2, int max2, |
923 |
boolean isOrdered1, |
1022 |
boolean isOrdered1, |
924 |
boolean isOrdered2, |
1023 |
boolean isOrdered2, |
925 |
boolean isUnique1, |
1024 |
boolean isUnique1, |
926 |
boolean isUnique2, |
1025 |
boolean isUnique2, |
927 |
boolean isAggr1, |
1026 |
boolean isAggr1, |
928 |
boolean isAggr2, |
1027 |
boolean isAggr2, |
929 |
boolean isIndexed1, |
1028 |
boolean isIndexed1, |
930 |
boolean isIndexed2, |
1029 |
boolean isIndexed2, |
931 |
Set localAssocProxies) { |
1030 |
Set localAssocProxies) { |
932 |
|
1031 |
|
933 |
try { |
1032 |
try { |
934 |
StorableAssociation result = new StorableAssociation( |
1033 |
StorableAssociation result = new StorableAssociation( |
935 |
mdrStorage, |
1034 |
mdrStorage, |
936 |
immediatePackage.getMofId(), |
1035 |
immediatePackage.getMofId(), |
937 |
metaObject.refMofId(), |
1036 |
metaObject.refMofId(), |
938 |
assocationEnd1, assocEnd1MofId, assocationEnd2, assocEnd2MofId, |
1037 |
assocationEnd1, assocEnd1MofId, assocationEnd2, assocEnd2MofId, |
939 |
type1, type2, |
1038 |
type1, type2, |
940 |
min1, max1, min2, max2, |
1039 |
min1, max1, min2, max2, |
941 |
isOrdered1, isOrdered2, |
1040 |
isOrdered1, isOrdered2, |
942 |
isUnique1, isUnique2, |
1041 |
isUnique1, isUnique2, |
943 |
isAggr1, isAggr2, |
1042 |
isAggr1, isAggr2, |
944 |
isIndexed1, isIndexed2); |
1043 |
isIndexed1, isIndexed2); |
945 |
immediatePackage.addAssociation(metaObject.getName(), result.getMofId()); |
1044 |
immediatePackage.addAssociation(metaObject.getName(), result.getMofId()); |
946 |
associationProxies.put(metaObject.refMofId(), result.getMofId()); |
1045 |
associationProxies.put(metaObject.refMofId(), result.getMofId()); |
947 |
localAssocProxies.add(result.getMofId()); |
1046 |
localAssocProxies.add(result.getMofId()); |
Lines 952-983
Link Here
|
952 |
} |
1051 |
} |
953 |
|
1052 |
|
954 |
private StorableAssociation createTransientAssociationHandler( |
1053 |
private StorableAssociation createTransientAssociationHandler( |
955 |
javax.jmi.model.Association metaObject, |
1054 |
javax.jmi.model.Association metaObject, |
956 |
StorablePackage immediatePackage, |
1055 |
StorablePackage immediatePackage, |
957 |
String assocationEnd1, String assocEnd1MofId, |
1056 |
String assocationEnd1, String assocEnd1MofId, |
958 |
String assocationEnd2, String assocEnd2MofId, |
1057 |
String assocationEnd2, String assocEnd2MofId, |
959 |
Class type1, Class type2, |
1058 |
Class type1, Class type2, |
960 |
int min1, int max1, |
1059 |
int min1, int max1, |
961 |
int min2, int max2, |
1060 |
int min2, int max2, |
962 |
boolean isOrdered1, |
1061 |
boolean isOrdered1, |
963 |
boolean isOrdered2, |
1062 |
boolean isOrdered2, |
964 |
boolean isUnique1, |
1063 |
boolean isUnique1, |
965 |
boolean isUnique2, |
1064 |
boolean isUnique2, |
966 |
boolean isAggr1, |
1065 |
boolean isAggr1, |
967 |
boolean isAggr2, |
1066 |
boolean isAggr2, |
968 |
Set localAssocProxies) { |
1067 |
Set localAssocProxies) { |
969 |
|
1068 |
|
970 |
try { |
1069 |
try { |
971 |
StorableAssociation result = new TransientStorableAssociation( |
1070 |
StorableAssociation result = new TransientStorableAssociation( |
972 |
mdrStorage, |
1071 |
mdrStorage, |
973 |
immediatePackage.getMofId(), |
1072 |
immediatePackage.getMofId(), |
974 |
metaObject.refMofId(), |
1073 |
metaObject.refMofId(), |
975 |
assocationEnd1, assocEnd1MofId, assocationEnd2, assocEnd2MofId, |
1074 |
assocationEnd1, assocEnd1MofId, assocationEnd2, assocEnd2MofId, |
976 |
type1, type2, |
1075 |
type1, type2, |
977 |
min1, max1, min2, max2, |
1076 |
min1, max1, min2, max2, |
978 |
isOrdered1, isOrdered2, |
1077 |
isOrdered1, isOrdered2, |
979 |
isUnique1, isUnique2, |
1078 |
isUnique1, isUnique2, |
980 |
isAggr1, isAggr2); |
1079 |
isAggr1, isAggr2); |
981 |
immediatePackage.addAssociation(metaObject.getName(), result.getMofId()); |
1080 |
immediatePackage.addAssociation(metaObject.getName(), result.getMofId()); |
982 |
associationProxies.put(metaObject.refMofId(), result.getMofId()); |
1081 |
associationProxies.put(metaObject.refMofId(), result.getMofId()); |
983 |
localAssocProxies.add(result.getMofId()); |
1082 |
localAssocProxies.add(result.getMofId()); |
Lines 990-996
Link Here
|
990 |
/* -------------------------------------------------------------------- */ |
1089 |
/* -------------------------------------------------------------------- */ |
991 |
/* -- Methods for bootstrapping (private) ----------------------------- */ |
1090 |
/* -- Methods for bootstrapping (private) ----------------------------- */ |
992 |
/* -------------------------------------------------------------------- */ |
1091 |
/* -------------------------------------------------------------------- */ |
993 |
|
1092 |
|
994 |
/** |
1093 |
/** |
995 |
* Main bootstrapping method. |
1094 |
* Main bootstrapping method. |
996 |
*/ |
1095 |
*/ |
Lines 1002-1008
Link Here
|
1002 |
try { |
1101 |
try { |
1003 |
beginTrans(true); |
1102 |
beginTrans(true); |
1004 |
installFakeMof(); |
1103 |
installFakeMof(); |
1005 |
installPureMof(); |
1104 |
installPureMof(); |
1006 |
fail = false; |
1105 |
fail = false; |
1007 |
} catch (Throwable e) { |
1106 |
} catch (Throwable e) { |
1008 |
e.printStackTrace(); |
1107 |
e.printStackTrace(); |
Lines 1011-1037
Link Here
|
1011 |
endTrans(fail); |
1110 |
endTrans(fail); |
1012 |
} |
1111 |
} |
1013 |
Log.out.unindent(); |
1112 |
Log.out.unindent(); |
1014 |
} |
1113 |
} |
1015 |
|
1114 |
|
1016 |
/** Installs the fake MOF |
1115 |
/** Installs the fake MOF |
1017 |
*/ |
1116 |
*/ |
1018 |
private void installFakeMof() { |
1117 |
private void installFakeMof() { |
1019 |
Log.out.println("Creating boot MOF metamodel ..."); |
1118 |
Log.out.println("Creating boot MOF metamodel ..."); |
1020 |
|
1119 |
|
1021 |
try { |
1120 |
createBootMOF(); |
1022 |
RefPackage p = createExtent(BOOT_MOF, null, null); |
1121 |
if (getExtent(BOOT_MOF) == null) { |
1023 |
} catch (CreationFailedException e) { |
1122 |
throw new DebugException("Cannot create instance of BOOT_MOF: Fatal error during bootstrapping."); |
1024 |
e.printStackTrace(); |
|
|
1025 |
throw new DebugException("Cannot create instance of BOOT_MOF: " + e.getMessage()); |
1026 |
} |
1123 |
} |
1027 |
} |
1124 |
} |
1028 |
|
1125 |
|
1029 |
/** Programatically installs the pure MOF model. |
1126 |
/** Programatically installs the pure MOF model. |
1030 |
*/ |
1127 |
*/ |
1031 |
private void installPureMof() { |
1128 |
private void installPureMof() { |
1032 |
Log.out.println("Installing pure MOF Metamodel ... "); |
1129 |
Log.out.println("Installing pure MOF Metamodel ... "); |
1033 |
Log.out.indent(); |
1130 |
Log.out.indent(); |
1034 |
|
1131 |
|
1035 |
try { |
1132 |
try { |
1036 |
Log.out.println("Parsing MOF model to DOM represtentation ...."); |
1133 |
Log.out.println("Parsing MOF model to DOM represtentation ...."); |
1037 |
ModelPackage modelPackage = (ModelPackage) createExtent(PURE_MOF, getBMModelPackage()); |
1134 |
ModelPackage modelPackage = (ModelPackage) createExtent(PURE_MOF, getBMModelPackage()); |
Lines 1045-1051
Link Here
|
1045 |
Log.out.unindent(); |
1142 |
Log.out.unindent(); |
1046 |
} |
1143 |
} |
1047 |
} |
1144 |
} |
1048 |
|
1145 |
|
1049 |
/** |
1146 |
/** |
1050 |
* Returns the MOF Model package as a model element of the |
1147 |
* Returns the MOF Model package as a model element of the |
1051 |
* bootstrapping MOF model. Needed only during bootstrapping. |
1148 |
* bootstrapping MOF model. Needed only during bootstrapping. |
Lines 1063-1071
Link Here
|
1063 |
} |
1160 |
} |
1064 |
return null; |
1161 |
return null; |
1065 |
} |
1162 |
} |
1066 |
|
1163 |
|
1067 |
/** Reads the XMI description of the mof directly into reporitory |
1164 |
/** Reads the XMI description of the mof directly into reporitory |
1068 |
*/ |
1165 |
*/ |
1069 |
private void createBootMOF() { |
1166 |
private void createBootMOF() { |
1070 |
try { |
1167 |
try { |
1071 |
BootReader br = new BootReader(mdrStorage, BOOTMOF_XML_URL); |
1168 |
BootReader br = new BootReader(mdrStorage, BOOTMOF_XML_URL); |