1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.jomc.ri.model;
37
38 import java.lang.ref.Reference;
39 import java.lang.ref.WeakReference;
40 import java.net.URI;
41 import java.util.Map;
42 import javax.xml.bind.annotation.XmlTransient;
43 import org.jomc.model.Implementation;
44 import org.jomc.model.JavaTypeName;
45 import org.jomc.model.ModelObjectException;
46 import static org.jomc.ri.model.RuntimeModelObjects.BOOTSTRAP_CLASSLOADER_KEY;
47 import static org.jomc.ri.model.RuntimeModelObjects.classesByClassLoaderAndNameCache;
48 import static org.jomc.ri.model.RuntimeModelObjects.createMap;
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
73
74
75 public class RuntimeImplementation extends Implementation implements RuntimeModelObject
76 {
77
78
79
80
81
82 private volatile URI locationUri;
83
84
85
86
87 @XmlTransient
88 private volatile JavaTypeName javaTypeName;
89
90
91
92
93
94
95
96
97 public RuntimeImplementation( final Implementation implementation )
98 {
99 super( implementation );
100
101 if ( this.getAuthors() != null )
102 {
103 this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
104 }
105 if ( this.getDependencies() != null )
106 {
107 this.setDependencies( RuntimeModelObjects.getInstance().copyOf( this.getDependencies() ) );
108 }
109 if ( this.getDocumentation() != null )
110 {
111 this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
112 }
113 if ( this.getImplementations() != null )
114 {
115 this.setImplementations( RuntimeModelObjects.getInstance().copyOf( this.getImplementations() ) );
116 }
117 if ( this.getMessages() != null )
118 {
119 this.setMessages( RuntimeModelObjects.getInstance().copyOf( this.getMessages() ) );
120 }
121 if ( this.getProperties() != null )
122 {
123 this.setProperties( RuntimeModelObjects.getInstance().copyOf( this.getProperties() ) );
124 }
125 if ( this.getSpecifications() != null )
126 {
127 this.setSpecifications( RuntimeModelObjects.getInstance().copyOf( this.getSpecifications() ) );
128 }
129 }
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151 @Override
152 public URI getLocationUri() throws ModelObjectException
153 {
154 if ( this.locationUri == null )
155 {
156 this.locationUri = super.getLocationUri();
157 }
158
159 return this.locationUri;
160 }
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185 @Override
186 public Class<?> getJavaClass( final ClassLoader classLoader )
187 throws ModelObjectException, ClassNotFoundException
188 {
189 Class<?> javaClass = null;
190
191 if ( this.getJavaTypeName() != null )
192 {
193 ClassLoader classLoaderKey = classLoader;
194 if ( classLoaderKey == null )
195 {
196 classLoaderKey = BOOTSTRAP_CLASSLOADER_KEY;
197 }
198
199 synchronized ( classesByClassLoaderAndNameCache )
200 {
201 Map<String, Reference<Class<?>>> map = classesByClassLoaderAndNameCache.get( classLoaderKey );
202
203 if ( map == null )
204 {
205 map = createMap();
206 classesByClassLoaderAndNameCache.put( classLoaderKey, map );
207 }
208
209 final Reference<Class<?>> reference = map.get( this.getJavaTypeName().getClassName() );
210
211 if ( reference != null )
212 {
213 javaClass = reference.get();
214 }
215
216 if ( javaClass == null )
217 {
218 javaClass = super.getJavaClass( classLoader );
219 map.put( this.getJavaTypeName().getClassName(), new WeakReference<Class<?>>( javaClass ) );
220 }
221 }
222 }
223
224 return javaClass;
225 }
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249 @Override
250 public JavaTypeName getJavaTypeName() throws ModelObjectException
251 {
252 if ( this.javaTypeName == null )
253 {
254 this.javaTypeName = super.getJavaTypeName();
255 }
256
257 return this.javaTypeName;
258 }
259
260
261
262 public void gc()
263 {
264 this.gcOrClear( true, false );
265 }
266
267 public void clear()
268 {
269 this.locationUri = null;
270 this.javaTypeName = null;
271 this.gcOrClear( false, true );
272 }
273
274 private void gcOrClear( final boolean gc, final boolean clear )
275 {
276 if ( this.getAuthors() instanceof RuntimeModelObject )
277 {
278 if ( gc )
279 {
280 ( (RuntimeModelObject) this.getAuthors() ).gc();
281 }
282 if ( clear )
283 {
284 ( (RuntimeModelObject) this.getAuthors() ).clear();
285 }
286 }
287 if ( this.getDependencies() instanceof RuntimeModelObject )
288 {
289 if ( gc )
290 {
291 ( (RuntimeModelObject) this.getDependencies() ).gc();
292 }
293 if ( clear )
294 {
295 ( (RuntimeModelObject) this.getDependencies() ).clear();
296 }
297 }
298 if ( this.getDocumentation() instanceof RuntimeModelObject )
299 {
300 if ( gc )
301 {
302 ( (RuntimeModelObject) this.getDocumentation() ).gc();
303 }
304 if ( clear )
305 {
306 ( (RuntimeModelObject) this.getDocumentation() ).clear();
307 }
308 }
309 if ( this.getImplementations() instanceof RuntimeModelObject )
310 {
311 if ( gc )
312 {
313 ( (RuntimeModelObject) this.getImplementations() ).gc();
314 }
315 if ( clear )
316 {
317 ( (RuntimeModelObject) this.getImplementations() ).clear();
318 }
319 }
320 if ( this.getMessages() instanceof RuntimeModelObject )
321 {
322 if ( gc )
323 {
324 ( (RuntimeModelObject) this.getMessages() ).gc();
325 }
326 if ( clear )
327 {
328 ( (RuntimeModelObject) this.getMessages() ).clear();
329 }
330 }
331 if ( this.getProperties() instanceof RuntimeModelObject )
332 {
333 if ( gc )
334 {
335 ( (RuntimeModelObject) this.getProperties() ).gc();
336 }
337 if ( clear )
338 {
339 ( (RuntimeModelObject) this.getProperties() ).clear();
340 }
341 }
342 if ( this.getSpecifications() instanceof RuntimeModelObject )
343 {
344 if ( gc )
345 {
346 ( (RuntimeModelObject) this.getSpecifications() ).gc();
347 }
348 if ( clear )
349 {
350 ( (RuntimeModelObject) this.getSpecifications() ).clear();
351 }
352 }
353 }
354
355
356
357
358
359 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
360 public RuntimeImplementation()
361 {
362
363 super();
364
365 }
366
367
368
369
370
371
372
373
374
375 }