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 org.jomc.model.Implementation;
43 import static org.jomc.ri.model.RuntimeModelObjects.BOOTSTRAP_CLASSLOADER_KEY;
44 import static org.jomc.ri.model.RuntimeModelObjects.classesByClassLoaderAndNameCache;
45 import static org.jomc.ri.model.RuntimeModelObjects.createMap;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
70
71
72 public class RuntimeImplementation extends Implementation implements RuntimeModelObject
73 {
74
75
76
77 private volatile URI locationUri;
78
79
80
81
82
83
84
85
86 public RuntimeImplementation( final Implementation implementation )
87 {
88 super( implementation );
89
90 if ( this.getAuthors() != null )
91 {
92 this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
93 }
94 if ( this.getDependencies() != null )
95 {
96 this.setDependencies( RuntimeModelObjects.getInstance().copyOf( this.getDependencies() ) );
97 }
98 if ( this.getDocumentation() != null )
99 {
100 this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
101 }
102 if ( this.getImplementations() != null )
103 {
104 this.setImplementations( RuntimeModelObjects.getInstance().copyOf( this.getImplementations() ) );
105 }
106 if ( this.getMessages() != null )
107 {
108 this.setMessages( RuntimeModelObjects.getInstance().copyOf( this.getMessages() ) );
109 }
110 if ( this.getProperties() != null )
111 {
112 this.setProperties( RuntimeModelObjects.getInstance().copyOf( this.getProperties() ) );
113 }
114 if ( this.getSpecifications() != null )
115 {
116 this.setSpecifications( RuntimeModelObjects.getInstance().copyOf( this.getSpecifications() ) );
117 }
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 @Override
135 public URI getLocationUri()
136 {
137 if ( this.locationUri == null )
138 {
139 this.locationUri = super.getLocationUri();
140 }
141
142 return this.locationUri;
143 }
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 @Override
164 public Class<?> getJavaClass( final ClassLoader classLoader ) throws ClassNotFoundException
165 {
166 Class<?> javaClass = null;
167
168 if ( this.getClazz() != null )
169 {
170 ClassLoader classLoaderKey = classLoader;
171 if ( classLoaderKey == null )
172 {
173 classLoaderKey = BOOTSTRAP_CLASSLOADER_KEY;
174 }
175
176 synchronized ( classesByClassLoaderAndNameCache )
177 {
178 Map<String, Reference<Class<?>>> map = classesByClassLoaderAndNameCache.get( classLoaderKey );
179
180 if ( map == null )
181 {
182 map = createMap();
183 classesByClassLoaderAndNameCache.put( classLoaderKey, map );
184 }
185
186 final Reference<Class<?>> reference = map.get( this.getClazz() );
187
188 if ( reference != null )
189 {
190 javaClass = reference.get();
191 }
192
193 if ( javaClass == null )
194 {
195 javaClass = super.getJavaClass( classLoader );
196 map.put( this.getClazz(), new WeakReference<Class<?>>( javaClass ) );
197 }
198 }
199 }
200
201 return javaClass;
202 }
203
204
205
206 public void gc()
207 {
208 this.gcOrClear( true, false );
209 }
210
211 public void clear()
212 {
213 this.locationUri = null;
214 this.gcOrClear( false, true );
215 }
216
217 private void gcOrClear( final boolean gc, final boolean clear )
218 {
219 if ( this.getAuthors() instanceof RuntimeModelObject )
220 {
221 if ( gc )
222 {
223 ( (RuntimeModelObject) this.getAuthors() ).gc();
224 }
225 if ( clear )
226 {
227 ( (RuntimeModelObject) this.getAuthors() ).clear();
228 }
229 }
230 if ( this.getDependencies() instanceof RuntimeModelObject )
231 {
232 if ( gc )
233 {
234 ( (RuntimeModelObject) this.getDependencies() ).gc();
235 }
236 if ( clear )
237 {
238 ( (RuntimeModelObject) this.getDependencies() ).clear();
239 }
240 }
241 if ( this.getDocumentation() instanceof RuntimeModelObject )
242 {
243 if ( gc )
244 {
245 ( (RuntimeModelObject) this.getDocumentation() ).gc();
246 }
247 if ( clear )
248 {
249 ( (RuntimeModelObject) this.getDocumentation() ).clear();
250 }
251 }
252 if ( this.getImplementations() instanceof RuntimeModelObject )
253 {
254 if ( gc )
255 {
256 ( (RuntimeModelObject) this.getImplementations() ).gc();
257 }
258 if ( clear )
259 {
260 ( (RuntimeModelObject) this.getImplementations() ).clear();
261 }
262 }
263 if ( this.getMessages() instanceof RuntimeModelObject )
264 {
265 if ( gc )
266 {
267 ( (RuntimeModelObject) this.getMessages() ).gc();
268 }
269 if ( clear )
270 {
271 ( (RuntimeModelObject) this.getMessages() ).clear();
272 }
273 }
274 if ( this.getProperties() instanceof RuntimeModelObject )
275 {
276 if ( gc )
277 {
278 ( (RuntimeModelObject) this.getProperties() ).gc();
279 }
280 if ( clear )
281 {
282 ( (RuntimeModelObject) this.getProperties() ).clear();
283 }
284 }
285 if ( this.getSpecifications() instanceof RuntimeModelObject )
286 {
287 if ( gc )
288 {
289 ( (RuntimeModelObject) this.getSpecifications() ).gc();
290 }
291 if ( clear )
292 {
293 ( (RuntimeModelObject) this.getSpecifications() ).clear();
294 }
295 }
296 }
297
298
299
300
301
302 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" )
303 public RuntimeImplementation()
304 {
305
306 super();
307
308 }
309
310
311
312
313
314
315
316
317 }