1 | // SECTION-START[License Header] |
2 | // <editor-fold defaultstate="collapsed" desc=" Generated License "> |
3 | /* |
4 | * Java Object Management and Configuration |
5 | * Copyright (C) Christian Schulte, 2005-206 |
6 | * All rights reserved. |
7 | * |
8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions |
10 | * are met: |
11 | * |
12 | * o Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. |
14 | * |
15 | * o Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in |
17 | * the documentation and/or other materials provided with the |
18 | * distribution. |
19 | * |
20 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
22 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
23 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, |
24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | * |
31 | * $JOMC: DefaultObjectManager.java 4795 2013-04-21 09:09:02Z schulte $ |
32 | * |
33 | */ |
34 | // </editor-fold> |
35 | // SECTION-END |
36 | package org.jomc.ri; |
37 | |
38 | import java.io.IOException; |
39 | import java.lang.ref.Reference; |
40 | import java.lang.ref.WeakReference; |
41 | import java.lang.reflect.Array; |
42 | import java.lang.reflect.Constructor; |
43 | import java.lang.reflect.InvocationHandler; |
44 | import java.lang.reflect.InvocationTargetException; |
45 | import java.lang.reflect.Method; |
46 | import java.math.BigInteger; |
47 | import java.net.URI; |
48 | import java.text.MessageFormat; |
49 | import java.util.ArrayList; |
50 | import java.util.Collections; |
51 | import java.util.HashMap; |
52 | import java.util.LinkedList; |
53 | import java.util.List; |
54 | import java.util.Locale; |
55 | import java.util.Map; |
56 | import java.util.logging.Level; |
57 | import java.util.logging.LogRecord; |
58 | import org.jomc.ObjectManagementException; |
59 | import org.jomc.ObjectManager; |
60 | import org.jomc.ObjectManagerFactory; |
61 | import org.jomc.model.Dependency; |
62 | import org.jomc.model.Implementation; |
63 | import org.jomc.model.ImplementationReference; |
64 | import org.jomc.model.Implementations; |
65 | import org.jomc.model.Instance; |
66 | import org.jomc.model.Message; |
67 | import org.jomc.model.ModelObject; |
68 | import org.jomc.model.ModelObjectException; |
69 | import org.jomc.model.Module; |
70 | import org.jomc.model.Modules; |
71 | import org.jomc.model.Multiplicity; |
72 | import org.jomc.model.Property; |
73 | import org.jomc.model.Specification; |
74 | import org.jomc.model.SpecificationReference; |
75 | import org.jomc.model.Specifications; |
76 | import org.jomc.model.modlet.ModelHelper; |
77 | import org.jomc.modlet.Model; |
78 | import org.jomc.modlet.ModelContext; |
79 | import org.jomc.modlet.ModelContextFactory; |
80 | import org.jomc.modlet.ModelException; |
81 | import org.jomc.modlet.ModelValidationReport; |
82 | import org.jomc.ri.model.RuntimeModelObject; |
83 | import org.jomc.ri.model.RuntimeModules; |
84 | import org.jomc.spi.Invocation; |
85 | import org.jomc.spi.Invoker; |
86 | import org.jomc.spi.Listener; |
87 | import org.jomc.spi.Locator; |
88 | import org.jomc.spi.Scope; |
89 | import org.jomc.util.WeakIdentityHashMap; |
90 | |
91 | // SECTION-START[Documentation] |
92 | // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> |
93 | /** |
94 | * Default {@code ObjectManager} implementation. |
95 | * |
96 | * <dl> |
97 | * <dt><b>Identifier:</b></dt><dd>org.jomc.ri.DefaultObjectManager</dd> |
98 | * <dt><b>Name:</b></dt><dd>JOMC ⁑ RI ⁑ DefaultObjectManager</dd> |
99 | * <dt><b>Specifications:</b></dt> |
100 | * <dd>org.jomc.ObjectManager @ 1.0</dd> |
101 | * <dt><b>Abstract:</b></dt><dd>No</dd> |
102 | * <dt><b>Final:</b></dt><dd>No</dd> |
103 | * <dt><b>Stateless:</b></dt><dd>No</dd> |
104 | * </dl> |
105 | * |
106 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0 |
107 | * @version 1.2 |
108 | */ |
109 | // </editor-fold> |
110 | // SECTION-END |
111 | // SECTION-START[Annotations] |
112 | // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> |
113 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
114 | // </editor-fold> |
115 | // SECTION-END |
116 | public class DefaultObjectManager implements ObjectManager |
117 | { |
118 | // SECTION-START[Constructors] |
119 | // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> |
120 | /** Creates a new {@code DefaultObjectManager} instance. */ |
121 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
122 | public DefaultObjectManager() |
123 | { |
124 | // SECTION-START[Default Constructor] |
125 | super(); |
126 | // SECTION-END |
127 | } |
128 | // </editor-fold> |
129 | // SECTION-END |
130 | // SECTION-START[ObjectManager] |
131 | |
132 | public <T> T getObject( final Class<T> specification ) |
133 | { |
134 | if ( specification == null ) |
135 | { |
136 | throw new NullPointerException( "specification" ); |
137 | } |
138 | |
139 | try |
140 | { |
141 | this.initialize(); |
142 | |
143 | Class<?> specificationClass = specification; |
144 | if ( specification.isArray() ) |
145 | { |
146 | specificationClass = specification.getComponentType(); |
147 | } |
148 | |
149 | final ClassLoader classLoader = this.getDefaultClassLoader( specificationClass ); |
150 | final Modules model = this.getModules( classLoader ); |
151 | final Specification s = model.getSpecification( specificationClass ); |
152 | |
153 | if ( s == null ) |
154 | { |
155 | if ( this.isLoggable( Level.WARNING ) ) |
156 | { |
157 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
158 | Locale.getDefault(), specificationClass.getName() ), null ); |
159 | |
160 | } |
161 | |
162 | return null; |
163 | } |
164 | |
165 | if ( s.getMultiplicity() == Multiplicity.ONE && specification.isArray() ) |
166 | { |
167 | if ( this.isLoggable( Level.WARNING ) ) |
168 | { |
169 | this.log( classLoader, Level.WARNING, getIllegalArraySpecificationMessage( |
170 | Locale.getDefault(), s.getIdentifier(), s.getMultiplicity().value() ), null ); |
171 | |
172 | } |
173 | |
174 | return null; |
175 | } |
176 | |
177 | if ( s.getMultiplicity() != Multiplicity.ONE && !specification.isArray() ) |
178 | { |
179 | if ( this.isLoggable( Level.WARNING ) ) |
180 | { |
181 | this.log( classLoader, Level.WARNING, getIllegalObjectSpecificationMessage( |
182 | Locale.getDefault(), s.getIdentifier(), s.getMultiplicity().value() ), null ); |
183 | |
184 | } |
185 | |
186 | return null; |
187 | } |
188 | |
189 | Scope scope = null; |
190 | if ( s.getScope() != null ) |
191 | { |
192 | scope = this.getScope( s.getScope(), classLoader ); |
193 | |
194 | if ( scope == null ) |
195 | { |
196 | if ( this.isLoggable( Level.WARNING ) ) |
197 | { |
198 | this.log( classLoader, Level.WARNING, getMissingScopeMessage( |
199 | Locale.getDefault(), s.getScope() ), null ); |
200 | |
201 | } |
202 | |
203 | return null; |
204 | } |
205 | } |
206 | |
207 | final Implementations available = model.getImplementations( s.getIdentifier() ); |
208 | if ( available == null ) |
209 | { |
210 | if ( this.isLoggable( Level.WARNING ) ) |
211 | { |
212 | this.log( classLoader, Level.WARNING, getMissingImplementationsMessage( |
213 | Locale.getDefault(), s.getIdentifier() ), null ); |
214 | |
215 | } |
216 | |
217 | return null; |
218 | } |
219 | |
220 | int idx = 0; |
221 | final Object[] array = new Object[ available.getImplementation().size() ]; |
222 | |
223 | for ( int i = 0, s0 = available.getImplementation().size(); i < s0; i++ ) |
224 | { |
225 | final Implementation impl = available.getImplementation().get( i ); |
226 | |
227 | if ( impl.getLocation() != null ) |
228 | { |
229 | if ( s.getClazz() == null ) |
230 | { |
231 | if ( this.isLoggable( Level.WARNING ) ) |
232 | { |
233 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
234 | Locale.getDefault(), s.getIdentifier() ), null ); |
235 | |
236 | } |
237 | |
238 | return null; |
239 | } |
240 | |
241 | final Object o = this.getObject( s.getJavaTypeName().getClass( classLoader, true ), |
242 | impl.getLocationUri(), classLoader ); |
243 | |
244 | if ( o == null ) |
245 | { |
246 | if ( this.isLoggable( Level.WARNING ) ) |
247 | { |
248 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
249 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
250 | |
251 | } |
252 | } |
253 | else if ( specificationClass.isInstance( o ) ) |
254 | { |
255 | array[idx++] = o; |
256 | } |
257 | } |
258 | else if ( !impl.isAbstract() ) |
259 | { |
260 | final Instance instance = model.getInstance( impl.getIdentifier() ); |
261 | if ( instance == null ) |
262 | { |
263 | if ( this.isLoggable( Level.WARNING ) ) |
264 | { |
265 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
266 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
267 | |
268 | } |
269 | |
270 | return null; |
271 | } |
272 | |
273 | final Object o = this.getObject( scope, instance, classLoader ); |
274 | if ( o == null ) |
275 | { |
276 | if ( this.isLoggable( Level.WARNING ) ) |
277 | { |
278 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
279 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
280 | |
281 | } |
282 | } |
283 | else if ( specificationClass.isInstance( o ) ) |
284 | { |
285 | array[idx++] = o; |
286 | } |
287 | } |
288 | } |
289 | |
290 | if ( specification.isArray() ) |
291 | { |
292 | @SuppressWarnings( "unchecked" ) |
293 | final T copy = (T) Array.newInstance( specificationClass, idx ); |
294 | System.arraycopy( array, 0, copy, 0, idx ); |
295 | return copy; |
296 | } |
297 | else if ( idx == 1 ) |
298 | { |
299 | @SuppressWarnings( "unchecked" ) |
300 | final T object = (T) array[0]; |
301 | return object; |
302 | } |
303 | |
304 | return null; |
305 | } |
306 | catch ( final Exception e ) |
307 | { |
308 | throw new ObjectManagementException( getMessage( e ), e ); |
309 | } |
310 | } |
311 | |
312 | public <T> T getObject( final Class<T> specification, final String implementationName ) |
313 | { |
314 | if ( specification == null ) |
315 | { |
316 | throw new NullPointerException( "specification" ); |
317 | } |
318 | if ( implementationName == null ) |
319 | { |
320 | throw new NullPointerException( "implementationName" ); |
321 | } |
322 | |
323 | try |
324 | { |
325 | this.initialize(); |
326 | |
327 | final ClassLoader classLoader = this.getDefaultClassLoader( specification ); |
328 | final Modules model = this.getModules( classLoader ); |
329 | final Specification s = model.getSpecification( specification ); |
330 | |
331 | if ( s == null ) |
332 | { |
333 | if ( this.isLoggable( Level.WARNING ) ) |
334 | { |
335 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
336 | Locale.getDefault(), specification.getName() ), null ); |
337 | |
338 | } |
339 | |
340 | return null; |
341 | } |
342 | |
343 | Scope scope = null; |
344 | if ( s.getScope() != null ) |
345 | { |
346 | scope = this.getScope( s.getScope(), classLoader ); |
347 | |
348 | if ( scope == null ) |
349 | { |
350 | if ( this.isLoggable( Level.WARNING ) ) |
351 | { |
352 | this.log( classLoader, Level.WARNING, getMissingScopeMessage( |
353 | Locale.getDefault(), s.getScope() ), null ); |
354 | |
355 | } |
356 | |
357 | return null; |
358 | } |
359 | } |
360 | |
361 | final Implementations available = model.getImplementations( s.getIdentifier() ); |
362 | if ( available == null ) |
363 | { |
364 | if ( this.isLoggable( Level.WARNING ) ) |
365 | { |
366 | this.log( classLoader, Level.WARNING, getMissingImplementationsMessage( |
367 | Locale.getDefault(), specification.getName() ), null ); |
368 | |
369 | } |
370 | |
371 | return null; |
372 | } |
373 | |
374 | final Implementation i = available.getImplementationByName( implementationName ); |
375 | if ( i == null ) |
376 | { |
377 | if ( this.isLoggable( Level.WARNING ) ) |
378 | { |
379 | this.log( classLoader, Level.WARNING, getMissingImplementationMessage( |
380 | Locale.getDefault(), s.getIdentifier(), implementationName ), null ); |
381 | |
382 | } |
383 | |
384 | return null; |
385 | } |
386 | |
387 | if ( i.getLocation() != null ) |
388 | { |
389 | if ( s.getClazz() == null ) |
390 | { |
391 | if ( this.isLoggable( Level.WARNING ) ) |
392 | { |
393 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
394 | Locale.getDefault(), s.getIdentifier() ), null ); |
395 | |
396 | } |
397 | |
398 | return null; |
399 | } |
400 | |
401 | final T object = this.getObject( s.getJavaTypeName().getClass( classLoader, true ). |
402 | asSubclass( specification ), i.getLocationUri(), classLoader ); |
403 | |
404 | if ( object == null ) |
405 | { |
406 | if ( this.isLoggable( Level.WARNING ) ) |
407 | { |
408 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
409 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
410 | |
411 | } |
412 | |
413 | return null; |
414 | } |
415 | |
416 | return object; |
417 | } |
418 | else if ( !i.isAbstract() ) |
419 | { |
420 | final Instance instance = model.getInstance( i.getIdentifier() ); |
421 | if ( instance == null ) |
422 | { |
423 | if ( this.isLoggable( Level.WARNING ) ) |
424 | { |
425 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
426 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
427 | |
428 | } |
429 | |
430 | return null; |
431 | } |
432 | |
433 | final Object object = this.getObject( scope, instance, classLoader ); |
434 | if ( object == null ) |
435 | { |
436 | if ( this.isLoggable( Level.WARNING ) ) |
437 | { |
438 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
439 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
440 | |
441 | } |
442 | |
443 | return null; |
444 | } |
445 | else if ( specification.isInstance( object ) ) |
446 | { |
447 | @SuppressWarnings( "unchecked" ) |
448 | final T o = (T) object; |
449 | return o; |
450 | } |
451 | } |
452 | |
453 | return null; |
454 | } |
455 | catch ( final Exception e ) |
456 | { |
457 | throw new ObjectManagementException( getMessage( e ), e ); |
458 | } |
459 | } |
460 | |
461 | public Object getDependency( final Object object, final String dependencyName ) |
462 | { |
463 | if ( object == null ) |
464 | { |
465 | throw new NullPointerException( "object" ); |
466 | } |
467 | if ( dependencyName == null ) |
468 | { |
469 | throw new NullPointerException( "dependencyName" ); |
470 | } |
471 | |
472 | try |
473 | { |
474 | this.initialize(); |
475 | |
476 | final ClassLoader classLoader = this.getDefaultClassLoader( object.getClass() ); |
477 | final Modules model = this.getModules( classLoader ); |
478 | final Instance instance = model.getInstance( object ); |
479 | |
480 | if ( instance == null ) |
481 | { |
482 | if ( this.isLoggable( Level.WARNING ) ) |
483 | { |
484 | this.log( classLoader, Level.WARNING, getMissingObjectInstanceMessage( |
485 | Locale.getDefault(), this.getObjectInfo( object ) ), null ); |
486 | |
487 | } |
488 | |
489 | return null; |
490 | } |
491 | |
492 | synchronized ( instance ) |
493 | { |
494 | final Dependency dependency = instance.getDependencies() != null |
495 | ? instance.getDependencies().getDependency( dependencyName ) : null; |
496 | |
497 | if ( dependency == null ) |
498 | { |
499 | if ( this.isLoggable( Level.WARNING ) ) |
500 | { |
501 | this.log( classLoader, Level.WARNING, getMissingDependencyMessage( |
502 | Locale.getDefault(), instance.getIdentifier(), dependencyName ), null ); |
503 | |
504 | } |
505 | |
506 | return null; |
507 | } |
508 | |
509 | Object o = instance.getDependencyObjects().get( dependencyName ); |
510 | if ( o == null && !instance.getDependencyObjects().containsKey( dependencyName ) ) |
511 | { |
512 | final Specification ds = model.getSpecification( dependency.getIdentifier() ); |
513 | if ( ds == null ) |
514 | { |
515 | if ( this.isLoggable( Level.WARNING ) ) |
516 | { |
517 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
518 | Locale.getDefault(), dependency.getIdentifier() ), null ); |
519 | |
520 | } |
521 | |
522 | return null; |
523 | } |
524 | |
525 | Scope scope = null; |
526 | if ( ds.getScope() != null ) |
527 | { |
528 | scope = this.getScope( ds.getScope(), classLoader ); |
529 | |
530 | if ( scope == null ) |
531 | { |
532 | if ( this.isLoggable( Level.WARNING ) ) |
533 | { |
534 | this.log( classLoader, Level.WARNING, getMissingScopeMessage( |
535 | Locale.getDefault(), ds.getScope() ), null ); |
536 | |
537 | } |
538 | |
539 | return null; |
540 | } |
541 | } |
542 | |
543 | final Implementations available = model.getImplementations( ds.getIdentifier() ); |
544 | if ( available == null ) |
545 | { |
546 | if ( !dependency.isOptional() && this.isLoggable( Level.WARNING ) ) |
547 | { |
548 | this.log( classLoader, Level.WARNING, getMissingImplementationsMessage( |
549 | Locale.getDefault(), dependency.getIdentifier() ), null ); |
550 | |
551 | } |
552 | |
553 | return null; |
554 | } |
555 | |
556 | if ( dependency.getImplementationName() != null ) |
557 | { |
558 | final Implementation i = |
559 | available.getImplementationByName( dependency.getImplementationName() ); |
560 | |
561 | if ( i == null ) |
562 | { |
563 | if ( !dependency.isOptional() && this.isLoggable( Level.WARNING ) ) |
564 | { |
565 | this.log( classLoader, Level.WARNING, getMissingImplementationMessage( |
566 | Locale.getDefault(), dependency.getIdentifier(), |
567 | dependency.getImplementationName() ), null ); |
568 | |
569 | } |
570 | |
571 | return null; |
572 | } |
573 | |
574 | if ( i.getLocation() != null ) |
575 | { |
576 | if ( ds.getClazz() == null ) |
577 | { |
578 | if ( this.isLoggable( Level.WARNING ) ) |
579 | { |
580 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
581 | Locale.getDefault(), ds.getIdentifier() ), null ); |
582 | |
583 | } |
584 | |
585 | return null; |
586 | } |
587 | |
588 | o = this.getObject( ds.getJavaTypeName().getClass( classLoader, true ), i.getLocationUri(), |
589 | classLoader ); |
590 | |
591 | if ( o == null ) |
592 | { |
593 | if ( this.isLoggable( Level.WARNING ) ) |
594 | { |
595 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
596 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
597 | |
598 | } |
599 | |
600 | return null; |
601 | } |
602 | } |
603 | else if ( !i.isAbstract() ) |
604 | { |
605 | final Instance di = model.getInstance( i.getIdentifier(), dependency ); |
606 | if ( di == null ) |
607 | { |
608 | if ( this.isLoggable( Level.WARNING ) ) |
609 | { |
610 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
611 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
612 | |
613 | } |
614 | |
615 | return null; |
616 | } |
617 | |
618 | o = this.getObject( scope, di, classLoader ); |
619 | if ( o == null ) |
620 | { |
621 | if ( this.isLoggable( Level.WARNING ) ) |
622 | { |
623 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
624 | Locale.getDefault(), i.getIdentifier(), i.getName() ), null ); |
625 | |
626 | } |
627 | |
628 | return null; |
629 | } |
630 | } |
631 | } |
632 | else if ( ds.getMultiplicity() == Multiplicity.ONE ) |
633 | { |
634 | if ( available.getImplementation().size() == 1 ) |
635 | { |
636 | final Implementation ref = available.getImplementation().get( 0 ); |
637 | |
638 | if ( ref.getLocation() != null ) |
639 | { |
640 | if ( ds.getClazz() == null ) |
641 | { |
642 | if ( this.isLoggable( Level.WARNING ) ) |
643 | { |
644 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
645 | Locale.getDefault(), ds.getIdentifier() ), null ); |
646 | |
647 | } |
648 | |
649 | return null; |
650 | } |
651 | |
652 | o = this.getObject( ds.getJavaTypeName().getClass( classLoader, true ), |
653 | ref.getLocationUri(), classLoader ); |
654 | |
655 | if ( o == null ) |
656 | { |
657 | if ( this.isLoggable( Level.WARNING ) ) |
658 | { |
659 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
660 | Locale.getDefault(), ref.getIdentifier(), ref.getName() ), null ); |
661 | |
662 | } |
663 | |
664 | return null; |
665 | } |
666 | } |
667 | else if ( !ref.isAbstract() ) |
668 | { |
669 | final Instance di = model.getInstance( ref.getIdentifier(), dependency ); |
670 | if ( di == null ) |
671 | { |
672 | if ( this.isLoggable( Level.WARNING ) ) |
673 | { |
674 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
675 | Locale.getDefault(), ref.getIdentifier(), ref.getName() ), null ); |
676 | |
677 | } |
678 | |
679 | return null; |
680 | } |
681 | |
682 | o = this.getObject( scope, di, classLoader ); |
683 | if ( o == null ) |
684 | { |
685 | if ( this.isLoggable( Level.WARNING ) ) |
686 | { |
687 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
688 | Locale.getDefault(), ref.getIdentifier(), ref.getName() ), null ); |
689 | |
690 | } |
691 | |
692 | return null; |
693 | } |
694 | } |
695 | } |
696 | else |
697 | { |
698 | this.log( classLoader, Level.WARNING, getUnexpectedDependencyObjectsMessage( |
699 | Locale.getDefault(), instance.getIdentifier(), dependencyName, BigInteger.ONE, |
700 | available.getImplementation().size() ), null ); |
701 | |
702 | } |
703 | } |
704 | else |
705 | { |
706 | int idx = 0; |
707 | final Object[] array = new Object[ available.getImplementation().size() ]; |
708 | |
709 | if ( !available.getImplementation().isEmpty() && ds.getClazz() == null ) |
710 | { |
711 | if ( this.isLoggable( Level.WARNING ) ) |
712 | { |
713 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
714 | Locale.getDefault(), ds.getIdentifier() ), null ); |
715 | |
716 | } |
717 | |
718 | return null; |
719 | } |
720 | |
721 | for ( int i = 0, s0 = available.getImplementation().size(); i < s0; i++ ) |
722 | { |
723 | final Implementation a = available.getImplementation().get( i ); |
724 | if ( a.getLocation() != null ) |
725 | { |
726 | if ( ds.getClazz() == null ) |
727 | { |
728 | if ( this.isLoggable( Level.WARNING ) ) |
729 | { |
730 | this.log( classLoader, Level.WARNING, getMissingSpecificationClassMessage( |
731 | Locale.getDefault(), ds.getIdentifier() ), null ); |
732 | |
733 | } |
734 | |
735 | return null; |
736 | } |
737 | |
738 | final Object o2 = this.getObject( ds.getJavaTypeName().getClass( classLoader, true ), |
739 | a.getLocationUri(), classLoader ); |
740 | |
741 | if ( o2 == null ) |
742 | { |
743 | if ( this.isLoggable( Level.WARNING ) ) |
744 | { |
745 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
746 | Locale.getDefault(), a.getIdentifier(), a.getName() ), null ); |
747 | |
748 | } |
749 | } |
750 | else |
751 | { |
752 | array[idx++] = o2; |
753 | } |
754 | } |
755 | else if ( !a.isAbstract() ) |
756 | { |
757 | final Instance di = model.getInstance( a.getIdentifier(), dependency ); |
758 | if ( di == null ) |
759 | { |
760 | if ( this.isLoggable( Level.WARNING ) ) |
761 | { |
762 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
763 | Locale.getDefault(), a.getIdentifier(), a.getName() ), null ); |
764 | |
765 | } |
766 | |
767 | return null; |
768 | } |
769 | |
770 | final Object o2 = this.getObject( scope, di, classLoader ); |
771 | if ( o2 == null ) |
772 | { |
773 | if ( this.isLoggable( Level.WARNING ) ) |
774 | { |
775 | this.log( classLoader, Level.WARNING, getMissingObjectMessage( |
776 | Locale.getDefault(), a.getIdentifier(), a.getName() ), null ); |
777 | |
778 | } |
779 | } |
780 | else |
781 | { |
782 | array[idx++] = o2; |
783 | } |
784 | } |
785 | } |
786 | |
787 | if ( idx > 0 ) |
788 | { |
789 | o = Array.newInstance( ds.getJavaTypeName().getClass( classLoader, true ), idx ); |
790 | System.arraycopy( array, 0, o, 0, idx ); |
791 | } |
792 | else |
793 | { |
794 | o = null; |
795 | } |
796 | } |
797 | } |
798 | |
799 | if ( dependency.isBound() ) |
800 | { |
801 | instance.getDependencyObjects().put( dependencyName, o ); |
802 | } |
803 | |
804 | return o; |
805 | } |
806 | } |
807 | catch ( final Exception e ) |
808 | { |
809 | throw new ObjectManagementException( getMessage( e ), e ); |
810 | } |
811 | } |
812 | |
813 | public Object getProperty( final Object object, final String propertyName ) |
814 | { |
815 | if ( object == null ) |
816 | { |
817 | throw new NullPointerException( "object" ); |
818 | } |
819 | if ( propertyName == null ) |
820 | { |
821 | throw new NullPointerException( "propertyName" ); |
822 | } |
823 | |
824 | try |
825 | { |
826 | this.initialize(); |
827 | |
828 | final ClassLoader classLoader = this.getDefaultClassLoader( object.getClass() ); |
829 | final Modules model = this.getModules( classLoader ); |
830 | final Instance instance = model.getInstance( object ); |
831 | |
832 | if ( instance == null ) |
833 | { |
834 | if ( this.isLoggable( Level.WARNING ) ) |
835 | { |
836 | this.log( classLoader, Level.WARNING, getMissingObjectInstanceMessage( |
837 | Locale.getDefault(), this.getObjectInfo( object ) ), null ); |
838 | |
839 | } |
840 | |
841 | return null; |
842 | } |
843 | |
844 | synchronized ( instance ) |
845 | { |
846 | Object value = instance.getPropertyObjects().get( propertyName ); |
847 | |
848 | if ( value == null && !instance.getPropertyObjects().containsKey( propertyName ) ) |
849 | { |
850 | final Property property = |
851 | instance.getProperties() != null ? instance.getProperties().getProperty( propertyName ) : null; |
852 | |
853 | if ( property == null ) |
854 | { |
855 | if ( this.isLoggable( Level.WARNING ) ) |
856 | { |
857 | this.log( classLoader, Level.WARNING, getMissingPropertyMessage( |
858 | Locale.getDefault(), instance.getIdentifier(), propertyName ), null ); |
859 | |
860 | } |
861 | |
862 | return null; |
863 | } |
864 | |
865 | value = property.getJavaValue( classLoader ); |
866 | instance.getPropertyObjects().put( propertyName, value ); |
867 | } |
868 | |
869 | return value; |
870 | } |
871 | } |
872 | catch ( final Exception e ) |
873 | { |
874 | throw new ObjectManagementException( getMessage( e ), e ); |
875 | } |
876 | } |
877 | |
878 | public String getMessage( final Object object, final String messageName, final Locale locale, |
879 | final Object... arguments ) |
880 | { |
881 | if ( object == null ) |
882 | { |
883 | throw new NullPointerException( "object" ); |
884 | } |
885 | if ( messageName == null ) |
886 | { |
887 | throw new NullPointerException( "messageName" ); |
888 | } |
889 | if ( locale == null ) |
890 | { |
891 | throw new NullPointerException( "locale" ); |
892 | } |
893 | |
894 | try |
895 | { |
896 | this.initialize(); |
897 | |
898 | final ClassLoader classLoader = this.getDefaultClassLoader( object.getClass() ); |
899 | final Modules model = this.getModules( classLoader ); |
900 | final Instance instance = model.getInstance( object ); |
901 | |
902 | if ( instance == null ) |
903 | { |
904 | if ( this.isLoggable( Level.WARNING ) ) |
905 | { |
906 | this.log( classLoader, Level.WARNING, getMissingObjectInstanceMessage( |
907 | Locale.getDefault(), this.getObjectInfo( object ) ), null ); |
908 | |
909 | } |
910 | |
911 | return null; |
912 | } |
913 | |
914 | synchronized ( instance ) |
915 | { |
916 | Map<Locale, MessageFormat> messageFormats = instance.getMessageObjects().get( messageName ); |
917 | |
918 | if ( messageFormats == null ) |
919 | { |
920 | messageFormats = new HashMap<Locale, MessageFormat>(); |
921 | instance.getMessageObjects().put( messageName, messageFormats ); |
922 | } |
923 | |
924 | MessageFormat messageFormat = messageFormats.get( locale ); |
925 | |
926 | if ( messageFormat == null && !messageFormats.containsKey( locale ) ) |
927 | { |
928 | final Message message = |
929 | instance.getMessages() != null ? instance.getMessages().getMessage( messageName ) : null; |
930 | |
931 | if ( message == null || message.getTemplate() == null ) |
932 | { |
933 | if ( this.isLoggable( Level.WARNING ) ) |
934 | { |
935 | this.log( classLoader, Level.WARNING, getMissingMessageMessage( |
936 | Locale.getDefault(), instance.getIdentifier(), messageName ), null ); |
937 | |
938 | } |
939 | } |
940 | else |
941 | { |
942 | messageFormat = message.getJavaMessage( locale ); |
943 | } |
944 | |
945 | messageFormats.put( locale, messageFormat ); |
946 | } |
947 | |
948 | if ( messageFormat != null ) |
949 | { |
950 | synchronized ( messageFormat ) |
951 | { |
952 | return messageFormat.format( arguments ); |
953 | } |
954 | } |
955 | } |
956 | |
957 | return null; |
958 | } |
959 | catch ( final Exception e ) |
960 | { |
961 | throw new ObjectManagementException( getMessage( e ), e ); |
962 | } |
963 | } |
964 | |
965 | // SECTION-END |
966 | // SECTION-START[DefaultObjectManager] |
967 | /** Constant for the {@code Singleton} scope identifier. */ |
968 | protected static final String SINGLETON_SCOPE_IDENTIFIER = "Singleton"; |
969 | |
970 | /** |
971 | * Array holding a single {@code InvocationHandler} class. |
972 | * @since 1.2 |
973 | */ |
974 | private static final Class<?>[] INVOCATION_HANDLER_ARGUMENTS = |
975 | { |
976 | InvocationHandler.class |
977 | }; |
978 | |
979 | /** |
980 | * Log level events are logged at by default. |
981 | * @see #getDefaultLogLevel() |
982 | */ |
983 | private static final Level DEFAULT_LOG_LEVEL = Level.WARNING; |
984 | |
985 | /** Default log level. */ |
986 | private static volatile Level defaultLogLevel; |
987 | |
988 | /** Name of the platform's bootstrap class loader class. */ |
989 | private static volatile String bootstrapClassLoaderClassName; |
990 | |
991 | private static volatile boolean bootstrapClassLoaderClassNameInitialized; |
992 | |
993 | /** |
994 | * Identifier of the model to search for modules by default. |
995 | * @since 1.1 |
996 | */ |
997 | private static volatile String defaultModelIdentifier; |
998 | |
999 | /** |
1000 | * Identifier of the model to search for modules. |
1001 | * @since 1.1 |
1002 | */ |
1003 | private String modelIdentifier; |
1004 | |
1005 | /** |
1006 | * Flag indicating model object class path resolution is enabled by default. |
1007 | * @since 1.1 |
1008 | */ |
1009 | private static volatile Boolean defaultModelObjectClasspathResolutionEnabled; |
1010 | |
1011 | /** |
1012 | * Flag indicating model object class path resolution is enabled. |
1013 | * @since 1.1 |
1014 | */ |
1015 | private Boolean modelObjectClasspathResolutionEnabled; |
1016 | |
1017 | /** |
1018 | * Flag indicating model processing is enabled by default. |
1019 | * @since 1.1 |
1020 | */ |
1021 | private static volatile Boolean defaultModelProcessingEnabled; |
1022 | |
1023 | /** |
1024 | * Flag indicating model processing is enabled. |
1025 | * @since 1.1 |
1026 | */ |
1027 | private Boolean modelProcessingEnabled; |
1028 | |
1029 | /** {@code ClassLoader} instance representing the bootstrap class loader. */ |
1030 | private static final ClassLoader BOOTSTRAP_CLASSLOADER = new ClassLoader( null ) |
1031 | { |
1032 | |
1033 | @Override |
1034 | public String toString() |
1035 | { |
1036 | return DefaultObjectManager.class.getName() + ".BootstrapClassLoader@" |
1037 | + Integer.toHexString( this.hashCode() ); |
1038 | |
1039 | } |
1040 | |
1041 | }; |
1042 | |
1043 | /** Flag indicating that initialization has been performed. */ |
1044 | private boolean initialized; |
1045 | |
1046 | /** Log level of the instance. */ |
1047 | private Level logLevel; |
1048 | |
1049 | /** Listeners of the instance. */ |
1050 | private final Map<ClassLoader, List<Listener>> listeners = |
1051 | new WeakIdentityHashMap<ClassLoader, List<Listener>>(); |
1052 | |
1053 | /** Modules of the instance. */ |
1054 | private final Map<ClassLoader, Modules> modules = |
1055 | new WeakIdentityHashMap<ClassLoader, Modules>(); |
1056 | |
1057 | /** Invokers of the instance. */ |
1058 | private final Map<ClassLoader, Invoker> invokers = |
1059 | new WeakIdentityHashMap<ClassLoader, Invoker>(); |
1060 | |
1061 | /** Scopes of the instance. */ |
1062 | private final Map<ClassLoader, Map<String, Scope>> scopes = |
1063 | new WeakIdentityHashMap<ClassLoader, Map<String, Scope>>(); |
1064 | |
1065 | /** Locators of the instance. */ |
1066 | private final Map<ClassLoader, Map<String, Locator>> locators = |
1067 | new WeakIdentityHashMap<ClassLoader, Map<String, Locator>>(); |
1068 | |
1069 | /** Objects of the instance. */ |
1070 | private final Map<ClassLoader, Map<Object, Instance>> objects = |
1071 | new WeakIdentityHashMap<ClassLoader, Map<Object, Instance>>(); |
1072 | |
1073 | /** {@code ObjectManager} singletons. */ |
1074 | private static final Map<ClassLoader, ObjectManager> singletons = |
1075 | new WeakIdentityHashMap<ClassLoader, ObjectManager>(); |
1076 | |
1077 | /** |
1078 | * Default class loaders cache. |
1079 | * @since 1.2 |
1080 | */ |
1081 | private static final Map<ClassLoader, Reference<ClassLoader>> defaultClassLoaders = |
1082 | new WeakIdentityHashMap<ClassLoader, Reference<ClassLoader>>(); |
1083 | |
1084 | /** |
1085 | * Proxy class constructors by class loader any instance cache. |
1086 | * @since 1.2 |
1087 | */ |
1088 | private static final Map<ClassLoader, Map<String, Reference<Constructor<?>>>> proxyClassConstructors = |
1089 | new WeakIdentityHashMap<ClassLoader, Map<String, Reference<Constructor<?>>>>(); |
1090 | |
1091 | /** |
1092 | * Default {@link ObjectManagerFactory#getObjectManager(ClassLoader)} implementation. |
1093 | * |
1094 | * @param classLoader The class loader to use for getting the singleton instance; {@code null} to use the platform's |
1095 | * bootstrap class loader. |
1096 | * |
1097 | * @return The default {@code ObjectManager} singleton instance. |
1098 | * |
1099 | * @see ObjectManagerFactory#getObjectManager(ClassLoader) |
1100 | */ |
1101 | public static ObjectManager getObjectManager( final ClassLoader classLoader ) |
1102 | { |
1103 | ObjectManager manager; |
1104 | final ClassLoader singletonsLoader = getClassLoader( classLoader ); |
1105 | |
1106 | synchronized ( singletons ) |
1107 | { |
1108 | manager = singletons.get( singletonsLoader ); |
1109 | |
1110 | if ( manager == null ) |
1111 | { |
1112 | manager = ObjectManagerFactory.newObjectManager( classLoader ); |
1113 | |
1114 | if ( singletons.put( singletonsLoader, manager ) != null ) |
1115 | { |
1116 | throw new AssertionError( getScopeContentionFailure( |
1117 | Locale.getDefault(), manager.getClass().getName() ) ); |
1118 | |
1119 | } |
1120 | } |
1121 | } |
1122 | |
1123 | return manager.getObject( ObjectManager.class ); |
1124 | } |
1125 | |
1126 | /** |
1127 | * Gets the list of listeners registered with the class loader of the instance. |
1128 | * <p>Calling this method is the same as calling<blockquote><pre> |
1129 | * getListeners( getClassLoader( getClass() ) );</pre></blockquote> |
1130 | * |
1131 | * @return The list of registered listeners. |
1132 | * |
1133 | * @throws ObjectManagementException if getting the list of listeners fails. |
1134 | * |
1135 | * @see #getListeners(java.lang.ClassLoader) |
1136 | */ |
1137 | public List<Listener> getListeners() |
1138 | { |
1139 | return this.getListeners( this.getDefaultClassLoader( this.getClass() ) ); |
1140 | } |
1141 | |
1142 | /** |
1143 | * Gets the list of listeners registered with a given class loader. |
1144 | * |
1145 | * @param classLoader The class loader to get registered listeners of. |
1146 | * |
1147 | * @return The list of listeners registered with {@code classLoader}. |
1148 | * |
1149 | * @throws NullPointerException if {@code classLoader} is {@code null}. |
1150 | * @throws ObjectManagementException if getting the list of listeners fails. |
1151 | * |
1152 | * @see #getDefaultListener(org.jomc.model.Modules) |
1153 | * |
1154 | * @since 1.1 |
1155 | */ |
1156 | public List<Listener> getListeners( final ClassLoader classLoader ) |
1157 | { |
1158 | if ( classLoader == null ) |
1159 | { |
1160 | throw new NullPointerException( "classLoader" ); |
1161 | } |
1162 | |
1163 | try |
1164 | { |
1165 | final ClassLoader listenersLoader = this.getDefaultClassLoader( classLoader ); |
1166 | |
1167 | synchronized ( this.listeners ) |
1168 | { |
1169 | List<Listener> cachedListeners = this.listeners.get( listenersLoader ); |
1170 | |
1171 | if ( cachedListeners == null ) |
1172 | { |
1173 | final List<LogRecord> bootstrapRecords = new ArrayList<LogRecord>( 1024 ); |
1174 | final Listener bootstrapListener = new Listener() |
1175 | { |
1176 | |
1177 | public void onLog( final Level level, final String message, final Throwable throwable ) |
1178 | { |
1179 | final LogRecord r = new LogRecord( level, message ); |
1180 | r.setThrown( throwable ); |
1181 | |
1182 | bootstrapRecords.add( r ); |
1183 | } |
1184 | |
1185 | }; |
1186 | |
1187 | cachedListeners = new LinkedList<Listener>(); |
1188 | cachedListeners.add( bootstrapListener ); |
1189 | this.listeners.put( listenersLoader, cachedListeners ); |
1190 | |
1191 | final List<Listener> modelListeners = new LinkedList<Listener>(); |
1192 | final Modules model = this.getModules( classLoader ); |
1193 | final Specification listenerSpecification = model.getSpecification( Listener.class ); |
1194 | |
1195 | if ( listenerSpecification != null ) |
1196 | { |
1197 | final Implementations implementations = |
1198 | model.getImplementations( listenerSpecification.getIdentifier() ); |
1199 | |
1200 | if ( implementations != null && !implementations.getImplementation().isEmpty() ) |
1201 | { |
1202 | for ( int i = 0, s0 = implementations.getImplementation().size(); i < s0; i++ ) |
1203 | { |
1204 | final Implementation impl = implementations.getImplementation().get( i ); |
1205 | final Instance listenerInstance = model.getInstance( impl.getIdentifier() ); |
1206 | if ( listenerInstance != null ) |
1207 | { |
1208 | try |
1209 | { |
1210 | final Listener l = |
1211 | (Listener) model.createObject( listenerInstance, classLoader ); |
1212 | |
1213 | modelListeners.add( l ); |
1214 | |
1215 | if ( this.isLoggable( Level.CONFIG ) ) |
1216 | { |
1217 | this.log( classLoader, Level.CONFIG, getListenerInfoMessage( |
1218 | Locale.getDefault(), l.getClass().getName(), |
1219 | this.getClassLoaderInfo( classLoader, listenersLoader ) ), null ); |
1220 | |
1221 | } |
1222 | } |
1223 | catch ( final InstantiationException e ) |
1224 | { |
1225 | if ( this.isLoggable( Level.SEVERE ) ) |
1226 | { |
1227 | this.log( classLoader, Level.SEVERE, getMessage( e ), e ); |
1228 | } |
1229 | } |
1230 | } |
1231 | else if ( this.isLoggable( Level.WARNING ) ) |
1232 | { |
1233 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
1234 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
1235 | |
1236 | } |
1237 | } |
1238 | } |
1239 | else if ( this.isLoggable( Level.WARNING ) ) |
1240 | { |
1241 | this.log( classLoader, Level.WARNING, getMissingImplementationsMessage( |
1242 | Locale.getDefault(), listenerSpecification.getIdentifier() ), null ); |
1243 | |
1244 | } |
1245 | } |
1246 | else if ( this.isLoggable( Level.WARNING ) ) |
1247 | { |
1248 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
1249 | Locale.getDefault(), Listener.class.getName() ), null ); |
1250 | |
1251 | } |
1252 | |
1253 | cachedListeners.remove( bootstrapListener ); |
1254 | cachedListeners.addAll( modelListeners ); |
1255 | |
1256 | if ( cachedListeners.isEmpty() ) |
1257 | { |
1258 | if ( !classLoader.equals( this.getDefaultClassLoader( this.getClass() ) ) ) |
1259 | { |
1260 | cachedListeners.addAll( this.getListeners() ); |
1261 | } |
1262 | else |
1263 | { |
1264 | cachedListeners.add( this.getDefaultListener( model ) ); |
1265 | |
1266 | if ( this.isLoggable( Level.CONFIG ) ) |
1267 | { |
1268 | this.log( Level.CONFIG, getDefaultListenerInfo( |
1269 | Locale.getDefault(), this.getClassLoaderInfo( classLoader, listenersLoader ) ), |
1270 | null ); |
1271 | |
1272 | } |
1273 | } |
1274 | } |
1275 | |
1276 | for ( LogRecord r : bootstrapRecords ) |
1277 | { |
1278 | this.log( classLoader, r.getLevel(), r.getMessage(), r.getThrown() ); |
1279 | } |
1280 | } |
1281 | |
1282 | return cachedListeners; |
1283 | } |
1284 | } |
1285 | catch ( final ModelObjectException e ) |
1286 | { |
1287 | throw new ObjectManagementException( getMessage( e ), e ); |
1288 | } |
1289 | } |
1290 | |
1291 | /** |
1292 | * Gets a new default listener implementation instance. |
1293 | * |
1294 | * @return A new default listener implementation instance. |
1295 | * |
1296 | * @see #getListeners() |
1297 | * @see #getListeners(java.lang.ClassLoader) |
1298 | * |
1299 | * @since 1.1 |
1300 | * |
1301 | * @deprecated As of JOMC 1.2, replaced by method {@link #getDefaultListener(org.jomc.model.Modules)}. This method |
1302 | * will be removed in version 2.0. |
1303 | */ |
1304 | @Deprecated |
1305 | public Listener getDefaultListener() |
1306 | { |
1307 | return new DefaultListener(); |
1308 | } |
1309 | |
1310 | /** |
1311 | * Gets a new default listener implementation instance. |
1312 | * |
1313 | * @param model The model to get a new default listener implementation instance of. |
1314 | * |
1315 | * @return A new default listener implementation instance. |
1316 | * |
1317 | * @throws NullPointerException if {@code model} is {@code null}. |
1318 | * @throws ObjectManagementException if getting a new default listener implementation instance fails. |
1319 | * |
1320 | * @see #getListeners() |
1321 | * @see #getListeners(java.lang.ClassLoader) |
1322 | * |
1323 | * @since 1.2 |
1324 | */ |
1325 | public Listener getDefaultListener( final Modules model ) |
1326 | { |
1327 | if ( model == null ) |
1328 | { |
1329 | throw new NullPointerException( "model" ); |
1330 | } |
1331 | |
1332 | try |
1333 | { |
1334 | final Listener defaultListener = new DefaultListener(); |
1335 | model.getInstance( defaultListener ); |
1336 | return defaultListener; |
1337 | } |
1338 | catch ( final ModelObjectException e ) |
1339 | { |
1340 | throw new ObjectManagementException( getMessage( e ), e ); |
1341 | } |
1342 | } |
1343 | |
1344 | /** |
1345 | * Gets the default log level events are logged at. |
1346 | * <p>The default log level is controlled by system property |
1347 | * {@code org.jomc.ri.DefaultObjectManager.defaultLogLevel} holding the log level to log events at by default. |
1348 | * If that property is not set, the {@code WARNING} default is returned.</p> |
1349 | * |
1350 | * @return The log level events are logged at by default. |
1351 | * |
1352 | * @see #getLogLevel() |
1353 | * @see Level#parse(java.lang.String) |
1354 | */ |
1355 | public static Level getDefaultLogLevel() |
1356 | { |
1357 | if ( defaultLogLevel == null ) |
1358 | { |
1359 | defaultLogLevel = Level.parse( System.getProperty( "org.jomc.ri.DefaultObjectManager.defaultLogLevel", |
1360 | DEFAULT_LOG_LEVEL.getName() ) ); |
1361 | |
1362 | } |
1363 | |
1364 | return defaultLogLevel; |
1365 | } |
1366 | |
1367 | /** |
1368 | * Sets the default log level events are logged at. |
1369 | * |
1370 | * @param value The new default level events are logged at or {@code null}. |
1371 | * |
1372 | * @see #getDefaultLogLevel() |
1373 | */ |
1374 | public static void setDefaultLogLevel( final Level value ) |
1375 | { |
1376 | defaultLogLevel = value; |
1377 | } |
1378 | |
1379 | /** |
1380 | * Gets the log level of the instance. |
1381 | * |
1382 | * @return The log level of the instance. |
1383 | * |
1384 | * @see #getDefaultLogLevel() |
1385 | * @see #setLogLevel(java.util.logging.Level) |
1386 | * @see #isLoggable(java.util.logging.Level) |
1387 | */ |
1388 | public final Level getLogLevel() |
1389 | { |
1390 | if ( this.logLevel == null ) |
1391 | { |
1392 | this.logLevel = getDefaultLogLevel(); |
1393 | |
1394 | if ( this.isLoggable( Level.CONFIG ) ) |
1395 | { |
1396 | this.log( Level.CONFIG, getDefaultLogLevelInfoMessage( |
1397 | Locale.getDefault(), this.logLevel.getLocalizedName() ), null ); |
1398 | |
1399 | } |
1400 | } |
1401 | |
1402 | return this.logLevel; |
1403 | } |
1404 | |
1405 | /** |
1406 | * Sets the log level of the instance. |
1407 | * |
1408 | * @param value The new log level of the instance or {@code null}. |
1409 | * |
1410 | * @see #getLogLevel() |
1411 | * @see #isLoggable(java.util.logging.Level) |
1412 | */ |
1413 | public final void setLogLevel( final Level value ) |
1414 | { |
1415 | this.logLevel = value; |
1416 | } |
1417 | |
1418 | /** |
1419 | * Checks if a message at a given level is provided to the listeners of the instance. |
1420 | * |
1421 | * @param level The level to test. |
1422 | * |
1423 | * @return {@code true}, if messages at {@code level} are provided to the listeners of the instance; |
1424 | * {@code false}, if messages at {@code level} are not provided to the listeners of the instance. |
1425 | * |
1426 | * @throws NullPointerException if {@code level} is {@code null}. |
1427 | * |
1428 | * @see #getLogLevel() |
1429 | * @see #setLogLevel(java.util.logging.Level) |
1430 | * @see #log(java.util.logging.Level, java.lang.String, java.lang.Throwable) |
1431 | * @see #log(java.lang.ClassLoader, java.util.logging.Level, java.lang.String, java.lang.Throwable) |
1432 | */ |
1433 | public boolean isLoggable( final Level level ) |
1434 | { |
1435 | if ( level == null ) |
1436 | { |
1437 | throw new NullPointerException( "level" ); |
1438 | } |
1439 | |
1440 | return level.intValue() >= this.getLogLevel().intValue(); |
1441 | } |
1442 | |
1443 | /** |
1444 | * Notifies listeners registered with the class loader of the instance. |
1445 | * <p>Calling this method is the same as calling<blockquote><pre> |
1446 | * log( getClassLoader( getClass() ), level, message, throwable );</pre></blockquote></p> |
1447 | * |
1448 | * @param level The level of the event. |
1449 | * @param message The message of the event or {@code null}. |
1450 | * @param throwable The throwable of the event or {@code null}. |
1451 | * |
1452 | * @throws NullPointerException if {@code level} is {@code null}. |
1453 | * @throws ObjectManagementException if notifying listeners fails. |
1454 | * |
1455 | * @see #log(java.lang.ClassLoader, java.util.logging.Level, java.lang.String, java.lang.Throwable) |
1456 | */ |
1457 | public void log( final Level level, final String message, final Throwable throwable ) |
1458 | { |
1459 | this.log( this.getDefaultClassLoader( this.getClass() ), level, message, throwable ); |
1460 | } |
1461 | |
1462 | /** |
1463 | * Notifies listeners registered with a given class loader. |
1464 | * |
1465 | * @param classLoader The class loader to notify listeners of. |
1466 | * @param level The level of the event. |
1467 | * @param message The message of the event or {@code null}. |
1468 | * @param throwable The throwable of the event or {@code null}. |
1469 | * |
1470 | * @throws NullPointerException if {@code classLoader} or {@code level} is {@code null}. |
1471 | * @throws ObjectManagementException if notifying listeners fails. |
1472 | * |
1473 | * @since 1.1 |
1474 | */ |
1475 | public void log( final ClassLoader classLoader, final Level level, final String message, final Throwable throwable ) |
1476 | { |
1477 | if ( level == null ) |
1478 | { |
1479 | throw new NullPointerException( "level" ); |
1480 | } |
1481 | if ( classLoader == null ) |
1482 | { |
1483 | throw new NullPointerException( "classLoader" ); |
1484 | } |
1485 | |
1486 | if ( this.isLoggable( level ) ) |
1487 | { |
1488 | final List<Listener> l = this.getListeners( classLoader ); |
1489 | |
1490 | for ( int i = 0, s0 = l.size(); i < s0; i++ ) |
1491 | { |
1492 | l.get( i ).onLog( level, message, throwable ); |
1493 | } |
1494 | } |
1495 | } |
1496 | |
1497 | /** |
1498 | * Gets the identifier of the model to search for modules by default. |
1499 | * <p>The identifier of the model to search for modules by default is controlled by system property |
1500 | * {@code org.jomc.ri.DefaultObjectManager.defaultModelIdentifier} holding the identifier of the model to search for |
1501 | * modules by default. If that property is not set, the {@code http://jomc.org/model} default is returned.</p> |
1502 | * |
1503 | * @return The identifier of the model to search for modules by default. |
1504 | * |
1505 | * @see #getModelIdentifier() |
1506 | * @see #setDefaultModelIdentifier(java.lang.String) |
1507 | * @see ModelObject#MODEL_PUBLIC_ID |
1508 | * |
1509 | * @since 1.1 |
1510 | */ |
1511 | public static String getDefaultModelIdentifier() |
1512 | { |
1513 | if ( defaultModelIdentifier == null ) |
1514 | { |
1515 | defaultModelIdentifier = System.getProperty( "org.jomc.ri.DefaultObjectManager.defaultModelIdentifier", |
1516 | ModelObject.MODEL_PUBLIC_ID ); |
1517 | |
1518 | } |
1519 | |
1520 | return defaultModelIdentifier; |
1521 | } |
1522 | |
1523 | /** |
1524 | * Sets the identifier of the model to search for modules by default. |
1525 | * |
1526 | * @param value The new identifier of the model to search for modules by default or {@code null}. |
1527 | * |
1528 | * @see #getDefaultModelIdentifier() |
1529 | * |
1530 | * @since 1.1 |
1531 | */ |
1532 | public static void setDefaultModelIdentifier( final String value ) |
1533 | { |
1534 | defaultModelIdentifier = value; |
1535 | } |
1536 | |
1537 | /** |
1538 | * Gets the identifier of the model to search for modules. |
1539 | * |
1540 | * @return The identifier of the model to search for modules. |
1541 | * |
1542 | * @see #getDefaultModelIdentifier() |
1543 | * @see #setModelIdentifier(java.lang.String) |
1544 | * |
1545 | * @since 1.1 |
1546 | */ |
1547 | public final String getModelIdentifier() |
1548 | { |
1549 | if ( this.modelIdentifier == null ) |
1550 | { |
1551 | this.modelIdentifier = getDefaultModelIdentifier(); |
1552 | |
1553 | if ( this.isLoggable( Level.CONFIG ) ) |
1554 | { |
1555 | this.log( Level.CONFIG, getDefaultModelIdentifierInfo( |
1556 | Locale.getDefault(), this.modelIdentifier ), null ); |
1557 | |
1558 | } |
1559 | } |
1560 | |
1561 | return this.modelIdentifier; |
1562 | } |
1563 | |
1564 | /** |
1565 | * Sets the identifier of the model to search for modules. |
1566 | * |
1567 | * @param value The new identifier of the model to search for modules or {@code null}. |
1568 | * |
1569 | * @since 1.1 |
1570 | */ |
1571 | public final void setModelIdentifier( final String value ) |
1572 | { |
1573 | this.modelIdentifier = value; |
1574 | } |
1575 | |
1576 | /** |
1577 | * Gets a flag indicating model object class path resolution is enabled by default. |
1578 | * <p>The default model object class path resolution enabled flag is controlled by system property |
1579 | * {@code org.jomc.ri.DefaultObjectManager.defaultModelObjectClasspathResolutionEnabled} holding a boolean |
1580 | * indicating model object class path resolution is enabled by default. If that property is not set, the |
1581 | * {@code true} default is returned.</p> |
1582 | * |
1583 | * @return {@code true}, if model object class path resolution is enabled by default; {@code false}, if model object |
1584 | * class path resolution is disabled by default. |
1585 | * |
1586 | * @see #isModelObjectClasspathResolutionEnabled() |
1587 | * @see #setDefaultModelObjectClasspathResolutionEnabled(java.lang.Boolean) |
1588 | * |
1589 | * @since 1.1 |
1590 | */ |
1591 | public static boolean isDefaultModelObjectClasspathResolutionEnabled() |
1592 | { |
1593 | if ( defaultModelObjectClasspathResolutionEnabled == null ) |
1594 | { |
1595 | defaultModelObjectClasspathResolutionEnabled = Boolean.valueOf( System.getProperty( |
1596 | "org.jomc.ri.DefaultObjectManager.defaultModelObjectClasspathResolutionEnabled", |
1597 | Boolean.toString( true ) ) ); |
1598 | |
1599 | } |
1600 | |
1601 | return defaultModelObjectClasspathResolutionEnabled; |
1602 | } |
1603 | |
1604 | /** |
1605 | * Sets the flag indicating model object class path resolution is enabled by default. |
1606 | * |
1607 | * @param value The new value of the flag indicating model object class path resolution is enabled by default or |
1608 | * {@code null}. |
1609 | * |
1610 | * @see #isDefaultModelObjectClasspathResolutionEnabled() |
1611 | * |
1612 | * @since 1.1 |
1613 | */ |
1614 | public static void setDefaultModelObjectClasspathResolutionEnabled( final Boolean value ) |
1615 | { |
1616 | defaultModelObjectClasspathResolutionEnabled = value; |
1617 | } |
1618 | |
1619 | /** |
1620 | * Gets a flag indicating model object class path resolution is enabled. |
1621 | * |
1622 | * @return {@code true}, if model object class path resolution is enabled; {@code false}, if model object class path |
1623 | * resolution is disabled. |
1624 | * |
1625 | * @see #isDefaultModelObjectClasspathResolutionEnabled() |
1626 | * @see #setModelObjectClasspathResolutionEnabled(java.lang.Boolean) |
1627 | * |
1628 | * @since 1.1 |
1629 | */ |
1630 | public final boolean isModelObjectClasspathResolutionEnabled() |
1631 | { |
1632 | if ( this.modelObjectClasspathResolutionEnabled == null ) |
1633 | { |
1634 | this.modelObjectClasspathResolutionEnabled = isDefaultModelObjectClasspathResolutionEnabled(); |
1635 | |
1636 | if ( this.isLoggable( Level.CONFIG ) ) |
1637 | { |
1638 | this.log( Level.CONFIG, getDefaultModelObjectClasspahResolutionEnabledInfo( |
1639 | Locale.getDefault(), Boolean.toString( this.modelObjectClasspathResolutionEnabled ) ), null ); |
1640 | |
1641 | } |
1642 | } |
1643 | |
1644 | return this.modelObjectClasspathResolutionEnabled; |
1645 | } |
1646 | |
1647 | /** |
1648 | * Sets the flag indicating model object class path resolution is enabled. |
1649 | * |
1650 | * @param value The new value of the flag indicating model object class path resolution is enabled or {@code null}. |
1651 | * |
1652 | * @see #isModelObjectClasspathResolutionEnabled() |
1653 | * |
1654 | * @since 1.1 |
1655 | */ |
1656 | public final void setModelObjectClasspathResolutionEnabled( final Boolean value ) |
1657 | { |
1658 | this.modelObjectClasspathResolutionEnabled = value; |
1659 | } |
1660 | |
1661 | /** |
1662 | * Gets a flag indicating model processing is enabled by default. |
1663 | * <p>The default model processing enabled flag is controlled by system property |
1664 | * {@code org.jomc.ri.DefaultObjectManager.defaultModelProcessingEnabled} holding a boolean indicating model |
1665 | * processing is enabled by default. If that property is not set, the {@code true} default is returned.</p> |
1666 | * |
1667 | * @return {@code true}, if model processing is enabled by default; {@code false}, if model processing is disabled |
1668 | * by default. |
1669 | * |
1670 | * @see #isModelProcessingEnabled() |
1671 | * @see #setDefaultModelProcessingEnabled(java.lang.Boolean) |
1672 | * |
1673 | * @since 1.1 |
1674 | */ |
1675 | public static boolean isDefaultModelProcessingEnabled() |
1676 | { |
1677 | if ( defaultModelProcessingEnabled == null ) |
1678 | { |
1679 | defaultModelProcessingEnabled = Boolean.valueOf( System.getProperty( |
1680 | "org.jomc.ri.DefaultObjectManager.defaultModelProcessingEnabled", Boolean.toString( true ) ) ); |
1681 | |
1682 | } |
1683 | |
1684 | return defaultModelProcessingEnabled; |
1685 | } |
1686 | |
1687 | /** |
1688 | * Sets the flag indicating model processing is enabled by default. |
1689 | * |
1690 | * @param value The new value of the flag indicating model processing is enabled by default or {@code null}. |
1691 | * |
1692 | * @see #isDefaultModelProcessingEnabled() |
1693 | * |
1694 | * @since 1.1 |
1695 | */ |
1696 | public static void setDefaultModelProcessingEnabled( final Boolean value ) |
1697 | { |
1698 | defaultModelProcessingEnabled = value; |
1699 | } |
1700 | |
1701 | /** |
1702 | * Gets a flag indicating model processing is enabled. |
1703 | * |
1704 | * @return {@code true}, if model processing is enabled; {@code false}, if model processing is disabled . |
1705 | * |
1706 | * @see #isDefaultModelProcessingEnabled() |
1707 | * @see #setModelProcessingEnabled(java.lang.Boolean) |
1708 | * |
1709 | * @since 1.1 |
1710 | */ |
1711 | public final boolean isModelProcessingEnabled() |
1712 | { |
1713 | if ( this.modelProcessingEnabled == null ) |
1714 | { |
1715 | this.modelProcessingEnabled = isDefaultModelProcessingEnabled(); |
1716 | |
1717 | if ( this.isLoggable( Level.CONFIG ) ) |
1718 | { |
1719 | this.log( Level.CONFIG, getDefaultModelProcessingEnabledInfo( |
1720 | Locale.getDefault(), Boolean.toString( this.modelProcessingEnabled ) ), null ); |
1721 | |
1722 | } |
1723 | } |
1724 | |
1725 | return this.modelProcessingEnabled; |
1726 | } |
1727 | |
1728 | /** |
1729 | * Sets the flag indicating model processing is enabled. |
1730 | * |
1731 | * @param value The new value of the flag indicating model processing is enabled or {@code null}. |
1732 | * |
1733 | * @see #isModelProcessingEnabled() |
1734 | * |
1735 | * @since 1.1 |
1736 | */ |
1737 | public final void setModelProcessingEnabled( final Boolean value ) |
1738 | { |
1739 | this.modelProcessingEnabled = value; |
1740 | } |
1741 | |
1742 | /** |
1743 | * Gets the name of the platform's bootstrap class loader class. |
1744 | * <p>The name of the platform's bootstrap class loader class is controlled by system property |
1745 | * {@code org.jomc.ri.DefaultObjectManager.bootstrapClassLoaderClassName} holding the name of the platform's |
1746 | * bootstrap class loader class. If that property is not set, the bootstrap class loader is assumed to be |
1747 | * represented by a {@code null} parent class loader.</p> |
1748 | * |
1749 | * @return The name of the platform's bootstrap class loader class or {@code null}. |
1750 | * |
1751 | * @see #getClassLoader(java.lang.ClassLoader) |
1752 | */ |
1753 | public static String getBootstrapClassLoaderClassName() |
1754 | { |
1755 | if ( bootstrapClassLoaderClassName == null && !bootstrapClassLoaderClassNameInitialized ) |
1756 | { |
1757 | bootstrapClassLoaderClassName = |
1758 | System.getProperty( "org.jomc.ri.DefaultObjectManager.bootstrapClassLoaderClassName" ); |
1759 | |
1760 | bootstrapClassLoaderClassNameInitialized = true; |
1761 | } |
1762 | |
1763 | return bootstrapClassLoaderClassName; |
1764 | } |
1765 | |
1766 | /** |
1767 | * Sets the name of the platform's bootstrap class loader class. |
1768 | * |
1769 | * @param value The new name of the platform's bootstrap class loader class or {@code null}. |
1770 | * |
1771 | * @see #getBootstrapClassLoaderClassName() |
1772 | */ |
1773 | public static void setBootstrapClassLoaderClassName( final String value ) |
1774 | { |
1775 | bootstrapClassLoaderClassName = value; |
1776 | bootstrapClassLoaderClassNameInitialized = false; |
1777 | } |
1778 | |
1779 | /** |
1780 | * Gets the modules registered with a given class loader. |
1781 | * |
1782 | * @param classLoader The class loader to get the modules of. |
1783 | * |
1784 | * @return The modules of the given class loader. |
1785 | * |
1786 | * @throws NullPointerException if {@code classLoader} is {@code null}. |
1787 | * @throws ObjectManagementException if getting the modules fails. |
1788 | * |
1789 | * @see #getDefaultModules() |
1790 | * @see #getModelIdentifier() |
1791 | * @see #isModelObjectClasspathResolutionEnabled() |
1792 | * @see #isModelProcessingEnabled() |
1793 | * @see #getRuntimeModules(org.jomc.model.Modules, java.util.Map) |
1794 | */ |
1795 | public Modules getModules( final ClassLoader classLoader ) |
1796 | { |
1797 | if ( classLoader == null ) |
1798 | { |
1799 | throw new NullPointerException( "classLoader" ); |
1800 | } |
1801 | |
1802 | synchronized ( this.modules ) |
1803 | { |
1804 | Modules cachedModules = this.modules.get( classLoader ); |
1805 | |
1806 | if ( cachedModules == null ) |
1807 | { |
1808 | final List<LogRecord> logRecords = new ArrayList<LogRecord>( 1024 ); |
1809 | |
1810 | try |
1811 | { |
1812 | final ModelContext modelContext = ModelContextFactory.newInstance().newModelContext( classLoader ); |
1813 | |
1814 | logRecords.add( new LogRecord( Level.FINER, getCreatingModulesInfo( |
1815 | Locale.getDefault(), this.getClassLoaderInfo( classLoader, null ) ) ) ); |
1816 | |
1817 | modelContext.setLogLevel( this.getLogLevel() ); |
1818 | modelContext.getListeners().add( new ModelContext.Listener() |
1819 | { |
1820 | |
1821 | @Override |
1822 | public void onLog( final Level level, final String message, final Throwable t ) |
1823 | { |
1824 | super.onLog( level, message, t ); |
1825 | final LogRecord r = new LogRecord( level, message ); |
1826 | r.setThrown( t ); |
1827 | |
1828 | logRecords.add( r ); |
1829 | } |
1830 | |
1831 | } ); |
1832 | |
1833 | Model model = modelContext.findModel( this.getModelIdentifier() ); |
1834 | cachedModules = ModelHelper.getModules( model ); |
1835 | |
1836 | if ( cachedModules != null ) |
1837 | { |
1838 | if ( this.isModelObjectClasspathResolutionEnabled() ) |
1839 | { |
1840 | final Module classpathModule = cachedModules.getClasspathModule( |
1841 | Modules.getDefaultClasspathModuleName(), classLoader ); |
1842 | |
1843 | if ( classpathModule != null ) |
1844 | { |
1845 | cachedModules.getModule().add( classpathModule ); |
1846 | } |
1847 | } |
1848 | |
1849 | if ( this.isModelProcessingEnabled() ) |
1850 | { |
1851 | model = modelContext.processModel( model ); |
1852 | } |
1853 | |
1854 | final ModelValidationReport validationReport = modelContext.validateModel( model ); |
1855 | |
1856 | for ( ModelValidationReport.Detail d : validationReport.getDetails() ) |
1857 | { |
1858 | final LogRecord r = new LogRecord( d.getLevel(), d.getMessage() ); |
1859 | logRecords.add( r ); |
1860 | } |
1861 | |
1862 | cachedModules = validationReport.isModelValid() ? ModelHelper.getModules( model ) : null; |
1863 | } |
1864 | } |
1865 | catch ( final ModelException e ) |
1866 | { |
1867 | cachedModules = null; |
1868 | |
1869 | final LogRecord r = new LogRecord( Level.SEVERE, getMessage( e ) ); |
1870 | r.setThrown( e ); |
1871 | logRecords.add( r ); |
1872 | } |
1873 | |
1874 | if ( cachedModules == null ) |
1875 | { |
1876 | cachedModules = this.getDefaultModules(); |
1877 | |
1878 | logRecords.add( new LogRecord( Level.WARNING, getDefaultModulesWarning( |
1879 | Locale.getDefault(), this.getModelIdentifier(), |
1880 | this.getClassLoaderInfo( classLoader, null ) ) ) ); |
1881 | |
1882 | } |
1883 | |
1884 | final ClassLoader objectsLoader = this.getDefaultClassLoader( classLoader ); |
1885 | |
1886 | synchronized ( this.objects ) |
1887 | { |
1888 | Map<Object, Instance> objectMap = this.objects.get( objectsLoader ); |
1889 | if ( objectMap == null ) |
1890 | { |
1891 | objectMap = new WeakIdentityHashMap<Object, Instance>(); |
1892 | this.objects.put( objectsLoader, objectMap ); |
1893 | } |
1894 | |
1895 | cachedModules = this.getRuntimeModules( cachedModules, objectMap ); |
1896 | |
1897 | if ( cachedModules instanceof RuntimeModelObject ) |
1898 | { |
1899 | ( (RuntimeModelObject) cachedModules ).clear(); |
1900 | } |
1901 | } |
1902 | |
1903 | this.modules.put( classLoader, cachedModules ); |
1904 | |
1905 | for ( LogRecord r : logRecords ) |
1906 | { |
1907 | this.log( classLoader, r.getLevel(), r.getMessage(), r.getThrown() ); |
1908 | } |
1909 | |
1910 | if ( this.isLoggable( Level.FINEST ) ) |
1911 | { |
1912 | this.logModulesReport( cachedModules, classLoader ); |
1913 | } |
1914 | } |
1915 | |
1916 | return cachedModules; |
1917 | } |
1918 | } |
1919 | |
1920 | /** |
1921 | * Gets a new default modules instance. |
1922 | * |
1923 | * @return A new default modules instance. |
1924 | * |
1925 | * @throws ObjectManagementException if getting a new default modules instance fails. |
1926 | * |
1927 | * @see #getModules(java.lang.ClassLoader) |
1928 | * |
1929 | * @since 1.1 |
1930 | */ |
1931 | public Modules getDefaultModules() |
1932 | { |
1933 | final Modules defaultModules = new Modules(); |
1934 | final Module defaultModule = new Module(); |
1935 | defaultModule.setSpecifications( new Specifications() ); |
1936 | defaultModule.setImplementations( new Implementations() ); |
1937 | defaultModules.getModule().add( defaultModule ); |
1938 | defaultModule.setName( getDefaultModuleName( Locale.getDefault() ) ); |
1939 | |
1940 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1941 | ObjectManager.class, Multiplicity.ONE, SINGLETON_SCOPE_IDENTIFIER ) ); |
1942 | |
1943 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1944 | Scope.class, null, null ) ); |
1945 | |
1946 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1947 | Listener.class, null, null ) ); |
1948 | |
1949 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1950 | Locator.class, null, null ) ); |
1951 | |
1952 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1953 | Invoker.class, null, null ) ); |
1954 | |
1955 | defaultModule.getSpecifications().getSpecification().add( createDefaultSpecification( |
1956 | Invocation.class, Multiplicity.ONE, null ) ); |
1957 | |
1958 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1959 | ObjectManagerFactory.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1960 | |
1961 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1962 | ObjectManagementException.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1963 | |
1964 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1965 | DefaultInvocation.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1966 | |
1967 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1968 | DefaultInvoker.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1969 | |
1970 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1971 | DefaultListener.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1972 | |
1973 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1974 | DefaultLocator.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1975 | |
1976 | defaultModule.getImplementations().getImplementation().add( createDefaultImplementation( |
1977 | DefaultScope.class, getDefaultImplementationName( Locale.getDefault() ) ) ); |
1978 | |
1979 | final Implementation defaultObjectManager = createDefaultImplementation( |
1980 | DefaultObjectManager.class, getDefaultImplementationName( Locale.getDefault() ) ); |
1981 | |
1982 | defaultObjectManager.setSpecifications( new Specifications() ); |
1983 | |
1984 | final SpecificationReference refObjectManager = new SpecificationReference(); |
1985 | refObjectManager.setIdentifier( ObjectManager.class.getName() ); |
1986 | refObjectManager.setVersion( getDefaultModulesVersion( Locale.getDefault() ) ); |
1987 | defaultObjectManager.getSpecifications().getReference().add( refObjectManager ); |
1988 | |
1989 | defaultModule.getImplementations().getImplementation().add( defaultObjectManager ); |
1990 | return defaultModules; |
1991 | } |
1992 | |
1993 | /** |
1994 | * Gets a new {@code Modules} instance to register with a class loader. |
1995 | * |
1996 | * @param modules The modules prepared for registration with a class loader. |
1997 | * @param objectMap The object map to associate with the given modules. |
1998 | * |
1999 | * @return The instance to register with a class loader. |
2000 | * |
2001 | * @throws NullPointerException if {@code modules} or {@code objectMap} is {@code null}. |
2002 | * |
2003 | * @see #getModules(java.lang.ClassLoader) |
2004 | * @see RuntimeModules |
2005 | * |
2006 | * @since 1.2 |
2007 | */ |
2008 | public Modules getRuntimeModules( final Modules modules, final Map<Object, Instance> objectMap ) |
2009 | { |
2010 | if ( modules == null ) |
2011 | { |
2012 | throw new NullPointerException( "modules" ); |
2013 | } |
2014 | if ( objectMap == null ) |
2015 | { |
2016 | throw new NullPointerException( "objectMap" ); |
2017 | } |
2018 | |
2019 | return new RuntimeModules( modules, objectMap ); |
2020 | } |
2021 | |
2022 | /** |
2023 | * Gets the class loader of a given class. |
2024 | * |
2025 | * @param clazz The class whose class loader to get. |
2026 | * |
2027 | * @return The class loader of {@code clazz}. |
2028 | * |
2029 | * @throws NullPointerException if {@code clazz} is {@code null}. |
2030 | * |
2031 | * @since 1.1 |
2032 | */ |
2033 | public ClassLoader getDefaultClassLoader( final Class<?> clazz ) |
2034 | { |
2035 | if ( clazz == null ) |
2036 | { |
2037 | throw new NullPointerException( "clazz" ); |
2038 | } |
2039 | |
2040 | ClassLoader cl = clazz.getClassLoader(); |
2041 | if ( cl == null ) |
2042 | { |
2043 | cl = BOOTSTRAP_CLASSLOADER; |
2044 | } |
2045 | |
2046 | return cl; |
2047 | } |
2048 | |
2049 | /** |
2050 | * Gets the parent class loader of a given class loader recursively. |
2051 | * <p>This method recursively finds the parent class loader of the given class loader. Recursion stops at the |
2052 | * platform's bootstrap class loader. That class loader is detected when either the current class loader has no |
2053 | * parent (a call to the {@code getParent()} method returns {@code null}) or when the class name of the |
2054 | * current class loader's parent class loader is equal to the name returned by method |
2055 | * {@code getBootstrapClassLoaderClassName()}. Configuration of the name of the platform's bootstrap class loader |
2056 | * class is needed when the platform's {@code getParent()} method of the {@code ClassLoader} class does not return |
2057 | * {@code null} to indicate the bootstrap class loader but instead returns an instance of {@code ClassLoader}.</p> |
2058 | * |
2059 | * @param classLoader The class loader whose parent class loader to return or {@code null} to return a |
2060 | * {@code ClassLoader} instance representing the platform's bootstrap class loader. |
2061 | * |
2062 | * @return The parent class loader of {@code classLoader}. |
2063 | * |
2064 | * @throws NullPointerException if {@code classLoader} is {@code null}. |
2065 | * |
2066 | * @see #getBootstrapClassLoaderClassName() |
2067 | * @see ClassLoader#getParent() |
2068 | * |
2069 | * @since 1.1 |
2070 | */ |
2071 | public ClassLoader getDefaultClassLoader( final ClassLoader classLoader ) |
2072 | { |
2073 | if ( classLoader == null ) |
2074 | { |
2075 | return BOOTSTRAP_CLASSLOADER; |
2076 | } |
2077 | |
2078 | synchronized ( defaultClassLoaders ) |
2079 | { |
2080 | ClassLoader loader = null; |
2081 | Reference<ClassLoader> reference = defaultClassLoaders.get( classLoader ); |
2082 | |
2083 | if ( reference != null ) |
2084 | { |
2085 | loader = reference.get(); |
2086 | } |
2087 | |
2088 | if ( loader == null ) |
2089 | { |
2090 | if ( classLoader.getParent() != null |
2091 | && !classLoader.getParent().getClass().getName().equals( getBootstrapClassLoaderClassName() ) ) |
2092 | { |
2093 | loader = this.getDefaultClassLoader( classLoader.getParent() ); |
2094 | } |
2095 | else |
2096 | { |
2097 | loader = classLoader; |
2098 | } |
2099 | |
2100 | defaultClassLoaders.put( classLoader, new WeakReference<ClassLoader>( loader ) ); |
2101 | } |
2102 | |
2103 | return loader; |
2104 | } |
2105 | } |
2106 | |
2107 | /** |
2108 | * Gets the class loader of a given class. |
2109 | * |
2110 | * @param clazz The class whose class loader to return. |
2111 | * |
2112 | * @return The class loader of {@code clazz}. |
2113 | * |
2114 | * @throws NullPointerException if {@code clazz} is {@code null}. |
2115 | * |
2116 | * @deprecated As of JOMC 1.1, please use method {@link #getDefaultClassLoader(java.lang.Class)}. This method will |
2117 | * be removed in version 2.0. |
2118 | */ |
2119 | @Deprecated |
2120 | public static ClassLoader getClassLoader( final Class<?> clazz ) |
2121 | { |
2122 | if ( clazz == null ) |
2123 | { |
2124 | throw new NullPointerException( "clazz" ); |
2125 | } |
2126 | |
2127 | ClassLoader cl = clazz.getClassLoader(); |
2128 | if ( cl == null ) |
2129 | { |
2130 | cl = BOOTSTRAP_CLASSLOADER; |
2131 | } |
2132 | |
2133 | return cl; |
2134 | } |
2135 | |
2136 | /** |
2137 | * Gets the parent class loader of a given class loader recursively. |
2138 | * <p>This method recursively finds the parent class loader of the given class loader. Recursion stops at the |
2139 | * platform's bootstrap class loader. That class loader is detected when either the current class loader has no |
2140 | * parent (a call to the {@code getParent()} method returns {@code null}) or when the class name of the |
2141 | * current class loader's parent class loader is equal to the name returned by method |
2142 | * {@code getBootstrapClassLoaderClassName()}. Configuration of the name of the platform's bootstrap class loader |
2143 | * class is needed when the platform's {@code getParent()} method of the {@code ClassLoader} class does not return |
2144 | * {@code null} to indicate the bootstrap class loader but instead returns an instance of {@code ClassLoader}.</p> |
2145 | * |
2146 | * @param classLoader The class loader whose parent class loader to return or {@code null} to return a |
2147 | * {@code ClassLoader} instance representing the platform's bootstrap class loader. |
2148 | * |
2149 | * @return The parent class loader of {@code classLoader}. |
2150 | * |
2151 | * @throws NullPointerException if {@code classLoader} is {@code null}. |
2152 | * |
2153 | * @see #getBootstrapClassLoaderClassName() |
2154 | * @see ClassLoader#getParent() |
2155 | * |
2156 | * @deprecated As of JOMC 1.1, please use method {@link #getDefaultClassLoader(java.lang.ClassLoader)}. This method |
2157 | * will be removed in version 2.0. |
2158 | */ |
2159 | @Deprecated |
2160 | public static ClassLoader getClassLoader( final ClassLoader classLoader ) |
2161 | { |
2162 | if ( classLoader == null ) |
2163 | { |
2164 | return BOOTSTRAP_CLASSLOADER; |
2165 | } |
2166 | |
2167 | synchronized ( defaultClassLoaders ) |
2168 | { |
2169 | ClassLoader loader = null; |
2170 | Reference<ClassLoader> reference = defaultClassLoaders.get( classLoader ); |
2171 | |
2172 | if ( reference != null ) |
2173 | { |
2174 | loader = reference.get(); |
2175 | } |
2176 | |
2177 | if ( loader == null ) |
2178 | { |
2179 | if ( classLoader.getParent() != null |
2180 | && !classLoader.getParent().getClass().getName().equals( getBootstrapClassLoaderClassName() ) ) |
2181 | { |
2182 | loader = getClassLoader( classLoader.getParent() ); |
2183 | } |
2184 | else |
2185 | { |
2186 | loader = classLoader; |
2187 | } |
2188 | |
2189 | defaultClassLoaders.put( classLoader, new WeakReference<ClassLoader>( loader ) ); |
2190 | } |
2191 | |
2192 | return loader; |
2193 | } |
2194 | } |
2195 | |
2196 | /** |
2197 | * Gets an object of a given instance from a given scope. |
2198 | * |
2199 | * @param scope The scope to get the object from or {@code null}. |
2200 | * @param instance The instance of the object to get. |
2201 | * @param classLoader The class loader to use for creating the object. |
2202 | * |
2203 | * @return An object of {@code instance} from {@code scope} or {@code null}, if no such object is found. |
2204 | * |
2205 | * @throws NullPointerException if {@code instance} or {@code classLoader} is {@code null}. |
2206 | * @throws ObjectManagementException if getting an object fails. |
2207 | */ |
2208 | public Object getObject( final Scope scope, final Instance instance, final ClassLoader classLoader ) |
2209 | { |
2210 | if ( instance == null ) |
2211 | { |
2212 | throw new NullPointerException( "instance" ); |
2213 | } |
2214 | if ( classLoader == null ) |
2215 | { |
2216 | throw new NullPointerException( "classLoader" ); |
2217 | } |
2218 | |
2219 | try |
2220 | { |
2221 | Object object = null; |
2222 | |
2223 | if ( scope != null ) |
2224 | { |
2225 | synchronized ( instance ) |
2226 | { |
2227 | boolean created = true; |
2228 | |
2229 | synchronized ( scope ) |
2230 | { |
2231 | object = scope.getObject( instance.getIdentifier() ); |
2232 | |
2233 | if ( object == null ) |
2234 | { |
2235 | scope.putObject( instance.getIdentifier(), instance ); |
2236 | created = false; |
2237 | } |
2238 | } |
2239 | |
2240 | if ( object instanceof Instance ) |
2241 | { |
2242 | synchronized ( object ) |
2243 | { |
2244 | synchronized ( scope ) |
2245 | { |
2246 | object = scope.getObject( instance.getIdentifier() ); |
2247 | |
2248 | if ( object instanceof Instance ) |
2249 | { |
2250 | throw new ObjectManagementException( getDependencyCycleMessage( |
2251 | Locale.getDefault(), instance.getIdentifier() ) ); |
2252 | |
2253 | } |
2254 | } |
2255 | } |
2256 | } |
2257 | |
2258 | if ( !created ) |
2259 | { |
2260 | try |
2261 | { |
2262 | object = this.getModules( classLoader ).createObject( instance, classLoader ); |
2263 | |
2264 | if ( object != null ) |
2265 | { |
2266 | object = this.createProxy( instance, object, classLoader ); |
2267 | } |
2268 | |
2269 | created = true; |
2270 | } |
2271 | finally |
2272 | { |
2273 | synchronized ( scope ) |
2274 | { |
2275 | if ( created && object != null ) |
2276 | { |
2277 | final Object o = scope.putObject( instance.getIdentifier(), object ); |
2278 | |
2279 | if ( o != instance ) |
2280 | { |
2281 | scope.putObject( instance.getIdentifier(), o ); |
2282 | throw new AssertionError( getScopeContentionFailure( |
2283 | Locale.getDefault(), instance.getIdentifier() ) ); |
2284 | |
2285 | } |
2286 | } |
2287 | else |
2288 | { |
2289 | scope.removeObject( instance.getIdentifier() ); |
2290 | } |
2291 | } |
2292 | } |
2293 | } |
2294 | } |
2295 | } |
2296 | else |
2297 | { |
2298 | object = this.getModules( classLoader ).createObject( instance, classLoader ); |
2299 | |
2300 | if ( object != null ) |
2301 | { |
2302 | object = this.createProxy( instance, object, classLoader ); |
2303 | } |
2304 | } |
2305 | |
2306 | return object; |
2307 | } |
2308 | catch ( final ModelObjectException e ) |
2309 | { |
2310 | throw new ObjectManagementException( getMessage( e ), e ); |
2311 | } |
2312 | catch ( final InstantiationException e ) |
2313 | { |
2314 | throw new ObjectManagementException( getMessage( e ), e ); |
2315 | } |
2316 | } |
2317 | |
2318 | /** |
2319 | * Gets an object for a given location URI. |
2320 | * |
2321 | * @param specification The specification class of the object to locate. |
2322 | * @param location The location URI of the object to locate. |
2323 | * @param classLoader The class loader to use for loading locator classes. |
2324 | * @param <T> The type of the object. |
2325 | * |
2326 | * @return An object located at {@code location} or {@code null}, if no such object is found. |
2327 | * |
2328 | * @throws NullPointerException if {@code specification}, {@code location} or {@code classLoader} is {@code null}. |
2329 | * @throws ObjectManagementException if getting an object fails. |
2330 | */ |
2331 | public <T> T getObject( final Class<T> specification, final URI location, final ClassLoader classLoader ) |
2332 | { |
2333 | if ( specification == null ) |
2334 | { |
2335 | throw new NullPointerException( "specification" ); |
2336 | } |
2337 | if ( location == null ) |
2338 | { |
2339 | throw new NullPointerException( "location" ); |
2340 | } |
2341 | if ( classLoader == null ) |
2342 | { |
2343 | throw new NullPointerException( "classLoader" ); |
2344 | } |
2345 | |
2346 | try |
2347 | { |
2348 | T object = null; |
2349 | final Locator locator = this.getLocator( location, classLoader ); |
2350 | |
2351 | if ( locator != null ) |
2352 | { |
2353 | object = locator.getObject( specification, location ); |
2354 | } |
2355 | else if ( this.isLoggable( Level.WARNING ) ) |
2356 | { |
2357 | this.log( classLoader, Level.WARNING, getMissingLocatorMessage( |
2358 | Locale.getDefault(), location.getScheme() ), null ); |
2359 | |
2360 | } |
2361 | |
2362 | return object; |
2363 | } |
2364 | catch ( final IOException e ) |
2365 | { |
2366 | throw new ObjectManagementException( getMessage( e ), e ); |
2367 | } |
2368 | } |
2369 | |
2370 | /** |
2371 | * Gets the scope implementation for a given scope identifier registered with a given class loader. |
2372 | * |
2373 | * @param identifier The identifier of the scope to get an implementation of. |
2374 | * @param classLoader The class loader to use for loading scope implementations. |
2375 | * |
2376 | * @return The implementation of the scope identified by {@code identifier} or {@code null}, if no such scope |
2377 | * implementation is found. |
2378 | * |
2379 | * @throws NullPointerException if {@code classLoader} or {@code identifier} is {@code null}. |
2380 | * @throws ObjectManagementException if getting the scope implementation fails. |
2381 | * |
2382 | * @see #getDefaultScope(org.jomc.model.Modules, java.lang.String) |
2383 | */ |
2384 | public Scope getScope( final String identifier, final ClassLoader classLoader ) |
2385 | { |
2386 | if ( classLoader == null ) |
2387 | { |
2388 | throw new NullPointerException( "classLoader" ); |
2389 | } |
2390 | if ( identifier == null ) |
2391 | { |
2392 | throw new NullPointerException( "identifier" ); |
2393 | } |
2394 | |
2395 | try |
2396 | { |
2397 | final ClassLoader scopesLoader = this.getDefaultClassLoader( classLoader ); |
2398 | |
2399 | synchronized ( this.scopes ) |
2400 | { |
2401 | Map<String, Scope> cachedScopes = this.scopes.get( scopesLoader ); |
2402 | if ( cachedScopes == null ) |
2403 | { |
2404 | cachedScopes = new HashMap<String, Scope>(); |
2405 | this.scopes.put( scopesLoader, cachedScopes ); |
2406 | } |
2407 | |
2408 | Scope scope = cachedScopes.get( identifier ); |
2409 | |
2410 | if ( scope == null ) |
2411 | { |
2412 | // Bootstrap scope loading. |
2413 | final Modules model = this.getModules( classLoader ); |
2414 | final Specification scopeSpecification = model.getSpecification( Scope.class ); |
2415 | |
2416 | if ( scopeSpecification != null ) |
2417 | { |
2418 | final Implementations implementations = |
2419 | model.getImplementations( scopeSpecification.getIdentifier() ); |
2420 | |
2421 | if ( implementations != null ) |
2422 | { |
2423 | for ( int i = 0, s0 = implementations.getImplementation().size(); i < s0; i++ ) |
2424 | { |
2425 | final Implementation impl = implementations.getImplementation().get( i ); |
2426 | |
2427 | if ( identifier.equals( impl.getName() ) ) |
2428 | { |
2429 | final Instance instance = model.getInstance( impl.getIdentifier() ); |
2430 | |
2431 | if ( instance != null ) |
2432 | { |
2433 | scope = (Scope) model.createObject( instance, classLoader ); |
2434 | cachedScopes.put( identifier, scope ); |
2435 | if ( this.isLoggable( Level.CONFIG ) ) |
2436 | { |
2437 | this.log( classLoader, Level.CONFIG, getScopeInfoMessage( |
2438 | Locale.getDefault(), impl.getIdentifier(), identifier, |
2439 | this.getClassLoaderInfo( classLoader, scopesLoader ) ), null ); |
2440 | |
2441 | } |
2442 | break; |
2443 | } |
2444 | else if ( this.isLoggable( Level.WARNING ) ) |
2445 | { |
2446 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
2447 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
2448 | |
2449 | } |
2450 | } |
2451 | } |
2452 | } |
2453 | } |
2454 | else if ( this.isLoggable( Level.WARNING ) ) |
2455 | { |
2456 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
2457 | Locale.getDefault(), Scope.class.getName() ), null ); |
2458 | |
2459 | } |
2460 | |
2461 | if ( scope == null ) |
2462 | { |
2463 | scope = this.getDefaultScope( model, identifier ); |
2464 | if ( scope != null ) |
2465 | { |
2466 | cachedScopes.put( identifier, scope ); |
2467 | if ( this.isLoggable( Level.CONFIG ) ) |
2468 | { |
2469 | this.log( classLoader, Level.CONFIG, getDefaultScopeInfoMessage( |
2470 | Locale.getDefault(), identifier, |
2471 | this.getClassLoaderInfo( classLoader, scopesLoader ) ), null ); |
2472 | |
2473 | } |
2474 | } |
2475 | } |
2476 | } |
2477 | |
2478 | return scope; |
2479 | } |
2480 | } |
2481 | catch ( final ModelObjectException e ) |
2482 | { |
2483 | throw new ObjectManagementException( getMessage( e ), e ); |
2484 | } |
2485 | catch ( final InstantiationException e ) |
2486 | { |
2487 | throw new ObjectManagementException( getMessage( e ), e ); |
2488 | } |
2489 | } |
2490 | |
2491 | /** |
2492 | * Gets a new default scope implementation instance for a given identifier. |
2493 | * |
2494 | * @param identifier The identifier to get a new default scope implementation instance for. |
2495 | * |
2496 | * @return A new default scope implementation instance for {@code identifier} or {@code null}, if no such instance |
2497 | * is available. |
2498 | * |
2499 | * @throws NullPointerException if {@code identifier} is {@code null}. |
2500 | * |
2501 | * @see #getScope(java.lang.String, java.lang.ClassLoader) |
2502 | * |
2503 | * @deprecated As of JOMC 1.2, replaced by method {@link #getDefaultScope(org.jomc.model.Modules,java.lang.String)}. |
2504 | * This method will be removed in version 2.0. |
2505 | */ |
2506 | @Deprecated |
2507 | public Scope getDefaultScope( final String identifier ) |
2508 | { |
2509 | if ( identifier == null ) |
2510 | { |
2511 | throw new NullPointerException( "identifier" ); |
2512 | } |
2513 | |
2514 | DefaultScope defaultScope = null; |
2515 | |
2516 | if ( identifier.equals( SINGLETON_SCOPE_IDENTIFIER ) ) |
2517 | { |
2518 | defaultScope = new DefaultScope( new HashMap<String, Object>() ); |
2519 | } |
2520 | |
2521 | return defaultScope; |
2522 | } |
2523 | |
2524 | /** |
2525 | * Gets a new default scope implementation instance for a given identifier. |
2526 | * |
2527 | * @param model The model to get a new default scope implementation instance of. |
2528 | * @param identifier The identifier to get a new default scope implementation instance for. |
2529 | * |
2530 | * @return A new default scope implementation instance for {@code identifier} or {@code null}, if no such instance |
2531 | * is available. |
2532 | * |
2533 | * @throws NullPointerException if {@code model} or {@code identifier} is {@code null}. |
2534 | * @throws ObjectManagementException if getting a new default scope implementation instance fails. |
2535 | * |
2536 | * @see #getScope(java.lang.String, java.lang.ClassLoader) |
2537 | */ |
2538 | public Scope getDefaultScope( final Modules model, final String identifier ) |
2539 | { |
2540 | if ( model == null ) |
2541 | { |
2542 | throw new NullPointerException( "model" ); |
2543 | } |
2544 | if ( identifier == null ) |
2545 | { |
2546 | throw new NullPointerException( "identifier" ); |
2547 | } |
2548 | |
2549 | try |
2550 | { |
2551 | Scope defaultScope = null; |
2552 | |
2553 | if ( identifier.equals( SINGLETON_SCOPE_IDENTIFIER ) ) |
2554 | { |
2555 | defaultScope = new DefaultScope( new HashMap<String, Object>() ); |
2556 | model.getInstance( defaultScope ); |
2557 | } |
2558 | |
2559 | return defaultScope; |
2560 | } |
2561 | catch ( final ModelObjectException e ) |
2562 | { |
2563 | throw new ObjectManagementException( getMessage( e ), e ); |
2564 | } |
2565 | } |
2566 | |
2567 | /** |
2568 | * Gets a locator to use with a given location URI registered with a given class loader. |
2569 | * |
2570 | * @param location The location URI to get a locator for. |
2571 | * @param classLoader The class loader to use for loading locator implementations. |
2572 | * |
2573 | * @return The locator to use for locating objects at {@code location} or {@code null}, if no such locator is |
2574 | * available. |
2575 | * |
2576 | * @throws NullPointerException if {@code classLoader} or {@code location} is {@code null}. |
2577 | * @throws ObjectManagementException if getting a locator fails. |
2578 | * |
2579 | * @see #getDefaultLocator(org.jomc.model.Modules, java.net.URI) |
2580 | */ |
2581 | public Locator getLocator( final URI location, final ClassLoader classLoader ) |
2582 | { |
2583 | if ( classLoader == null ) |
2584 | { |
2585 | throw new NullPointerException( "classLoader" ); |
2586 | } |
2587 | if ( location == null ) |
2588 | { |
2589 | throw new NullPointerException( "location" ); |
2590 | } |
2591 | |
2592 | try |
2593 | { |
2594 | final String scheme = location.getScheme(); |
2595 | |
2596 | if ( scheme != null ) |
2597 | { |
2598 | final ClassLoader locatorsLoader = this.getDefaultClassLoader( classLoader ); |
2599 | |
2600 | synchronized ( this.locators ) |
2601 | { |
2602 | Map<String, Locator> cachedLocators = this.locators.get( locatorsLoader ); |
2603 | if ( cachedLocators == null ) |
2604 | { |
2605 | cachedLocators = new HashMap<String, Locator>(); |
2606 | this.locators.put( locatorsLoader, cachedLocators ); |
2607 | } |
2608 | |
2609 | Locator locator = cachedLocators.get( scheme ); |
2610 | |
2611 | if ( locator == null ) |
2612 | { |
2613 | // Bootstrap locator loading. |
2614 | final Modules model = this.getModules( classLoader ); |
2615 | final Specification locatorSpecification = model.getSpecification( Locator.class ); |
2616 | |
2617 | if ( locatorSpecification != null ) |
2618 | { |
2619 | final Implementations implementations = |
2620 | model.getImplementations( locatorSpecification.getIdentifier() ); |
2621 | |
2622 | if ( implementations != null ) |
2623 | { |
2624 | for ( int i = 0, s0 = implementations.getImplementation().size(); i < s0; i++ ) |
2625 | { |
2626 | final Implementation impl = implementations.getImplementation().get( i ); |
2627 | |
2628 | if ( scheme.equals( impl.getName() ) ) |
2629 | { |
2630 | final Instance instance = model.getInstance( impl.getIdentifier() ); |
2631 | |
2632 | if ( instance != null ) |
2633 | { |
2634 | locator = (Locator) model.createObject( instance, classLoader ); |
2635 | cachedLocators.put( scheme, locator ); |
2636 | |
2637 | if ( this.isLoggable( Level.CONFIG ) ) |
2638 | { |
2639 | this.log( classLoader, Level.CONFIG, getLocatorInfoMessage( |
2640 | Locale.getDefault(), impl.getIdentifier(), scheme, |
2641 | this.getClassLoaderInfo( classLoader, locatorsLoader ) ), null ); |
2642 | |
2643 | } |
2644 | |
2645 | break; |
2646 | } |
2647 | else if ( this.isLoggable( Level.WARNING ) ) |
2648 | { |
2649 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
2650 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
2651 | |
2652 | } |
2653 | } |
2654 | } |
2655 | } |
2656 | } |
2657 | else if ( this.isLoggable( Level.WARNING ) ) |
2658 | { |
2659 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
2660 | Locale.getDefault(), Locator.class.getName() ), null ); |
2661 | |
2662 | } |
2663 | |
2664 | if ( locator == null ) |
2665 | { |
2666 | locator = this.getDefaultLocator( model, location ); |
2667 | if ( locator != null ) |
2668 | { |
2669 | cachedLocators.put( scheme, locator ); |
2670 | if ( this.isLoggable( Level.CONFIG ) ) |
2671 | { |
2672 | this.log( classLoader, Level.CONFIG, getDefaultLocatorInfoMessage( |
2673 | Locale.getDefault(), scheme, |
2674 | this.getClassLoaderInfo( classLoader, locatorsLoader ) ), null ); |
2675 | |
2676 | } |
2677 | } |
2678 | } |
2679 | } |
2680 | |
2681 | return locator; |
2682 | } |
2683 | } |
2684 | |
2685 | return null; |
2686 | } |
2687 | catch ( final ModelObjectException e ) |
2688 | { |
2689 | throw new ObjectManagementException( getMessage( e ), e ); |
2690 | } |
2691 | catch ( final InstantiationException e ) |
2692 | { |
2693 | throw new ObjectManagementException( getMessage( e ), e ); |
2694 | } |
2695 | } |
2696 | |
2697 | /** |
2698 | * Gets a new default locator implementation instance for a given location URI. |
2699 | * |
2700 | * @param location The location URI to get a new default locator implementation instance for. |
2701 | * |
2702 | * @return A new default locator implementation instance for {@code location} or {@code null}, if no such instance |
2703 | * is available. |
2704 | * |
2705 | * @throws NullPointerException if {@code location} is {@code null}. |
2706 | * |
2707 | * @see #getLocator(java.net.URI, java.lang.ClassLoader) |
2708 | * |
2709 | * @deprecated As of JOMC 1.2, replaced by method {@link #getDefaultLocator(org.jomc.model.Modules, java.net.URI)}. |
2710 | * This method will be removed in version 2.0. |
2711 | */ |
2712 | @Deprecated |
2713 | public Locator getDefaultLocator( final URI location ) |
2714 | { |
2715 | if ( location == null ) |
2716 | { |
2717 | throw new NullPointerException( "location" ); |
2718 | } |
2719 | |
2720 | Locator locator = null; |
2721 | final DefaultLocator defaultLocator = new DefaultLocator(); |
2722 | |
2723 | if ( defaultLocator.isLocationSupported( location ) ) |
2724 | { |
2725 | locator = defaultLocator; |
2726 | } |
2727 | |
2728 | return locator; |
2729 | } |
2730 | |
2731 | /** |
2732 | * Gets a new default locator implementation instance for a given location URI. |
2733 | * |
2734 | * @param model The model to get a new default location implementation instance of. |
2735 | * @param location The location URI to get a new default locator implementation instance for. |
2736 | * |
2737 | * @return A new default locator implementation instance for {@code location} or {@code null}, if no such instance |
2738 | * is available. |
2739 | * |
2740 | * @throws NullPointerException if {@code model} or {@code location} is {@code null}. |
2741 | * @throws ObjectManagementException if getting a new default locator implementation instance fails. |
2742 | * |
2743 | * @see #getLocator(java.net.URI, java.lang.ClassLoader) |
2744 | * |
2745 | * @since 1.2 |
2746 | */ |
2747 | public Locator getDefaultLocator( final Modules model, final URI location ) |
2748 | { |
2749 | if ( model == null ) |
2750 | { |
2751 | throw new NullPointerException( "model" ); |
2752 | } |
2753 | if ( location == null ) |
2754 | { |
2755 | throw new NullPointerException( "location" ); |
2756 | } |
2757 | |
2758 | try |
2759 | { |
2760 | Locator locator = null; |
2761 | final DefaultLocator defaultLocator = new DefaultLocator(); |
2762 | |
2763 | if ( defaultLocator.isLocationSupported( location ) ) |
2764 | { |
2765 | locator = defaultLocator; |
2766 | model.getInstance( locator ); |
2767 | } |
2768 | |
2769 | return locator; |
2770 | } |
2771 | catch ( final ModelObjectException e ) |
2772 | { |
2773 | throw new ObjectManagementException( getMessage( e ), e ); |
2774 | } |
2775 | } |
2776 | |
2777 | /** |
2778 | * Gets the invoker registered with a given class loader. |
2779 | * |
2780 | * @param classLoader The class loader to use for loading invoker implementations. |
2781 | * |
2782 | * @return The invoker of the given class loader. |
2783 | * |
2784 | * @throws NullPointerException if {@code classLoader} is {@code null}. |
2785 | * @throws ObjectManagementException if getting the invoker fails. |
2786 | * |
2787 | * @see #getDefaultInvoker(org.jomc.model.Modules) |
2788 | */ |
2789 | public Invoker getInvoker( final ClassLoader classLoader ) |
2790 | { |
2791 | if ( classLoader == null ) |
2792 | { |
2793 | throw new NullPointerException( "classLoader" ); |
2794 | } |
2795 | |
2796 | try |
2797 | { |
2798 | final ClassLoader invokersLoader = this.getDefaultClassLoader( classLoader ); |
2799 | |
2800 | synchronized ( this.invokers ) |
2801 | { |
2802 | Invoker invoker = this.invokers.get( invokersLoader ); |
2803 | |
2804 | if ( invoker == null ) |
2805 | { |
2806 | final Modules model = this.getModules( classLoader ); |
2807 | final Specification invokerSpecification = model.getSpecification( Invoker.class ); |
2808 | |
2809 | if ( invokerSpecification != null ) |
2810 | { |
2811 | final Implementations implementations = |
2812 | model.getImplementations( invokerSpecification.getIdentifier() ); |
2813 | |
2814 | if ( implementations != null && !implementations.getImplementation().isEmpty() ) |
2815 | { |
2816 | for ( int i = 0, s0 = implementations.getImplementation().size(); i < s0; i++ ) |
2817 | { |
2818 | final Implementation impl = implementations.getImplementation().get( i ); |
2819 | |
2820 | if ( invoker == null ) |
2821 | { |
2822 | final Instance invokerInstance = model.getInstance( impl.getIdentifier() ); |
2823 | |
2824 | if ( invokerInstance != null ) |
2825 | { |
2826 | invoker = (Invoker) model.createObject( invokerInstance, classLoader ); |
2827 | this.invokers.put( invokersLoader, invoker ); |
2828 | |
2829 | if ( this.isLoggable( Level.CONFIG ) ) |
2830 | { |
2831 | this.log( classLoader, Level.CONFIG, getInvokerInfoMessage( |
2832 | Locale.getDefault(), impl.getIdentifier(), |
2833 | this.getClassLoaderInfo( classLoader, invokersLoader ) ), null ); |
2834 | |
2835 | } |
2836 | } |
2837 | else if ( this.isLoggable( Level.WARNING ) ) |
2838 | { |
2839 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
2840 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
2841 | |
2842 | } |
2843 | } |
2844 | else if ( this.isLoggable( Level.CONFIG ) ) |
2845 | { |
2846 | this.log( classLoader, Level.CONFIG, getIgnoredInvokerMessage( |
2847 | Locale.getDefault(), impl.getIdentifier() ), null ); |
2848 | |
2849 | } |
2850 | } |
2851 | } |
2852 | } |
2853 | else if ( this.isLoggable( Level.WARNING ) ) |
2854 | { |
2855 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
2856 | Locale.getDefault(), Invoker.class.getName() ), null ); |
2857 | |
2858 | } |
2859 | |
2860 | if ( invoker == null ) |
2861 | { |
2862 | invoker = this.getDefaultInvoker( model ); |
2863 | this.invokers.put( invokersLoader, invoker ); |
2864 | if ( this.isLoggable( Level.CONFIG ) ) |
2865 | { |
2866 | this.log( classLoader, Level.CONFIG, getDefaultInvokerInfoMessage( |
2867 | Locale.getDefault(), this.getClassLoaderInfo( classLoader, invokersLoader ) ), null ); |
2868 | |
2869 | } |
2870 | } |
2871 | } |
2872 | |
2873 | return invoker; |
2874 | } |
2875 | } |
2876 | catch ( final ModelObjectException e ) |
2877 | { |
2878 | throw new ObjectManagementException( getMessage( e ), e ); |
2879 | } |
2880 | catch ( final InstantiationException e ) |
2881 | { |
2882 | throw new ObjectManagementException( getMessage( e ), e ); |
2883 | } |
2884 | } |
2885 | |
2886 | /** |
2887 | * Gets a new default invoker implementation instance. |
2888 | * |
2889 | * @return A new default invoker implementation instance. |
2890 | * |
2891 | * @see #getInvoker(java.lang.ClassLoader) |
2892 | * |
2893 | * @since 1.1 |
2894 | * |
2895 | * @deprecated As of JOMC 1.2, replaced by method {@link #getDefaultInvoker(org.jomc.model.Modules)}. This method |
2896 | * will be removed in version 2.0. |
2897 | */ |
2898 | @Deprecated |
2899 | public Invoker getDefaultInvoker() |
2900 | { |
2901 | return new DefaultInvoker(); |
2902 | } |
2903 | |
2904 | /** |
2905 | * Gets a new default invoker implementation instance. |
2906 | * |
2907 | * @param model The model to get a new default invoker implementation instance of. |
2908 | * |
2909 | * @return A new default invoker implementation instance. |
2910 | * |
2911 | * @throws NullPointerException if {@code model} is {@code null}. |
2912 | * @throws ObjectManagementException if getting a new default invoker implementation instance fails. |
2913 | * |
2914 | * @see #getInvoker(java.lang.ClassLoader) |
2915 | * |
2916 | * @since 1.2 |
2917 | */ |
2918 | public Invoker getDefaultInvoker( final Modules model ) |
2919 | { |
2920 | if ( model == null ) |
2921 | { |
2922 | throw new NullPointerException( "model" ); |
2923 | } |
2924 | |
2925 | try |
2926 | { |
2927 | final Invoker defaultInvoker = new DefaultInvoker(); |
2928 | model.getInstance( defaultInvoker ); |
2929 | return defaultInvoker; |
2930 | } |
2931 | catch ( final ModelObjectException e ) |
2932 | { |
2933 | throw new ObjectManagementException( getMessage( e ), e ); |
2934 | } |
2935 | } |
2936 | |
2937 | /** |
2938 | * Gets an invocation for a given object, instance, method and arguments. |
2939 | * |
2940 | * @param object The object to invoke. |
2941 | * @param instance The instance of the object to invoke. |
2942 | * @param method The method to invoke on {@code object}. |
2943 | * @param arguments The arguments of the invocation or {@code null}. |
2944 | * |
2945 | * @return An invocation with {@code object}, {@code instance}, {@code method} and {@code arguments}. |
2946 | * |
2947 | * @throws NullPointerException if {@code object}, {@code instance} or {@code method} is {@code null}. |
2948 | * @throws InstantiationException if instantiating a new invocation fails. |
2949 | * |
2950 | * @deprecated As of JOMC 1.1, please use method {@link #getInvocation(java.lang.ClassLoader, java.lang.Object, org.jomc.model.Instance, java.lang.reflect.Method, java.lang.Object[])}. |
2951 | * This method will be removed in version 2.0. |
2952 | */ |
2953 | @Deprecated |
2954 | public Invocation getInvocation( final Object object, final Instance instance, final Method method, |
2955 | final Object[] arguments ) throws InstantiationException |
2956 | { |
2957 | return this.getInvocation( this.getDefaultClassLoader( object.getClass() ), object, instance, method, |
2958 | arguments ); |
2959 | |
2960 | } |
2961 | |
2962 | /** |
2963 | * Gets an invocation for a given class loader, object, instance, method and arguments. |
2964 | * |
2965 | * @param classLoader The class loader of the invocation. |
2966 | * @param object The object to invoke. |
2967 | * @param instance The instance of the object to invoke. |
2968 | * @param method The method to invoke on {@code object}. |
2969 | * @param arguments The arguments of the invocation or {@code null}. |
2970 | * |
2971 | * @return An invocation with {@code classLoader}, {@code object}, {@code instance}, {@code method} and |
2972 | * {@code arguments}. |
2973 | * |
2974 | * @throws NullPointerException if {@code classLoader} {@code object}, {@code instance} or {@code method} is |
2975 | * {@code null}. |
2976 | * @throws ObjectManagementException if getting an invocation fails. |
2977 | * |
2978 | * @see #getDefaultInvocation(org.jomc.model.Modules) |
2979 | * |
2980 | * @since 1.1 |
2981 | */ |
2982 | public Invocation getInvocation( final ClassLoader classLoader, final Object object, final Instance instance, |
2983 | final Method method, final Object[] arguments ) |
2984 | { |
2985 | if ( classLoader == null ) |
2986 | { |
2987 | throw new NullPointerException( "classLoader" ); |
2988 | } |
2989 | if ( object == null ) |
2990 | { |
2991 | throw new NullPointerException( "object" ); |
2992 | } |
2993 | if ( instance == null ) |
2994 | { |
2995 | throw new NullPointerException( "instance" ); |
2996 | } |
2997 | if ( method == null ) |
2998 | { |
2999 | throw new NullPointerException( "method" ); |
3000 | } |
3001 | |
3002 | try |
3003 | { |
3004 | Invocation invocation = null; |
3005 | final Modules model = this.getModules( classLoader ); |
3006 | final Specification invocationSpecification = model.getSpecification( Invocation.class ); |
3007 | |
3008 | if ( invocationSpecification != null ) |
3009 | { |
3010 | final Implementations implementations = |
3011 | model.getImplementations( invocationSpecification.getIdentifier() ); |
3012 | |
3013 | if ( implementations != null && !implementations.getImplementation().isEmpty() ) |
3014 | { |
3015 | for ( int i = 0, s0 = implementations.getImplementation().size(); i < s0; i++ ) |
3016 | { |
3017 | final Implementation impl = implementations.getImplementation().get( i ); |
3018 | |
3019 | if ( invocation == null ) |
3020 | { |
3021 | final Instance invocationInstance = model.getInstance( impl.getIdentifier() ); |
3022 | |
3023 | if ( invocationInstance != null ) |
3024 | { |
3025 | invocation = (Invocation) model.createObject( invocationInstance, classLoader ); |
3026 | } |
3027 | else if ( this.isLoggable( Level.WARNING ) ) |
3028 | { |
3029 | this.log( classLoader, Level.WARNING, getMissingInstanceMessage( |
3030 | Locale.getDefault(), impl.getIdentifier(), impl.getName() ), null ); |
3031 | |
3032 | } |
3033 | } |
3034 | else if ( this.isLoggable( Level.CONFIG ) ) |
3035 | { |
3036 | this.log( classLoader, Level.CONFIG, getIgnoredInvocationMessage( |
3037 | Locale.getDefault(), impl.getIdentifier() ), null ); |
3038 | |
3039 | } |
3040 | } |
3041 | } |
3042 | } |
3043 | else if ( this.isLoggable( Level.WARNING ) ) |
3044 | { |
3045 | this.log( classLoader, Level.WARNING, getMissingSpecificationMessage( |
3046 | Locale.getDefault(), Invocation.class.getName() ), null ); |
3047 | |
3048 | } |
3049 | |
3050 | if ( invocation == null ) |
3051 | { |
3052 | invocation = this.getDefaultInvocation( model ); |
3053 | } |
3054 | |
3055 | invocation.getContext().put( DefaultInvocation.OBJECT_KEY, object ); |
3056 | invocation.getContext().put( DefaultInvocation.METHOD_KEY, method ); |
3057 | invocation.getContext().put( DefaultInvocation.ARGUMENTS_KEY, arguments ); |
3058 | invocation.getContext().put( DefaultInvocation.INSTANCE_KEY, instance ); |
3059 | invocation.getContext().put( DefaultInvocation.MODULES_KEY, model ); |
3060 | invocation.getContext().put( DefaultInvocation.CLASSLOADER_KEY, classLoader ); |
3061 | return invocation; |
3062 | } |
3063 | catch ( final ModelObjectException e ) |
3064 | { |
3065 | throw new ObjectManagementException( getMessage( e ), e ); |
3066 | } |
3067 | catch ( final InstantiationException e ) |
3068 | { |
3069 | throw new ObjectManagementException( getMessage( e ), e ); |
3070 | } |
3071 | } |
3072 | |
3073 | /** |
3074 | * Gets a new default invocation implementation instance. |
3075 | * |
3076 | * @return A new default invocation implementation instance. |
3077 | * |
3078 | * @see #getInvocation(java.lang.Object, org.jomc.model.Instance, java.lang.reflect.Method, java.lang.Object[]) |
3079 | * |
3080 | * @since 1.1 |
3081 | * |
3082 | * @deprecated As of JOMC 1.2, replaced by method {@link #getDefaultInvocation(org.jomc.model.Modules)}. This method |
3083 | * will be removed in version 2.0. |
3084 | */ |
3085 | @Deprecated |
3086 | public Invocation getDefaultInvocation() |
3087 | { |
3088 | return new DefaultInvocation(); |
3089 | } |
3090 | |
3091 | /** |
3092 | * Gets a new default invocation implementation instance. |
3093 | * |
3094 | * @param model The model to get a new default invocation implementation instance of. |
3095 | * |
3096 | * @return A new default invocation implementation instance. |
3097 | * |
3098 | * @throws NullPointerException if {@code model} is {@code null}. |
3099 | * @throws ObjectManagementException if getting a new default invocation implementation instance fails. |
3100 | * |
3101 | * @see #getInvocation(java.lang.ClassLoader, java.lang.Object, org.jomc.model.Instance, java.lang.reflect.Method, java.lang.Object[]) |
3102 | * |
3103 | * @since 1.2 |
3104 | */ |
3105 | public Invocation getDefaultInvocation( final Modules model ) |
3106 | { |
3107 | if ( model == null ) |
3108 | { |
3109 | throw new NullPointerException( "model" ); |
3110 | } |
3111 | |
3112 | try |
3113 | { |
3114 | final Invocation defaultInvocation = new DefaultInvocation(); |
3115 | model.getInstance( defaultInvocation ); |
3116 | return defaultInvocation; |
3117 | } |
3118 | catch ( final ModelObjectException e ) |
3119 | { |
3120 | throw new ObjectManagementException( getMessage( e ), e ); |
3121 | } |
3122 | } |
3123 | |
3124 | /** |
3125 | * Initializes the instance. |
3126 | * <p>This method is called once on first usage of a new instance.</p> |
3127 | * |
3128 | * @throws ObjectManagementException if initialization fails. |
3129 | */ |
3130 | public synchronized void initialize() |
3131 | { |
3132 | try |
3133 | { |
3134 | if ( !this.initialized ) |
3135 | { |
3136 | try |
3137 | { |
3138 | final long t0 = System.currentTimeMillis(); |
3139 | this.initialized = true; |
3140 | |
3141 | this.listeners.clear(); |
3142 | this.modules.clear(); |
3143 | this.invokers.clear(); |
3144 | this.locators.clear(); |
3145 | this.scopes.clear(); |
3146 | |
3147 | final ClassLoader classLoader = this.getDefaultClassLoader( this.getClass() ); |
3148 | final List<LogRecord> bootstrapLogRecords = new ArrayList<LogRecord>( 1024 ); |
3149 | final List<Listener> bootstrapListeners = new ArrayList<Listener>( 1 ); |
3150 | bootstrapListeners.add( new Listener() |
3151 | { |
3152 | |
3153 | public void onLog( final Level level, final String message, final Throwable throwable ) |
3154 | { |
3155 | final LogRecord r = new LogRecord( level, message ); |
3156 | r.setThrown( throwable ); |
3157 | |
3158 | bootstrapLogRecords.add( r ); |
3159 | } |
3160 | |
3161 | } ); |
3162 | |
3163 | this.listeners.put( this.getDefaultClassLoader( classLoader ), |
3164 | Collections.unmodifiableList( bootstrapListeners ) ); |
3165 | |
3166 | final Modules model = this.getModules( classLoader ); |
3167 | final Specification objectManager = model.getSpecification( ObjectManager.class ); |
3168 | if ( objectManager == null ) |
3169 | { |
3170 | throw new InstantiationException( getMissingSpecificationMessage( |
3171 | Locale.getDefault(), ObjectManager.class.getName() ) ); |
3172 | |
3173 | } |
3174 | |
3175 | final Implementation thisImplementation = model.getImplementation( this.getClass() ); |
3176 | if ( thisImplementation == null ) |
3177 | { |
3178 | throw new InstantiationException( getMissingImplementationMessage( |
3179 | Locale.getDefault(), objectManager.getIdentifier(), this.getClass().getName() ) ); |
3180 | |
3181 | } |
3182 | |
3183 | final Instance thisInstance = model.getInstance( this ); |
3184 | if ( thisInstance == null ) |
3185 | { |
3186 | throw new InstantiationException( getMissingInstanceMessage( |
3187 | Locale.getDefault(), objectManager.getIdentifier(), thisImplementation.getName() ) ); |
3188 | |
3189 | } |
3190 | |
3191 | if ( objectManager.getScope() != null ) |
3192 | { |
3193 | final Scope scope = this.getScope( objectManager.getScope(), classLoader ); |
3194 | if ( scope == null ) |
3195 | { |
3196 | throw new InstantiationException( getMissingScopeMessage( |
3197 | Locale.getDefault(), objectManager.getScope() ) ); |
3198 | |
3199 | } |
3200 | |
3201 | scope.putObject( thisInstance.getIdentifier(), this ); |
3202 | } |
3203 | |
3204 | if ( this.isLoggable( Level.FINE ) ) |
3205 | { |
3206 | this.log( Level.FINE, getImplementationInfoMessage( |
3207 | Locale.getDefault(), Long.valueOf( System.currentTimeMillis() - t0 ) ), null ); |
3208 | |
3209 | } |
3210 | |
3211 | this.listeners.clear(); |
3212 | |
3213 | for ( LogRecord r : bootstrapLogRecords ) |
3214 | { |
3215 | this.log( classLoader, r.getLevel(), r.getMessage(), r.getThrown() ); |
3216 | } |
3217 | } |
3218 | catch ( final InstantiationException e ) |
3219 | { |
3220 | this.listeners.clear(); |
3221 | this.modules.clear(); |
3222 | this.invokers.clear(); |
3223 | this.locators.clear(); |
3224 | this.scopes.clear(); |
3225 | this.initialized = false; |
3226 | |
3227 | throw new ObjectManagementException( getMessage( e ), e ); |
3228 | } |
3229 | } |
3230 | } |
3231 | catch ( final ModelObjectException e ) |
3232 | { |
3233 | throw new ObjectManagementException( getMessage( e ), e ); |
3234 | } |
3235 | } |
3236 | |
3237 | /** |
3238 | * Creates a proxy object for a given object. |
3239 | * |
3240 | * @param instance The instance of {@code object}. |
3241 | * @param object The object to create a proxy object for. |
3242 | * @param classLoader The class loader to create the proxy object with. |
3243 | * |
3244 | * @return A new proxy object for {@code object}. |
3245 | * |
3246 | * @throws ObjectManagementException if creating a proxy object fails. |
3247 | */ |
3248 | private Object createProxy( final Instance instance, final Object object, final ClassLoader classLoader ) |
3249 | { |
3250 | try |
3251 | { |
3252 | Constructor<?> proxyClassConstructor = null; |
3253 | |
3254 | synchronized ( proxyClassConstructors ) |
3255 | { |
3256 | Map<String, Reference<Constructor<?>>> map = proxyClassConstructors.get( classLoader ); |
3257 | |
3258 | if ( map == null ) |
3259 | { |
3260 | map = new HashMap<String, Reference<Constructor<?>>>(); |
3261 | proxyClassConstructors.put( classLoader, map ); |
3262 | } |
3263 | |
3264 | Reference<Constructor<?>> reference = map.get( instance.getIdentifier() ); |
3265 | |
3266 | if ( reference != null ) |
3267 | { |
3268 | proxyClassConstructor = reference.get(); |
3269 | } |
3270 | |
3271 | if ( proxyClassConstructor == null |
3272 | && ( reference != null || !map.containsKey( instance.getIdentifier() ) ) ) |
3273 | { |
3274 | final Class<?> proxyClass = instance.getJavaProxyClass( classLoader ); |
3275 | |
3276 | if ( proxyClass != null ) |
3277 | { |
3278 | proxyClassConstructor = proxyClass.getConstructor( INVOCATION_HANDLER_ARGUMENTS ); |
3279 | } |
3280 | |
3281 | map.put( instance.getIdentifier(), new WeakReference<Constructor<?>>( proxyClassConstructor ) ); |
3282 | } |
3283 | } |
3284 | |
3285 | Object proxyObject = object; |
3286 | |
3287 | if ( proxyClassConstructor != null ) |
3288 | { |
3289 | proxyObject = proxyClassConstructor.newInstance( new Object[] |
3290 | { |
3291 | new InvocationHandler() |
3292 | { |
3293 | |
3294 | private final Invoker invoker = getInvoker( classLoader ); |
3295 | |
3296 | public Object invoke( final Object proxy, final Method method, final Object[] args ) |
3297 | throws Throwable |
3298 | { |
3299 | if ( args != null ) |
3300 | { |
3301 | Object[] clonedArgs = args; |
3302 | |
3303 | for ( int i = 0, s0 = clonedArgs.length; i < s0; i++ ) |
3304 | { |
3305 | if ( clonedArgs[i] == proxy ) |
3306 | { |
3307 | if ( clonedArgs == args ) |
3308 | { |
3309 | clonedArgs = clonedArgs.clone(); |
3310 | } |
3311 | |
3312 | clonedArgs[i] = object; |
3313 | } |
3314 | } |
3315 | |
3316 | return this.invoker.invoke( getInvocation( |
3317 | classLoader, object, instance, method, clonedArgs ) ); |
3318 | |
3319 | } |
3320 | |
3321 | return this.invoker.invoke( getInvocation( |
3322 | classLoader, object, instance, method, null ) ); |
3323 | |
3324 | } |
3325 | |
3326 | } |
3327 | } ); |
3328 | |
3329 | } |
3330 | |
3331 | return proxyObject; |
3332 | } |
3333 | catch ( final ModelObjectException e ) |
3334 | { |
3335 | throw new ObjectManagementException( getMessage( e ), e ); |
3336 | } |
3337 | catch ( final ClassNotFoundException e ) |
3338 | { |
3339 | throw new ObjectManagementException( getMessage( e ), e ); |
3340 | } |
3341 | catch ( final NoSuchMethodException e ) |
3342 | { |
3343 | throw new ObjectManagementException( getMessage( e ), e ); |
3344 | } |
3345 | catch ( final IllegalAccessException e ) |
3346 | { |
3347 | throw new ObjectManagementException( getMessage( e ), e ); |
3348 | } |
3349 | catch ( final InstantiationException e ) |
3350 | { |
3351 | throw new ObjectManagementException( getMessage( e ), e ); |
3352 | } |
3353 | catch ( final InvocationTargetException e ) |
3354 | { |
3355 | throw new ObjectManagementException( getMessage( e ), e ); |
3356 | } |
3357 | } |
3358 | |
3359 | private void logModulesReport( final Modules mods, final ClassLoader classLoader ) |
3360 | { |
3361 | final StringBuilder modulesInfo = new StringBuilder( 8192 ); |
3362 | |
3363 | this.log( classLoader, Level.FINEST, getModulesReportMessage( Locale.getDefault() ), null ); |
3364 | |
3365 | modulesInfo.append( "\tClassLoader:" ).append( classLoader ); |
3366 | |
3367 | if ( mods.getDocumentation() != null ) |
3368 | { |
3369 | modulesInfo.append( "|Documentation:" ).append( mods.getDocumentation().getText( |
3370 | Locale.getDefault().getLanguage() ).getValue() ); |
3371 | |
3372 | } |
3373 | |
3374 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3375 | |
3376 | for ( Module m : mods.getModule() ) |
3377 | { |
3378 | modulesInfo.setLength( 0 ); |
3379 | modulesInfo.append( "\tM:" ).append( m.getName() ); |
3380 | |
3381 | if ( m.getVersion() != null ) |
3382 | { |
3383 | modulesInfo.append( "|Version:" ).append( m.getVersion() ); |
3384 | } |
3385 | if ( m.getVendor() != null ) |
3386 | { |
3387 | modulesInfo.append( "|Vendor:" ).append( m.getVendor() ); |
3388 | } |
3389 | |
3390 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3391 | modulesInfo.setLength( 0 ); |
3392 | |
3393 | if ( m.getSpecifications() != null ) |
3394 | { |
3395 | for ( Specification s : m.getSpecifications().getSpecification() ) |
3396 | { |
3397 | modulesInfo.append( "\t\t" ); |
3398 | this.appendSpecificationInfo( s, modulesInfo ); |
3399 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3400 | modulesInfo.setLength( 0 ); |
3401 | |
3402 | final Implementations available = mods.getImplementations( s.getIdentifier() ); |
3403 | |
3404 | if ( available != null ) |
3405 | { |
3406 | for ( Implementation i : available.getImplementation() ) |
3407 | { |
3408 | modulesInfo.append( "\t\t\t" ); |
3409 | this.appendImplementationInfo( i, modulesInfo ).append( "|Module:" ). |
3410 | append( mods.getModuleOfImplementation( i.getIdentifier() ).getName() ); |
3411 | |
3412 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3413 | modulesInfo.setLength( 0 ); |
3414 | } |
3415 | } |
3416 | } |
3417 | } |
3418 | |
3419 | if ( m.getImplementations() != null ) |
3420 | { |
3421 | for ( Implementation i : m.getImplementations().getImplementation() ) |
3422 | { |
3423 | modulesInfo.append( "\t\t" ); |
3424 | this.appendImplementationInfo( i, modulesInfo ); |
3425 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3426 | modulesInfo.setLength( 0 ); |
3427 | |
3428 | if ( i.getImplementations() != null ) |
3429 | { |
3430 | modulesInfo.append( "\t\t\t" ); |
3431 | for ( ImplementationReference r : i.getImplementations().getReference() ) |
3432 | { |
3433 | this.appendImplementationInfo( |
3434 | mods.getImplementation( r.getIdentifier() ), modulesInfo ).append( "|Module:" ). |
3435 | append( mods.getModuleOfImplementation( r.getIdentifier() ).getName() ); |
3436 | |
3437 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3438 | modulesInfo.setLength( 0 ); |
3439 | } |
3440 | } |
3441 | if ( i.getSpecifications() != null ) |
3442 | { |
3443 | for ( SpecificationReference s : i.getSpecifications().getReference() ) |
3444 | { |
3445 | modulesInfo.append( "\t\t\tS:" ).append( s.getIdentifier() ); |
3446 | |
3447 | if ( s.getVersion() != null ) |
3448 | { |
3449 | modulesInfo.append( "|Version:" ).append( s.getVersion() ); |
3450 | } |
3451 | |
3452 | modulesInfo.append( "|Module:" ).append( mods.getModuleOfSpecification( |
3453 | s.getIdentifier() ).getName() ); |
3454 | |
3455 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3456 | modulesInfo.setLength( 0 ); |
3457 | } |
3458 | } |
3459 | |
3460 | if ( i.getDependencies() != null ) |
3461 | { |
3462 | for ( Dependency d : i.getDependencies().getDependency() ) |
3463 | { |
3464 | modulesInfo.append( "\t\t\tD:" ).append( d.getName() ).append( "|Identifier:" ). |
3465 | append( d.getIdentifier() ); |
3466 | |
3467 | if ( d.getImplementationName() != null ) |
3468 | { |
3469 | modulesInfo.append( "|Name:" ).append( d.getImplementationName() ); |
3470 | } |
3471 | |
3472 | modulesInfo.append( "|Module:" ).append( mods.getModuleOfSpecification( |
3473 | d.getIdentifier() ).getName() ); |
3474 | |
3475 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3476 | modulesInfo.setLength( 0 ); |
3477 | |
3478 | final Implementations available = mods.getImplementations( d.getIdentifier() ); |
3479 | |
3480 | if ( available != null ) |
3481 | { |
3482 | for ( Implementation di : available.getImplementation() ) |
3483 | { |
3484 | modulesInfo.append( "\t\t\t\t" ); |
3485 | this.appendImplementationInfo( di, modulesInfo ).append( "|Module:" ). |
3486 | append( mods.getModuleOfImplementation( di.getIdentifier() ).getName() ); |
3487 | |
3488 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3489 | modulesInfo.setLength( 0 ); |
3490 | } |
3491 | } |
3492 | } |
3493 | } |
3494 | |
3495 | if ( i.getMessages() != null ) |
3496 | { |
3497 | for ( Message msg : i.getMessages().getMessage() ) |
3498 | { |
3499 | modulesInfo.append( "\t\t\tM:" ).append( msg.getName() ).append( "|Text:" ). |
3500 | append( msg.getTemplate().getText( Locale.getDefault().getLanguage() ).getValue() ); |
3501 | |
3502 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3503 | modulesInfo.setLength( 0 ); |
3504 | } |
3505 | } |
3506 | |
3507 | if ( i.getProperties() != null ) |
3508 | { |
3509 | for ( Property p : i.getProperties().getProperty() ) |
3510 | { |
3511 | modulesInfo.append( "\t\t\tP:" ).append( p.getName() ); |
3512 | modulesInfo.append( "|Type:" ).append( p.getType() ); |
3513 | modulesInfo.append( "|Value:" ).append( p.getValue() ); |
3514 | |
3515 | try |
3516 | { |
3517 | modulesInfo.append( "|JavaValue:" ).append( p.getJavaValue( classLoader ) ); |
3518 | } |
3519 | catch ( final ModelObjectException e ) |
3520 | { |
3521 | modulesInfo.append( "|JavaValue:" ).append( e ); |
3522 | } |
3523 | |
3524 | this.log( classLoader, Level.FINEST, modulesInfo.toString(), null ); |
3525 | modulesInfo.setLength( 0 ); |
3526 | } |
3527 | } |
3528 | } |
3529 | } |
3530 | } |
3531 | } |
3532 | |
3533 | private StringBuilder appendSpecificationInfo( final Specification s, final StringBuilder b ) |
3534 | { |
3535 | b.append( "S:" ).append( s.getIdentifier() ); |
3536 | if ( s.getVersion() != null ) |
3537 | { |
3538 | b.append( "|Version:" ).append( s.getVersion() ); |
3539 | } |
3540 | if ( s.getVendor() != null ) |
3541 | { |
3542 | b.append( "|Vendor:" ).append( s.getVendor() ); |
3543 | } |
3544 | |
3545 | b.append( "|Multiplicity:" ).append( s.getMultiplicity() ).append( "|Scope:" ). |
3546 | append( s.getScope() == null ? "Multiton" : s.getScope() ); |
3547 | |
3548 | if ( s.getClazz() != null ) |
3549 | { |
3550 | b.append( "|Class:" ).append( s.getClazz() ); |
3551 | } |
3552 | |
3553 | return b; |
3554 | } |
3555 | |
3556 | private StringBuilder appendImplementationInfo( final Implementation i, final StringBuilder b ) |
3557 | { |
3558 | b.append( "I:" ).append( i.getIdentifier() ).append( "|Name:" ).append( i.getName() ).append( "|Abstract:" ). |
3559 | append( i.isAbstract() ).append( "|Final:" ).append( i.isFinal() ).append( "|Stateless:" ). |
3560 | append( i.isStateless() ); |
3561 | |
3562 | if ( i.getVersion() != null ) |
3563 | { |
3564 | b.append( "|Version:" ).append( i.getVersion() ); |
3565 | } |
3566 | if ( i.getVendor() != null ) |
3567 | { |
3568 | b.append( "|Vendor:" ).append( i.getVendor() ); |
3569 | } |
3570 | if ( i.getClazz() != null ) |
3571 | { |
3572 | b.append( "|Class:" ).append( i.getClazz() ); |
3573 | } |
3574 | if ( i.getLocation() != null ) |
3575 | { |
3576 | b.append( "|Location:" ).append( i.getLocation() ); |
3577 | } |
3578 | |
3579 | return b; |
3580 | } |
3581 | |
3582 | private String getClassLoaderInfo( final ClassLoader current, final ClassLoader parent ) |
3583 | { |
3584 | final StringBuilder b = new StringBuilder(); |
3585 | appendClassLoaderInfo( b, current ); |
3586 | |
3587 | if ( parent != null ) |
3588 | { |
3589 | b.append( " => " ); |
3590 | appendClassLoaderInfo( b, parent ); |
3591 | } |
3592 | |
3593 | return b.toString(); |
3594 | } |
3595 | |
3596 | private String getObjectInfo( final Object object ) |
3597 | { |
3598 | final StringBuilder b = new StringBuilder(); |
3599 | appendObjectInfo( b, object ); |
3600 | b.append( " @ " ); |
3601 | appendClassLoaderInfo( b, this.getDefaultClassLoader( object.getClass() ) ); |
3602 | return b.toString(); |
3603 | } |
3604 | |
3605 | private static StringBuilder appendClassLoaderInfo( final StringBuilder b, final ClassLoader classLoader ) |
3606 | { |
3607 | return b.append( "(" ).append( Integer.toHexString( System.identityHashCode( classLoader ) ) ).append( ")" ). |
3608 | append( classLoader ); |
3609 | |
3610 | } |
3611 | |
3612 | private static StringBuilder appendObjectInfo( final StringBuilder b, final Object object ) |
3613 | { |
3614 | return b.append( "(" ).append( Integer.toHexString( System.identityHashCode( object ) ) ).append( ")" ). |
3615 | append( object ); |
3616 | |
3617 | } |
3618 | |
3619 | private static String getMessage( final Throwable t ) |
3620 | { |
3621 | return t != null |
3622 | ? t.getMessage() != null && t.getMessage().trim().length() > 0 |
3623 | ? t.getMessage() |
3624 | : getMessage( t.getCause() ) |
3625 | : null; |
3626 | |
3627 | } |
3628 | |
3629 | private static Specification createDefaultSpecification( final Class<?> specification, |
3630 | final Multiplicity multiplicity, final String scope ) |
3631 | { |
3632 | final Specification s = new Specification(); |
3633 | s.setClassDeclaration( true ); |
3634 | s.setClazz( specification.getName() ); |
3635 | s.setIdentifier( specification.getName() ); |
3636 | s.setMultiplicity( multiplicity ); |
3637 | s.setScope( scope ); |
3638 | s.setVendor( getDefaultModulesVendor( Locale.getDefault() ) ); |
3639 | s.setVersion( getDefaultModulesVersion( Locale.getDefault() ) ); |
3640 | return s; |
3641 | } |
3642 | |
3643 | private static Implementation createDefaultImplementation( final Class<?> implementation, final String name ) |
3644 | { |
3645 | final Implementation i = new Implementation(); |
3646 | i.setClassDeclaration( true ); |
3647 | i.setClazz( implementation.getName() ); |
3648 | i.setIdentifier( implementation.getName() ); |
3649 | i.setName( name ); |
3650 | i.setVendor( getDefaultModulesVendor( Locale.getDefault() ) ); |
3651 | i.setVersion( getDefaultModulesVersion( Locale.getDefault() ) ); |
3652 | return i; |
3653 | } |
3654 | |
3655 | // SECTION-END |
3656 | // SECTION-START[Dependencies] |
3657 | // SECTION-END |
3658 | // SECTION-START[Properties] |
3659 | // SECTION-END |
3660 | // SECTION-START[Messages] |
3661 | // <editor-fold defaultstate="collapsed" desc=" Generated Messages "> |
3662 | /** |
3663 | * Gets the text of the {@code <Creating Modules Info>} message. |
3664 | * <p><dl> |
3665 | * <dt><b>Languages:</b></dt> |
3666 | * <dd>English (default)</dd> |
3667 | * <dd>Deutsch</dd> |
3668 | * <dt><b>Final:</b></dt><dd>No</dd> |
3669 | * </dl></p> |
3670 | * @param locale The locale of the message to return. |
3671 | * @param classLoaderInfo Format argument. |
3672 | * @return The text of the {@code <Creating Modules Info>} message for {@code locale}. |
3673 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
3674 | */ |
3675 | @SuppressWarnings("unused") |
3676 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
3677 | private static String getCreatingModulesInfo( final java.util.Locale locale, final java.lang.String classLoaderInfo ) |
3678 | { |
3679 | java.io.BufferedReader reader = null; |
3680 | boolean suppressExceptionOnClose = true; |
3681 | |
3682 | try |
3683 | { |
3684 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Creating Modules Info" ), classLoaderInfo, (Object) null ); |
3685 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
3686 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
3687 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
3688 | |
3689 | String line; |
3690 | while ( ( line = reader.readLine() ) != null ) |
3691 | { |
3692 | builder.append( lineSeparator ).append( line ); |
3693 | } |
3694 | |
3695 | suppressExceptionOnClose = false; |
3696 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
3697 | } |
3698 | catch( final java.lang.ClassCastException e ) |
3699 | { |
3700 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3701 | } |
3702 | catch( final java.lang.IllegalArgumentException e ) |
3703 | { |
3704 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3705 | } |
3706 | catch( final java.util.MissingResourceException e ) |
3707 | { |
3708 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3709 | } |
3710 | catch( final java.io.IOException e ) |
3711 | { |
3712 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3713 | } |
3714 | finally |
3715 | { |
3716 | try |
3717 | { |
3718 | if( reader != null ) |
3719 | { |
3720 | reader.close(); |
3721 | } |
3722 | } |
3723 | catch( final java.io.IOException e ) |
3724 | { |
3725 | if( !suppressExceptionOnClose ) |
3726 | { |
3727 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3728 | } |
3729 | } |
3730 | } |
3731 | } |
3732 | /** |
3733 | * Gets the text of the {@code <Default Implementation Name>} message. |
3734 | * <p><dl> |
3735 | * <dt><b>Languages:</b></dt> |
3736 | * <dd>English (default)</dd> |
3737 | * <dd>Deutsch</dd> |
3738 | * <dt><b>Final:</b></dt><dd>No</dd> |
3739 | * </dl></p> |
3740 | * @param locale The locale of the message to return. |
3741 | * @return The text of the {@code <Default Implementation Name>} message for {@code locale}. |
3742 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
3743 | */ |
3744 | @SuppressWarnings("unused") |
3745 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
3746 | private static String getDefaultImplementationName( final java.util.Locale locale ) |
3747 | { |
3748 | java.io.BufferedReader reader = null; |
3749 | boolean suppressExceptionOnClose = true; |
3750 | |
3751 | try |
3752 | { |
3753 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Implementation Name" ), (Object) null ); |
3754 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
3755 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
3756 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
3757 | |
3758 | String line; |
3759 | while ( ( line = reader.readLine() ) != null ) |
3760 | { |
3761 | builder.append( lineSeparator ).append( line ); |
3762 | } |
3763 | |
3764 | suppressExceptionOnClose = false; |
3765 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
3766 | } |
3767 | catch( final java.lang.ClassCastException e ) |
3768 | { |
3769 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3770 | } |
3771 | catch( final java.lang.IllegalArgumentException e ) |
3772 | { |
3773 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3774 | } |
3775 | catch( final java.util.MissingResourceException e ) |
3776 | { |
3777 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3778 | } |
3779 | catch( final java.io.IOException e ) |
3780 | { |
3781 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3782 | } |
3783 | finally |
3784 | { |
3785 | try |
3786 | { |
3787 | if( reader != null ) |
3788 | { |
3789 | reader.close(); |
3790 | } |
3791 | } |
3792 | catch( final java.io.IOException e ) |
3793 | { |
3794 | if( !suppressExceptionOnClose ) |
3795 | { |
3796 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3797 | } |
3798 | } |
3799 | } |
3800 | } |
3801 | /** |
3802 | * Gets the text of the {@code <Default Invoker Info Message>} message. |
3803 | * <p><dl> |
3804 | * <dt><b>Languages:</b></dt> |
3805 | * <dd>English (default)</dd> |
3806 | * <dd>Deutsch</dd> |
3807 | * <dt><b>Final:</b></dt><dd>No</dd> |
3808 | * </dl></p> |
3809 | * @param locale The locale of the message to return. |
3810 | * @param classLoaderInfo Format argument. |
3811 | * @return The text of the {@code <Default Invoker Info Message>} message for {@code locale}. |
3812 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
3813 | */ |
3814 | @SuppressWarnings("unused") |
3815 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
3816 | private static String getDefaultInvokerInfoMessage( final java.util.Locale locale, final java.lang.String classLoaderInfo ) |
3817 | { |
3818 | java.io.BufferedReader reader = null; |
3819 | boolean suppressExceptionOnClose = true; |
3820 | |
3821 | try |
3822 | { |
3823 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Invoker Info Message" ), classLoaderInfo, (Object) null ); |
3824 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
3825 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
3826 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
3827 | |
3828 | String line; |
3829 | while ( ( line = reader.readLine() ) != null ) |
3830 | { |
3831 | builder.append( lineSeparator ).append( line ); |
3832 | } |
3833 | |
3834 | suppressExceptionOnClose = false; |
3835 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
3836 | } |
3837 | catch( final java.lang.ClassCastException e ) |
3838 | { |
3839 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3840 | } |
3841 | catch( final java.lang.IllegalArgumentException e ) |
3842 | { |
3843 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3844 | } |
3845 | catch( final java.util.MissingResourceException e ) |
3846 | { |
3847 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3848 | } |
3849 | catch( final java.io.IOException e ) |
3850 | { |
3851 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3852 | } |
3853 | finally |
3854 | { |
3855 | try |
3856 | { |
3857 | if( reader != null ) |
3858 | { |
3859 | reader.close(); |
3860 | } |
3861 | } |
3862 | catch( final java.io.IOException e ) |
3863 | { |
3864 | if( !suppressExceptionOnClose ) |
3865 | { |
3866 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3867 | } |
3868 | } |
3869 | } |
3870 | } |
3871 | /** |
3872 | * Gets the text of the {@code <Default Listener Info>} message. |
3873 | * <p><dl> |
3874 | * <dt><b>Languages:</b></dt> |
3875 | * <dd>English (default)</dd> |
3876 | * <dd>Deutsch</dd> |
3877 | * <dt><b>Final:</b></dt><dd>No</dd> |
3878 | * </dl></p> |
3879 | * @param locale The locale of the message to return. |
3880 | * @param classLoaderInfo Format argument. |
3881 | * @return The text of the {@code <Default Listener Info>} message for {@code locale}. |
3882 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
3883 | */ |
3884 | @SuppressWarnings("unused") |
3885 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
3886 | private static String getDefaultListenerInfo( final java.util.Locale locale, final java.lang.String classLoaderInfo ) |
3887 | { |
3888 | java.io.BufferedReader reader = null; |
3889 | boolean suppressExceptionOnClose = true; |
3890 | |
3891 | try |
3892 | { |
3893 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Listener Info" ), classLoaderInfo, (Object) null ); |
3894 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
3895 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
3896 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
3897 | |
3898 | String line; |
3899 | while ( ( line = reader.readLine() ) != null ) |
3900 | { |
3901 | builder.append( lineSeparator ).append( line ); |
3902 | } |
3903 | |
3904 | suppressExceptionOnClose = false; |
3905 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
3906 | } |
3907 | catch( final java.lang.ClassCastException e ) |
3908 | { |
3909 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3910 | } |
3911 | catch( final java.lang.IllegalArgumentException e ) |
3912 | { |
3913 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3914 | } |
3915 | catch( final java.util.MissingResourceException e ) |
3916 | { |
3917 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3918 | } |
3919 | catch( final java.io.IOException e ) |
3920 | { |
3921 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3922 | } |
3923 | finally |
3924 | { |
3925 | try |
3926 | { |
3927 | if( reader != null ) |
3928 | { |
3929 | reader.close(); |
3930 | } |
3931 | } |
3932 | catch( final java.io.IOException e ) |
3933 | { |
3934 | if( !suppressExceptionOnClose ) |
3935 | { |
3936 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3937 | } |
3938 | } |
3939 | } |
3940 | } |
3941 | /** |
3942 | * Gets the text of the {@code <Default Locator Info Message>} message. |
3943 | * <p><dl> |
3944 | * <dt><b>Languages:</b></dt> |
3945 | * <dd>English (default)</dd> |
3946 | * <dd>Deutsch</dd> |
3947 | * <dt><b>Final:</b></dt><dd>No</dd> |
3948 | * </dl></p> |
3949 | * @param locale The locale of the message to return. |
3950 | * @param schemeInfo Format argument. |
3951 | * @param classLoaderInfo Format argument. |
3952 | * @return The text of the {@code <Default Locator Info Message>} message for {@code locale}. |
3953 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
3954 | */ |
3955 | @SuppressWarnings("unused") |
3956 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
3957 | private static String getDefaultLocatorInfoMessage( final java.util.Locale locale, final java.lang.String schemeInfo, final java.lang.String classLoaderInfo ) |
3958 | { |
3959 | java.io.BufferedReader reader = null; |
3960 | boolean suppressExceptionOnClose = true; |
3961 | |
3962 | try |
3963 | { |
3964 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Locator Info Message" ), schemeInfo, classLoaderInfo, (Object) null ); |
3965 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
3966 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
3967 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
3968 | |
3969 | String line; |
3970 | while ( ( line = reader.readLine() ) != null ) |
3971 | { |
3972 | builder.append( lineSeparator ).append( line ); |
3973 | } |
3974 | |
3975 | suppressExceptionOnClose = false; |
3976 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
3977 | } |
3978 | catch( final java.lang.ClassCastException e ) |
3979 | { |
3980 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3981 | } |
3982 | catch( final java.lang.IllegalArgumentException e ) |
3983 | { |
3984 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3985 | } |
3986 | catch( final java.util.MissingResourceException e ) |
3987 | { |
3988 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3989 | } |
3990 | catch( final java.io.IOException e ) |
3991 | { |
3992 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
3993 | } |
3994 | finally |
3995 | { |
3996 | try |
3997 | { |
3998 | if( reader != null ) |
3999 | { |
4000 | reader.close(); |
4001 | } |
4002 | } |
4003 | catch( final java.io.IOException e ) |
4004 | { |
4005 | if( !suppressExceptionOnClose ) |
4006 | { |
4007 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4008 | } |
4009 | } |
4010 | } |
4011 | } |
4012 | /** |
4013 | * Gets the text of the {@code <Default Log Level Info Message>} message. |
4014 | * <p><dl> |
4015 | * <dt><b>Languages:</b></dt> |
4016 | * <dd>English (default)</dd> |
4017 | * <dd>Deutsch</dd> |
4018 | * <dt><b>Final:</b></dt><dd>No</dd> |
4019 | * </dl></p> |
4020 | * @param locale The locale of the message to return. |
4021 | * @param logLevel Format argument. |
4022 | * @return The text of the {@code <Default Log Level Info Message>} message for {@code locale}. |
4023 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4024 | */ |
4025 | @SuppressWarnings("unused") |
4026 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4027 | private static String getDefaultLogLevelInfoMessage( final java.util.Locale locale, final java.lang.String logLevel ) |
4028 | { |
4029 | java.io.BufferedReader reader = null; |
4030 | boolean suppressExceptionOnClose = true; |
4031 | |
4032 | try |
4033 | { |
4034 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Log Level Info Message" ), logLevel, (Object) null ); |
4035 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4036 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4037 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4038 | |
4039 | String line; |
4040 | while ( ( line = reader.readLine() ) != null ) |
4041 | { |
4042 | builder.append( lineSeparator ).append( line ); |
4043 | } |
4044 | |
4045 | suppressExceptionOnClose = false; |
4046 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4047 | } |
4048 | catch( final java.lang.ClassCastException e ) |
4049 | { |
4050 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4051 | } |
4052 | catch( final java.lang.IllegalArgumentException e ) |
4053 | { |
4054 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4055 | } |
4056 | catch( final java.util.MissingResourceException e ) |
4057 | { |
4058 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4059 | } |
4060 | catch( final java.io.IOException e ) |
4061 | { |
4062 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4063 | } |
4064 | finally |
4065 | { |
4066 | try |
4067 | { |
4068 | if( reader != null ) |
4069 | { |
4070 | reader.close(); |
4071 | } |
4072 | } |
4073 | catch( final java.io.IOException e ) |
4074 | { |
4075 | if( !suppressExceptionOnClose ) |
4076 | { |
4077 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4078 | } |
4079 | } |
4080 | } |
4081 | } |
4082 | /** |
4083 | * Gets the text of the {@code <Default Model Identifier Info>} message. |
4084 | * <p><dl> |
4085 | * <dt><b>Languages:</b></dt> |
4086 | * <dd>English (default)</dd> |
4087 | * <dd>Deutsch</dd> |
4088 | * <dt><b>Final:</b></dt><dd>No</dd> |
4089 | * </dl></p> |
4090 | * @param locale The locale of the message to return. |
4091 | * @param defaultValue Format argument. |
4092 | * @return The text of the {@code <Default Model Identifier Info>} message for {@code locale}. |
4093 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4094 | */ |
4095 | @SuppressWarnings("unused") |
4096 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4097 | private static String getDefaultModelIdentifierInfo( final java.util.Locale locale, final java.lang.String defaultValue ) |
4098 | { |
4099 | java.io.BufferedReader reader = null; |
4100 | boolean suppressExceptionOnClose = true; |
4101 | |
4102 | try |
4103 | { |
4104 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Model Identifier Info" ), defaultValue, (Object) null ); |
4105 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4106 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4107 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4108 | |
4109 | String line; |
4110 | while ( ( line = reader.readLine() ) != null ) |
4111 | { |
4112 | builder.append( lineSeparator ).append( line ); |
4113 | } |
4114 | |
4115 | suppressExceptionOnClose = false; |
4116 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4117 | } |
4118 | catch( final java.lang.ClassCastException e ) |
4119 | { |
4120 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4121 | } |
4122 | catch( final java.lang.IllegalArgumentException e ) |
4123 | { |
4124 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4125 | } |
4126 | catch( final java.util.MissingResourceException e ) |
4127 | { |
4128 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4129 | } |
4130 | catch( final java.io.IOException e ) |
4131 | { |
4132 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4133 | } |
4134 | finally |
4135 | { |
4136 | try |
4137 | { |
4138 | if( reader != null ) |
4139 | { |
4140 | reader.close(); |
4141 | } |
4142 | } |
4143 | catch( final java.io.IOException e ) |
4144 | { |
4145 | if( !suppressExceptionOnClose ) |
4146 | { |
4147 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4148 | } |
4149 | } |
4150 | } |
4151 | } |
4152 | /** |
4153 | * Gets the text of the {@code <Default Model Object Classpah Resolution Enabled Info>} message. |
4154 | * <p><dl> |
4155 | * <dt><b>Languages:</b></dt> |
4156 | * <dd>English (default)</dd> |
4157 | * <dd>Deutsch</dd> |
4158 | * <dt><b>Final:</b></dt><dd>No</dd> |
4159 | * </dl></p> |
4160 | * @param locale The locale of the message to return. |
4161 | * @param defaultValue Format argument. |
4162 | * @return The text of the {@code <Default Model Object Classpah Resolution Enabled Info>} message for {@code locale}. |
4163 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4164 | */ |
4165 | @SuppressWarnings("unused") |
4166 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4167 | private static String getDefaultModelObjectClasspahResolutionEnabledInfo( final java.util.Locale locale, final java.lang.String defaultValue ) |
4168 | { |
4169 | java.io.BufferedReader reader = null; |
4170 | boolean suppressExceptionOnClose = true; |
4171 | |
4172 | try |
4173 | { |
4174 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Model Object Classpah Resolution Enabled Info" ), defaultValue, (Object) null ); |
4175 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4176 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4177 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4178 | |
4179 | String line; |
4180 | while ( ( line = reader.readLine() ) != null ) |
4181 | { |
4182 | builder.append( lineSeparator ).append( line ); |
4183 | } |
4184 | |
4185 | suppressExceptionOnClose = false; |
4186 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4187 | } |
4188 | catch( final java.lang.ClassCastException e ) |
4189 | { |
4190 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4191 | } |
4192 | catch( final java.lang.IllegalArgumentException e ) |
4193 | { |
4194 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4195 | } |
4196 | catch( final java.util.MissingResourceException e ) |
4197 | { |
4198 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4199 | } |
4200 | catch( final java.io.IOException e ) |
4201 | { |
4202 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4203 | } |
4204 | finally |
4205 | { |
4206 | try |
4207 | { |
4208 | if( reader != null ) |
4209 | { |
4210 | reader.close(); |
4211 | } |
4212 | } |
4213 | catch( final java.io.IOException e ) |
4214 | { |
4215 | if( !suppressExceptionOnClose ) |
4216 | { |
4217 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4218 | } |
4219 | } |
4220 | } |
4221 | } |
4222 | /** |
4223 | * Gets the text of the {@code <Default Model Processing Enabled Info>} message. |
4224 | * <p><dl> |
4225 | * <dt><b>Languages:</b></dt> |
4226 | * <dd>English (default)</dd> |
4227 | * <dd>Deutsch</dd> |
4228 | * <dt><b>Final:</b></dt><dd>No</dd> |
4229 | * </dl></p> |
4230 | * @param locale The locale of the message to return. |
4231 | * @param defaultValue Format argument. |
4232 | * @return The text of the {@code <Default Model Processing Enabled Info>} message for {@code locale}. |
4233 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4234 | */ |
4235 | @SuppressWarnings("unused") |
4236 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4237 | private static String getDefaultModelProcessingEnabledInfo( final java.util.Locale locale, final java.lang.String defaultValue ) |
4238 | { |
4239 | java.io.BufferedReader reader = null; |
4240 | boolean suppressExceptionOnClose = true; |
4241 | |
4242 | try |
4243 | { |
4244 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Model Processing Enabled Info" ), defaultValue, (Object) null ); |
4245 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4246 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4247 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4248 | |
4249 | String line; |
4250 | while ( ( line = reader.readLine() ) != null ) |
4251 | { |
4252 | builder.append( lineSeparator ).append( line ); |
4253 | } |
4254 | |
4255 | suppressExceptionOnClose = false; |
4256 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4257 | } |
4258 | catch( final java.lang.ClassCastException e ) |
4259 | { |
4260 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4261 | } |
4262 | catch( final java.lang.IllegalArgumentException e ) |
4263 | { |
4264 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4265 | } |
4266 | catch( final java.util.MissingResourceException e ) |
4267 | { |
4268 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4269 | } |
4270 | catch( final java.io.IOException e ) |
4271 | { |
4272 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4273 | } |
4274 | finally |
4275 | { |
4276 | try |
4277 | { |
4278 | if( reader != null ) |
4279 | { |
4280 | reader.close(); |
4281 | } |
4282 | } |
4283 | catch( final java.io.IOException e ) |
4284 | { |
4285 | if( !suppressExceptionOnClose ) |
4286 | { |
4287 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4288 | } |
4289 | } |
4290 | } |
4291 | } |
4292 | /** |
4293 | * Gets the text of the {@code <Default Module Name>} message. |
4294 | * <p><dl> |
4295 | * <dt><b>Languages:</b></dt> |
4296 | * <dd>English (default)</dd> |
4297 | * <dd>Deutsch</dd> |
4298 | * <dt><b>Final:</b></dt><dd>No</dd> |
4299 | * </dl></p> |
4300 | * @param locale The locale of the message to return. |
4301 | * @return The text of the {@code <Default Module Name>} message for {@code locale}. |
4302 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4303 | */ |
4304 | @SuppressWarnings("unused") |
4305 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4306 | private static String getDefaultModuleName( final java.util.Locale locale ) |
4307 | { |
4308 | java.io.BufferedReader reader = null; |
4309 | boolean suppressExceptionOnClose = true; |
4310 | |
4311 | try |
4312 | { |
4313 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Module Name" ), (Object) null ); |
4314 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4315 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4316 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4317 | |
4318 | String line; |
4319 | while ( ( line = reader.readLine() ) != null ) |
4320 | { |
4321 | builder.append( lineSeparator ).append( line ); |
4322 | } |
4323 | |
4324 | suppressExceptionOnClose = false; |
4325 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4326 | } |
4327 | catch( final java.lang.ClassCastException e ) |
4328 | { |
4329 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4330 | } |
4331 | catch( final java.lang.IllegalArgumentException e ) |
4332 | { |
4333 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4334 | } |
4335 | catch( final java.util.MissingResourceException e ) |
4336 | { |
4337 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4338 | } |
4339 | catch( final java.io.IOException e ) |
4340 | { |
4341 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4342 | } |
4343 | finally |
4344 | { |
4345 | try |
4346 | { |
4347 | if( reader != null ) |
4348 | { |
4349 | reader.close(); |
4350 | } |
4351 | } |
4352 | catch( final java.io.IOException e ) |
4353 | { |
4354 | if( !suppressExceptionOnClose ) |
4355 | { |
4356 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4357 | } |
4358 | } |
4359 | } |
4360 | } |
4361 | /** |
4362 | * Gets the text of the {@code <Default Modules Vendor>} message. |
4363 | * <p><dl> |
4364 | * <dt><b>Languages:</b></dt> |
4365 | * <dd>English (default)</dd> |
4366 | * <dd>Deutsch</dd> |
4367 | * <dt><b>Final:</b></dt><dd>No</dd> |
4368 | * </dl></p> |
4369 | * @param locale The locale of the message to return. |
4370 | * @return The text of the {@code <Default Modules Vendor>} message for {@code locale}. |
4371 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4372 | */ |
4373 | @SuppressWarnings("unused") |
4374 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4375 | private static String getDefaultModulesVendor( final java.util.Locale locale ) |
4376 | { |
4377 | java.io.BufferedReader reader = null; |
4378 | boolean suppressExceptionOnClose = true; |
4379 | |
4380 | try |
4381 | { |
4382 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Modules Vendor" ), (Object) null ); |
4383 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4384 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4385 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4386 | |
4387 | String line; |
4388 | while ( ( line = reader.readLine() ) != null ) |
4389 | { |
4390 | builder.append( lineSeparator ).append( line ); |
4391 | } |
4392 | |
4393 | suppressExceptionOnClose = false; |
4394 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4395 | } |
4396 | catch( final java.lang.ClassCastException e ) |
4397 | { |
4398 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4399 | } |
4400 | catch( final java.lang.IllegalArgumentException e ) |
4401 | { |
4402 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4403 | } |
4404 | catch( final java.util.MissingResourceException e ) |
4405 | { |
4406 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4407 | } |
4408 | catch( final java.io.IOException e ) |
4409 | { |
4410 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4411 | } |
4412 | finally |
4413 | { |
4414 | try |
4415 | { |
4416 | if( reader != null ) |
4417 | { |
4418 | reader.close(); |
4419 | } |
4420 | } |
4421 | catch( final java.io.IOException e ) |
4422 | { |
4423 | if( !suppressExceptionOnClose ) |
4424 | { |
4425 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4426 | } |
4427 | } |
4428 | } |
4429 | } |
4430 | /** |
4431 | * Gets the text of the {@code <Default Modules Version>} message. |
4432 | * <p><dl> |
4433 | * <dt><b>Languages:</b></dt> |
4434 | * <dd>English (default)</dd> |
4435 | * <dd>Deutsch</dd> |
4436 | * <dt><b>Final:</b></dt><dd>No</dd> |
4437 | * </dl></p> |
4438 | * @param locale The locale of the message to return. |
4439 | * @return The text of the {@code <Default Modules Version>} message for {@code locale}. |
4440 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4441 | */ |
4442 | @SuppressWarnings("unused") |
4443 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4444 | private static String getDefaultModulesVersion( final java.util.Locale locale ) |
4445 | { |
4446 | java.io.BufferedReader reader = null; |
4447 | boolean suppressExceptionOnClose = true; |
4448 | |
4449 | try |
4450 | { |
4451 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Modules Version" ), (Object) null ); |
4452 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4453 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4454 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4455 | |
4456 | String line; |
4457 | while ( ( line = reader.readLine() ) != null ) |
4458 | { |
4459 | builder.append( lineSeparator ).append( line ); |
4460 | } |
4461 | |
4462 | suppressExceptionOnClose = false; |
4463 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4464 | } |
4465 | catch( final java.lang.ClassCastException e ) |
4466 | { |
4467 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4468 | } |
4469 | catch( final java.lang.IllegalArgumentException e ) |
4470 | { |
4471 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4472 | } |
4473 | catch( final java.util.MissingResourceException e ) |
4474 | { |
4475 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4476 | } |
4477 | catch( final java.io.IOException e ) |
4478 | { |
4479 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4480 | } |
4481 | finally |
4482 | { |
4483 | try |
4484 | { |
4485 | if( reader != null ) |
4486 | { |
4487 | reader.close(); |
4488 | } |
4489 | } |
4490 | catch( final java.io.IOException e ) |
4491 | { |
4492 | if( !suppressExceptionOnClose ) |
4493 | { |
4494 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4495 | } |
4496 | } |
4497 | } |
4498 | } |
4499 | /** |
4500 | * Gets the text of the {@code <Default Modules Warning>} message. |
4501 | * <p><dl> |
4502 | * <dt><b>Languages:</b></dt> |
4503 | * <dd>English (default)</dd> |
4504 | * <dd>Deutsch</dd> |
4505 | * <dt><b>Final:</b></dt><dd>No</dd> |
4506 | * </dl></p> |
4507 | * @param locale The locale of the message to return. |
4508 | * @param modelInfo Format argument. |
4509 | * @param classLoaderInfo Format argument. |
4510 | * @return The text of the {@code <Default Modules Warning>} message for {@code locale}. |
4511 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4512 | */ |
4513 | @SuppressWarnings("unused") |
4514 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4515 | private static String getDefaultModulesWarning( final java.util.Locale locale, final java.lang.String modelInfo, final java.lang.String classLoaderInfo ) |
4516 | { |
4517 | java.io.BufferedReader reader = null; |
4518 | boolean suppressExceptionOnClose = true; |
4519 | |
4520 | try |
4521 | { |
4522 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Modules Warning" ), modelInfo, classLoaderInfo, (Object) null ); |
4523 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4524 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4525 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4526 | |
4527 | String line; |
4528 | while ( ( line = reader.readLine() ) != null ) |
4529 | { |
4530 | builder.append( lineSeparator ).append( line ); |
4531 | } |
4532 | |
4533 | suppressExceptionOnClose = false; |
4534 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4535 | } |
4536 | catch( final java.lang.ClassCastException e ) |
4537 | { |
4538 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4539 | } |
4540 | catch( final java.lang.IllegalArgumentException e ) |
4541 | { |
4542 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4543 | } |
4544 | catch( final java.util.MissingResourceException e ) |
4545 | { |
4546 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4547 | } |
4548 | catch( final java.io.IOException e ) |
4549 | { |
4550 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4551 | } |
4552 | finally |
4553 | { |
4554 | try |
4555 | { |
4556 | if( reader != null ) |
4557 | { |
4558 | reader.close(); |
4559 | } |
4560 | } |
4561 | catch( final java.io.IOException e ) |
4562 | { |
4563 | if( !suppressExceptionOnClose ) |
4564 | { |
4565 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4566 | } |
4567 | } |
4568 | } |
4569 | } |
4570 | /** |
4571 | * Gets the text of the {@code <Default Scope Info Message>} message. |
4572 | * <p><dl> |
4573 | * <dt><b>Languages:</b></dt> |
4574 | * <dd>English (default)</dd> |
4575 | * <dd>Deutsch</dd> |
4576 | * <dt><b>Final:</b></dt><dd>No</dd> |
4577 | * </dl></p> |
4578 | * @param locale The locale of the message to return. |
4579 | * @param scopeIdentifier Format argument. |
4580 | * @param classLoaderInfo Format argument. |
4581 | * @return The text of the {@code <Default Scope Info Message>} message for {@code locale}. |
4582 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4583 | */ |
4584 | @SuppressWarnings("unused") |
4585 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4586 | private static String getDefaultScopeInfoMessage( final java.util.Locale locale, final java.lang.String scopeIdentifier, final java.lang.String classLoaderInfo ) |
4587 | { |
4588 | java.io.BufferedReader reader = null; |
4589 | boolean suppressExceptionOnClose = true; |
4590 | |
4591 | try |
4592 | { |
4593 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Default Scope Info Message" ), scopeIdentifier, classLoaderInfo, (Object) null ); |
4594 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4595 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4596 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4597 | |
4598 | String line; |
4599 | while ( ( line = reader.readLine() ) != null ) |
4600 | { |
4601 | builder.append( lineSeparator ).append( line ); |
4602 | } |
4603 | |
4604 | suppressExceptionOnClose = false; |
4605 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4606 | } |
4607 | catch( final java.lang.ClassCastException e ) |
4608 | { |
4609 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4610 | } |
4611 | catch( final java.lang.IllegalArgumentException e ) |
4612 | { |
4613 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4614 | } |
4615 | catch( final java.util.MissingResourceException e ) |
4616 | { |
4617 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4618 | } |
4619 | catch( final java.io.IOException e ) |
4620 | { |
4621 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4622 | } |
4623 | finally |
4624 | { |
4625 | try |
4626 | { |
4627 | if( reader != null ) |
4628 | { |
4629 | reader.close(); |
4630 | } |
4631 | } |
4632 | catch( final java.io.IOException e ) |
4633 | { |
4634 | if( !suppressExceptionOnClose ) |
4635 | { |
4636 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4637 | } |
4638 | } |
4639 | } |
4640 | } |
4641 | /** |
4642 | * Gets the text of the {@code <Dependency Cycle Message>} message. |
4643 | * <p><dl> |
4644 | * <dt><b>Languages:</b></dt> |
4645 | * <dd>English (default)</dd> |
4646 | * <dd>Deutsch</dd> |
4647 | * <dt><b>Final:</b></dt><dd>No</dd> |
4648 | * </dl></p> |
4649 | * @param locale The locale of the message to return. |
4650 | * @param implementationIdentifier Format argument. |
4651 | * @return The text of the {@code <Dependency Cycle Message>} message for {@code locale}. |
4652 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4653 | */ |
4654 | @SuppressWarnings("unused") |
4655 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4656 | private static String getDependencyCycleMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier ) |
4657 | { |
4658 | java.io.BufferedReader reader = null; |
4659 | boolean suppressExceptionOnClose = true; |
4660 | |
4661 | try |
4662 | { |
4663 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Dependency Cycle Message" ), implementationIdentifier, (Object) null ); |
4664 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4665 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4666 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4667 | |
4668 | String line; |
4669 | while ( ( line = reader.readLine() ) != null ) |
4670 | { |
4671 | builder.append( lineSeparator ).append( line ); |
4672 | } |
4673 | |
4674 | suppressExceptionOnClose = false; |
4675 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4676 | } |
4677 | catch( final java.lang.ClassCastException e ) |
4678 | { |
4679 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4680 | } |
4681 | catch( final java.lang.IllegalArgumentException e ) |
4682 | { |
4683 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4684 | } |
4685 | catch( final java.util.MissingResourceException e ) |
4686 | { |
4687 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4688 | } |
4689 | catch( final java.io.IOException e ) |
4690 | { |
4691 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4692 | } |
4693 | finally |
4694 | { |
4695 | try |
4696 | { |
4697 | if( reader != null ) |
4698 | { |
4699 | reader.close(); |
4700 | } |
4701 | } |
4702 | catch( final java.io.IOException e ) |
4703 | { |
4704 | if( !suppressExceptionOnClose ) |
4705 | { |
4706 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4707 | } |
4708 | } |
4709 | } |
4710 | } |
4711 | /** |
4712 | * Gets the text of the {@code <Ignored Invocation Message>} message. |
4713 | * <p><dl> |
4714 | * <dt><b>Languages:</b></dt> |
4715 | * <dd>English (default)</dd> |
4716 | * <dd>Deutsch</dd> |
4717 | * <dt><b>Final:</b></dt><dd>No</dd> |
4718 | * </dl></p> |
4719 | * @param locale The locale of the message to return. |
4720 | * @param implementationIdentifier Format argument. |
4721 | * @return The text of the {@code <Ignored Invocation Message>} message for {@code locale}. |
4722 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4723 | */ |
4724 | @SuppressWarnings("unused") |
4725 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4726 | private static String getIgnoredInvocationMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier ) |
4727 | { |
4728 | java.io.BufferedReader reader = null; |
4729 | boolean suppressExceptionOnClose = true; |
4730 | |
4731 | try |
4732 | { |
4733 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Ignored Invocation Message" ), implementationIdentifier, (Object) null ); |
4734 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4735 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4736 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4737 | |
4738 | String line; |
4739 | while ( ( line = reader.readLine() ) != null ) |
4740 | { |
4741 | builder.append( lineSeparator ).append( line ); |
4742 | } |
4743 | |
4744 | suppressExceptionOnClose = false; |
4745 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4746 | } |
4747 | catch( final java.lang.ClassCastException e ) |
4748 | { |
4749 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4750 | } |
4751 | catch( final java.lang.IllegalArgumentException e ) |
4752 | { |
4753 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4754 | } |
4755 | catch( final java.util.MissingResourceException e ) |
4756 | { |
4757 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4758 | } |
4759 | catch( final java.io.IOException e ) |
4760 | { |
4761 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4762 | } |
4763 | finally |
4764 | { |
4765 | try |
4766 | { |
4767 | if( reader != null ) |
4768 | { |
4769 | reader.close(); |
4770 | } |
4771 | } |
4772 | catch( final java.io.IOException e ) |
4773 | { |
4774 | if( !suppressExceptionOnClose ) |
4775 | { |
4776 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4777 | } |
4778 | } |
4779 | } |
4780 | } |
4781 | /** |
4782 | * Gets the text of the {@code <Ignored Invoker Message>} message. |
4783 | * <p><dl> |
4784 | * <dt><b>Languages:</b></dt> |
4785 | * <dd>English (default)</dd> |
4786 | * <dd>Deutsch</dd> |
4787 | * <dt><b>Final:</b></dt><dd>No</dd> |
4788 | * </dl></p> |
4789 | * @param locale The locale of the message to return. |
4790 | * @param implementationIdentifier Format argument. |
4791 | * @return The text of the {@code <Ignored Invoker Message>} message for {@code locale}. |
4792 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4793 | */ |
4794 | @SuppressWarnings("unused") |
4795 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4796 | private static String getIgnoredInvokerMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier ) |
4797 | { |
4798 | java.io.BufferedReader reader = null; |
4799 | boolean suppressExceptionOnClose = true; |
4800 | |
4801 | try |
4802 | { |
4803 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Ignored Invoker Message" ), implementationIdentifier, (Object) null ); |
4804 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4805 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4806 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4807 | |
4808 | String line; |
4809 | while ( ( line = reader.readLine() ) != null ) |
4810 | { |
4811 | builder.append( lineSeparator ).append( line ); |
4812 | } |
4813 | |
4814 | suppressExceptionOnClose = false; |
4815 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4816 | } |
4817 | catch( final java.lang.ClassCastException e ) |
4818 | { |
4819 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4820 | } |
4821 | catch( final java.lang.IllegalArgumentException e ) |
4822 | { |
4823 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4824 | } |
4825 | catch( final java.util.MissingResourceException e ) |
4826 | { |
4827 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4828 | } |
4829 | catch( final java.io.IOException e ) |
4830 | { |
4831 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4832 | } |
4833 | finally |
4834 | { |
4835 | try |
4836 | { |
4837 | if( reader != null ) |
4838 | { |
4839 | reader.close(); |
4840 | } |
4841 | } |
4842 | catch( final java.io.IOException e ) |
4843 | { |
4844 | if( !suppressExceptionOnClose ) |
4845 | { |
4846 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4847 | } |
4848 | } |
4849 | } |
4850 | } |
4851 | /** |
4852 | * Gets the text of the {@code <Illegal Array Specification Message>} message. |
4853 | * <p><dl> |
4854 | * <dt><b>Languages:</b></dt> |
4855 | * <dd>English (default)</dd> |
4856 | * <dd>Deutsch</dd> |
4857 | * <dt><b>Final:</b></dt><dd>No</dd> |
4858 | * </dl></p> |
4859 | * @param locale The locale of the message to return. |
4860 | * @param specificationIdentifier Format argument. |
4861 | * @param specificationMultiplicity Format argument. |
4862 | * @return The text of the {@code <Illegal Array Specification Message>} message for {@code locale}. |
4863 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4864 | */ |
4865 | @SuppressWarnings("unused") |
4866 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4867 | private static String getIllegalArraySpecificationMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier, final java.lang.String specificationMultiplicity ) |
4868 | { |
4869 | java.io.BufferedReader reader = null; |
4870 | boolean suppressExceptionOnClose = true; |
4871 | |
4872 | try |
4873 | { |
4874 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Illegal Array Specification Message" ), specificationIdentifier, specificationMultiplicity, (Object) null ); |
4875 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4876 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4877 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4878 | |
4879 | String line; |
4880 | while ( ( line = reader.readLine() ) != null ) |
4881 | { |
4882 | builder.append( lineSeparator ).append( line ); |
4883 | } |
4884 | |
4885 | suppressExceptionOnClose = false; |
4886 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4887 | } |
4888 | catch( final java.lang.ClassCastException e ) |
4889 | { |
4890 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4891 | } |
4892 | catch( final java.lang.IllegalArgumentException e ) |
4893 | { |
4894 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4895 | } |
4896 | catch( final java.util.MissingResourceException e ) |
4897 | { |
4898 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4899 | } |
4900 | catch( final java.io.IOException e ) |
4901 | { |
4902 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4903 | } |
4904 | finally |
4905 | { |
4906 | try |
4907 | { |
4908 | if( reader != null ) |
4909 | { |
4910 | reader.close(); |
4911 | } |
4912 | } |
4913 | catch( final java.io.IOException e ) |
4914 | { |
4915 | if( !suppressExceptionOnClose ) |
4916 | { |
4917 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4918 | } |
4919 | } |
4920 | } |
4921 | } |
4922 | /** |
4923 | * Gets the text of the {@code <Illegal Object Specification Message>} message. |
4924 | * <p><dl> |
4925 | * <dt><b>Languages:</b></dt> |
4926 | * <dd>English (default)</dd> |
4927 | * <dd>Deutsch</dd> |
4928 | * <dt><b>Final:</b></dt><dd>No</dd> |
4929 | * </dl></p> |
4930 | * @param locale The locale of the message to return. |
4931 | * @param specificationIdentifier Format argument. |
4932 | * @param specificationMultiplicity Format argument. |
4933 | * @return The text of the {@code <Illegal Object Specification Message>} message for {@code locale}. |
4934 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
4935 | */ |
4936 | @SuppressWarnings("unused") |
4937 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
4938 | private static String getIllegalObjectSpecificationMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier, final java.lang.String specificationMultiplicity ) |
4939 | { |
4940 | java.io.BufferedReader reader = null; |
4941 | boolean suppressExceptionOnClose = true; |
4942 | |
4943 | try |
4944 | { |
4945 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Illegal Object Specification Message" ), specificationIdentifier, specificationMultiplicity, (Object) null ); |
4946 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
4947 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
4948 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
4949 | |
4950 | String line; |
4951 | while ( ( line = reader.readLine() ) != null ) |
4952 | { |
4953 | builder.append( lineSeparator ).append( line ); |
4954 | } |
4955 | |
4956 | suppressExceptionOnClose = false; |
4957 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
4958 | } |
4959 | catch( final java.lang.ClassCastException e ) |
4960 | { |
4961 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4962 | } |
4963 | catch( final java.lang.IllegalArgumentException e ) |
4964 | { |
4965 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4966 | } |
4967 | catch( final java.util.MissingResourceException e ) |
4968 | { |
4969 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4970 | } |
4971 | catch( final java.io.IOException e ) |
4972 | { |
4973 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4974 | } |
4975 | finally |
4976 | { |
4977 | try |
4978 | { |
4979 | if( reader != null ) |
4980 | { |
4981 | reader.close(); |
4982 | } |
4983 | } |
4984 | catch( final java.io.IOException e ) |
4985 | { |
4986 | if( !suppressExceptionOnClose ) |
4987 | { |
4988 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
4989 | } |
4990 | } |
4991 | } |
4992 | } |
4993 | /** |
4994 | * Gets the text of the {@code <Implementation Info Message>} message. |
4995 | * <p><dl> |
4996 | * <dt><b>Languages:</b></dt> |
4997 | * <dd>English (default)</dd> |
4998 | * <dd>Deutsch</dd> |
4999 | * <dt><b>Final:</b></dt><dd>No</dd> |
5000 | * </dl></p> |
5001 | * @param locale The locale of the message to return. |
5002 | * @param initializationMillis Format argument. |
5003 | * @return The text of the {@code <Implementation Info Message>} message for {@code locale}. |
5004 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5005 | */ |
5006 | @SuppressWarnings("unused") |
5007 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5008 | private static String getImplementationInfoMessage( final java.util.Locale locale, final java.lang.Number initializationMillis ) |
5009 | { |
5010 | java.io.BufferedReader reader = null; |
5011 | boolean suppressExceptionOnClose = true; |
5012 | |
5013 | try |
5014 | { |
5015 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Implementation Info Message" ), initializationMillis, (Object) null ); |
5016 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5017 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5018 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5019 | |
5020 | String line; |
5021 | while ( ( line = reader.readLine() ) != null ) |
5022 | { |
5023 | builder.append( lineSeparator ).append( line ); |
5024 | } |
5025 | |
5026 | suppressExceptionOnClose = false; |
5027 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5028 | } |
5029 | catch( final java.lang.ClassCastException e ) |
5030 | { |
5031 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5032 | } |
5033 | catch( final java.lang.IllegalArgumentException e ) |
5034 | { |
5035 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5036 | } |
5037 | catch( final java.util.MissingResourceException e ) |
5038 | { |
5039 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5040 | } |
5041 | catch( final java.io.IOException e ) |
5042 | { |
5043 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5044 | } |
5045 | finally |
5046 | { |
5047 | try |
5048 | { |
5049 | if( reader != null ) |
5050 | { |
5051 | reader.close(); |
5052 | } |
5053 | } |
5054 | catch( final java.io.IOException e ) |
5055 | { |
5056 | if( !suppressExceptionOnClose ) |
5057 | { |
5058 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5059 | } |
5060 | } |
5061 | } |
5062 | } |
5063 | /** |
5064 | * Gets the text of the {@code <Invoker Info Message>} message. |
5065 | * <p><dl> |
5066 | * <dt><b>Languages:</b></dt> |
5067 | * <dd>English (default)</dd> |
5068 | * <dd>Deutsch</dd> |
5069 | * <dt><b>Final:</b></dt><dd>No</dd> |
5070 | * </dl></p> |
5071 | * @param locale The locale of the message to return. |
5072 | * @param implementationIdentifier Format argument. |
5073 | * @param classLoaderInfo Format argument. |
5074 | * @return The text of the {@code <Invoker Info Message>} message for {@code locale}. |
5075 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5076 | */ |
5077 | @SuppressWarnings("unused") |
5078 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5079 | private static String getInvokerInfoMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String classLoaderInfo ) |
5080 | { |
5081 | java.io.BufferedReader reader = null; |
5082 | boolean suppressExceptionOnClose = true; |
5083 | |
5084 | try |
5085 | { |
5086 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Invoker Info Message" ), implementationIdentifier, classLoaderInfo, (Object) null ); |
5087 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5088 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5089 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5090 | |
5091 | String line; |
5092 | while ( ( line = reader.readLine() ) != null ) |
5093 | { |
5094 | builder.append( lineSeparator ).append( line ); |
5095 | } |
5096 | |
5097 | suppressExceptionOnClose = false; |
5098 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5099 | } |
5100 | catch( final java.lang.ClassCastException e ) |
5101 | { |
5102 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5103 | } |
5104 | catch( final java.lang.IllegalArgumentException e ) |
5105 | { |
5106 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5107 | } |
5108 | catch( final java.util.MissingResourceException e ) |
5109 | { |
5110 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5111 | } |
5112 | catch( final java.io.IOException e ) |
5113 | { |
5114 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5115 | } |
5116 | finally |
5117 | { |
5118 | try |
5119 | { |
5120 | if( reader != null ) |
5121 | { |
5122 | reader.close(); |
5123 | } |
5124 | } |
5125 | catch( final java.io.IOException e ) |
5126 | { |
5127 | if( !suppressExceptionOnClose ) |
5128 | { |
5129 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5130 | } |
5131 | } |
5132 | } |
5133 | } |
5134 | /** |
5135 | * Gets the text of the {@code <Listener Info Message>} message. |
5136 | * <p><dl> |
5137 | * <dt><b>Languages:</b></dt> |
5138 | * <dd>English (default)</dd> |
5139 | * <dd>Deutsch</dd> |
5140 | * <dt><b>Final:</b></dt><dd>No</dd> |
5141 | * </dl></p> |
5142 | * @param locale The locale of the message to return. |
5143 | * @param implementationIdentifier Format argument. |
5144 | * @param classLoaderInfo Format argument. |
5145 | * @return The text of the {@code <Listener Info Message>} message for {@code locale}. |
5146 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5147 | */ |
5148 | @SuppressWarnings("unused") |
5149 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5150 | private static String getListenerInfoMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String classLoaderInfo ) |
5151 | { |
5152 | java.io.BufferedReader reader = null; |
5153 | boolean suppressExceptionOnClose = true; |
5154 | |
5155 | try |
5156 | { |
5157 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Listener Info Message" ), implementationIdentifier, classLoaderInfo, (Object) null ); |
5158 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5159 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5160 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5161 | |
5162 | String line; |
5163 | while ( ( line = reader.readLine() ) != null ) |
5164 | { |
5165 | builder.append( lineSeparator ).append( line ); |
5166 | } |
5167 | |
5168 | suppressExceptionOnClose = false; |
5169 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5170 | } |
5171 | catch( final java.lang.ClassCastException e ) |
5172 | { |
5173 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5174 | } |
5175 | catch( final java.lang.IllegalArgumentException e ) |
5176 | { |
5177 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5178 | } |
5179 | catch( final java.util.MissingResourceException e ) |
5180 | { |
5181 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5182 | } |
5183 | catch( final java.io.IOException e ) |
5184 | { |
5185 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5186 | } |
5187 | finally |
5188 | { |
5189 | try |
5190 | { |
5191 | if( reader != null ) |
5192 | { |
5193 | reader.close(); |
5194 | } |
5195 | } |
5196 | catch( final java.io.IOException e ) |
5197 | { |
5198 | if( !suppressExceptionOnClose ) |
5199 | { |
5200 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5201 | } |
5202 | } |
5203 | } |
5204 | } |
5205 | /** |
5206 | * Gets the text of the {@code <Locator Info Message>} message. |
5207 | * <p><dl> |
5208 | * <dt><b>Languages:</b></dt> |
5209 | * <dd>English (default)</dd> |
5210 | * <dd>Deutsch</dd> |
5211 | * <dt><b>Final:</b></dt><dd>No</dd> |
5212 | * </dl></p> |
5213 | * @param locale The locale of the message to return. |
5214 | * @param implementationIdentifier Format argument. |
5215 | * @param schemeInfo Format argument. |
5216 | * @param classLoaderInfo Format argument. |
5217 | * @return The text of the {@code <Locator Info Message>} message for {@code locale}. |
5218 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5219 | */ |
5220 | @SuppressWarnings("unused") |
5221 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5222 | private static String getLocatorInfoMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String schemeInfo, final java.lang.String classLoaderInfo ) |
5223 | { |
5224 | java.io.BufferedReader reader = null; |
5225 | boolean suppressExceptionOnClose = true; |
5226 | |
5227 | try |
5228 | { |
5229 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Locator Info Message" ), implementationIdentifier, schemeInfo, classLoaderInfo, (Object) null ); |
5230 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5231 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5232 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5233 | |
5234 | String line; |
5235 | while ( ( line = reader.readLine() ) != null ) |
5236 | { |
5237 | builder.append( lineSeparator ).append( line ); |
5238 | } |
5239 | |
5240 | suppressExceptionOnClose = false; |
5241 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5242 | } |
5243 | catch( final java.lang.ClassCastException e ) |
5244 | { |
5245 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5246 | } |
5247 | catch( final java.lang.IllegalArgumentException e ) |
5248 | { |
5249 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5250 | } |
5251 | catch( final java.util.MissingResourceException e ) |
5252 | { |
5253 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5254 | } |
5255 | catch( final java.io.IOException e ) |
5256 | { |
5257 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5258 | } |
5259 | finally |
5260 | { |
5261 | try |
5262 | { |
5263 | if( reader != null ) |
5264 | { |
5265 | reader.close(); |
5266 | } |
5267 | } |
5268 | catch( final java.io.IOException e ) |
5269 | { |
5270 | if( !suppressExceptionOnClose ) |
5271 | { |
5272 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5273 | } |
5274 | } |
5275 | } |
5276 | } |
5277 | /** |
5278 | * Gets the text of the {@code <Missing Dependency Message>} message. |
5279 | * <p><dl> |
5280 | * <dt><b>Languages:</b></dt> |
5281 | * <dd>English (default)</dd> |
5282 | * <dd>Deutsch</dd> |
5283 | * <dt><b>Final:</b></dt><dd>No</dd> |
5284 | * </dl></p> |
5285 | * @param locale The locale of the message to return. |
5286 | * @param implementationIdentifier Format argument. |
5287 | * @param dependencyName Format argument. |
5288 | * @return The text of the {@code <Missing Dependency Message>} message for {@code locale}. |
5289 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5290 | */ |
5291 | @SuppressWarnings("unused") |
5292 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5293 | private static String getMissingDependencyMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String dependencyName ) |
5294 | { |
5295 | java.io.BufferedReader reader = null; |
5296 | boolean suppressExceptionOnClose = true; |
5297 | |
5298 | try |
5299 | { |
5300 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Dependency Message" ), implementationIdentifier, dependencyName, (Object) null ); |
5301 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5302 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5303 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5304 | |
5305 | String line; |
5306 | while ( ( line = reader.readLine() ) != null ) |
5307 | { |
5308 | builder.append( lineSeparator ).append( line ); |
5309 | } |
5310 | |
5311 | suppressExceptionOnClose = false; |
5312 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5313 | } |
5314 | catch( final java.lang.ClassCastException e ) |
5315 | { |
5316 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5317 | } |
5318 | catch( final java.lang.IllegalArgumentException e ) |
5319 | { |
5320 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5321 | } |
5322 | catch( final java.util.MissingResourceException e ) |
5323 | { |
5324 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5325 | } |
5326 | catch( final java.io.IOException e ) |
5327 | { |
5328 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5329 | } |
5330 | finally |
5331 | { |
5332 | try |
5333 | { |
5334 | if( reader != null ) |
5335 | { |
5336 | reader.close(); |
5337 | } |
5338 | } |
5339 | catch( final java.io.IOException e ) |
5340 | { |
5341 | if( !suppressExceptionOnClose ) |
5342 | { |
5343 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5344 | } |
5345 | } |
5346 | } |
5347 | } |
5348 | /** |
5349 | * Gets the text of the {@code <Missing Implementation Message>} message. |
5350 | * <p><dl> |
5351 | * <dt><b>Languages:</b></dt> |
5352 | * <dd>English (default)</dd> |
5353 | * <dd>Deutsch</dd> |
5354 | * <dt><b>Final:</b></dt><dd>No</dd> |
5355 | * </dl></p> |
5356 | * @param locale The locale of the message to return. |
5357 | * @param specificationIdentifier Format argument. |
5358 | * @param implementationName Format argument. |
5359 | * @return The text of the {@code <Missing Implementation Message>} message for {@code locale}. |
5360 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5361 | */ |
5362 | @SuppressWarnings("unused") |
5363 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5364 | private static String getMissingImplementationMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier, final java.lang.String implementationName ) |
5365 | { |
5366 | java.io.BufferedReader reader = null; |
5367 | boolean suppressExceptionOnClose = true; |
5368 | |
5369 | try |
5370 | { |
5371 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Implementation Message" ), specificationIdentifier, implementationName, (Object) null ); |
5372 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5373 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5374 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5375 | |
5376 | String line; |
5377 | while ( ( line = reader.readLine() ) != null ) |
5378 | { |
5379 | builder.append( lineSeparator ).append( line ); |
5380 | } |
5381 | |
5382 | suppressExceptionOnClose = false; |
5383 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5384 | } |
5385 | catch( final java.lang.ClassCastException e ) |
5386 | { |
5387 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5388 | } |
5389 | catch( final java.lang.IllegalArgumentException e ) |
5390 | { |
5391 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5392 | } |
5393 | catch( final java.util.MissingResourceException e ) |
5394 | { |
5395 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5396 | } |
5397 | catch( final java.io.IOException e ) |
5398 | { |
5399 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5400 | } |
5401 | finally |
5402 | { |
5403 | try |
5404 | { |
5405 | if( reader != null ) |
5406 | { |
5407 | reader.close(); |
5408 | } |
5409 | } |
5410 | catch( final java.io.IOException e ) |
5411 | { |
5412 | if( !suppressExceptionOnClose ) |
5413 | { |
5414 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5415 | } |
5416 | } |
5417 | } |
5418 | } |
5419 | /** |
5420 | * Gets the text of the {@code <Missing Implementations Message>} message. |
5421 | * <p><dl> |
5422 | * <dt><b>Languages:</b></dt> |
5423 | * <dd>English (default)</dd> |
5424 | * <dd>Deutsch</dd> |
5425 | * <dt><b>Final:</b></dt><dd>No</dd> |
5426 | * </dl></p> |
5427 | * @param locale The locale of the message to return. |
5428 | * @param specificationIdentifier Format argument. |
5429 | * @return The text of the {@code <Missing Implementations Message>} message for {@code locale}. |
5430 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5431 | */ |
5432 | @SuppressWarnings("unused") |
5433 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5434 | private static String getMissingImplementationsMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier ) |
5435 | { |
5436 | java.io.BufferedReader reader = null; |
5437 | boolean suppressExceptionOnClose = true; |
5438 | |
5439 | try |
5440 | { |
5441 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Implementations Message" ), specificationIdentifier, (Object) null ); |
5442 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5443 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5444 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5445 | |
5446 | String line; |
5447 | while ( ( line = reader.readLine() ) != null ) |
5448 | { |
5449 | builder.append( lineSeparator ).append( line ); |
5450 | } |
5451 | |
5452 | suppressExceptionOnClose = false; |
5453 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5454 | } |
5455 | catch( final java.lang.ClassCastException e ) |
5456 | { |
5457 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5458 | } |
5459 | catch( final java.lang.IllegalArgumentException e ) |
5460 | { |
5461 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5462 | } |
5463 | catch( final java.util.MissingResourceException e ) |
5464 | { |
5465 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5466 | } |
5467 | catch( final java.io.IOException e ) |
5468 | { |
5469 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5470 | } |
5471 | finally |
5472 | { |
5473 | try |
5474 | { |
5475 | if( reader != null ) |
5476 | { |
5477 | reader.close(); |
5478 | } |
5479 | } |
5480 | catch( final java.io.IOException e ) |
5481 | { |
5482 | if( !suppressExceptionOnClose ) |
5483 | { |
5484 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5485 | } |
5486 | } |
5487 | } |
5488 | } |
5489 | /** |
5490 | * Gets the text of the {@code <Missing Instance Message>} message. |
5491 | * <p><dl> |
5492 | * <dt><b>Languages:</b></dt> |
5493 | * <dd>English (default)</dd> |
5494 | * <dd>Deutsch</dd> |
5495 | * <dt><b>Final:</b></dt><dd>No</dd> |
5496 | * </dl></p> |
5497 | * @param locale The locale of the message to return. |
5498 | * @param implementationIdentifier Format argument. |
5499 | * @param implementationName Format argument. |
5500 | * @return The text of the {@code <Missing Instance Message>} message for {@code locale}. |
5501 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5502 | */ |
5503 | @SuppressWarnings("unused") |
5504 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5505 | private static String getMissingInstanceMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String implementationName ) |
5506 | { |
5507 | java.io.BufferedReader reader = null; |
5508 | boolean suppressExceptionOnClose = true; |
5509 | |
5510 | try |
5511 | { |
5512 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Instance Message" ), implementationIdentifier, implementationName, (Object) null ); |
5513 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5514 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5515 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5516 | |
5517 | String line; |
5518 | while ( ( line = reader.readLine() ) != null ) |
5519 | { |
5520 | builder.append( lineSeparator ).append( line ); |
5521 | } |
5522 | |
5523 | suppressExceptionOnClose = false; |
5524 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5525 | } |
5526 | catch( final java.lang.ClassCastException e ) |
5527 | { |
5528 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5529 | } |
5530 | catch( final java.lang.IllegalArgumentException e ) |
5531 | { |
5532 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5533 | } |
5534 | catch( final java.util.MissingResourceException e ) |
5535 | { |
5536 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5537 | } |
5538 | catch( final java.io.IOException e ) |
5539 | { |
5540 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5541 | } |
5542 | finally |
5543 | { |
5544 | try |
5545 | { |
5546 | if( reader != null ) |
5547 | { |
5548 | reader.close(); |
5549 | } |
5550 | } |
5551 | catch( final java.io.IOException e ) |
5552 | { |
5553 | if( !suppressExceptionOnClose ) |
5554 | { |
5555 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5556 | } |
5557 | } |
5558 | } |
5559 | } |
5560 | /** |
5561 | * Gets the text of the {@code <Missing Locator Message>} message. |
5562 | * <p><dl> |
5563 | * <dt><b>Languages:</b></dt> |
5564 | * <dd>English (default)</dd> |
5565 | * <dd>Deutsch</dd> |
5566 | * <dt><b>Final:</b></dt><dd>No</dd> |
5567 | * </dl></p> |
5568 | * @param locale The locale of the message to return. |
5569 | * @param locationInfo Format argument. |
5570 | * @return The text of the {@code <Missing Locator Message>} message for {@code locale}. |
5571 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5572 | */ |
5573 | @SuppressWarnings("unused") |
5574 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5575 | private static String getMissingLocatorMessage( final java.util.Locale locale, final java.lang.String locationInfo ) |
5576 | { |
5577 | java.io.BufferedReader reader = null; |
5578 | boolean suppressExceptionOnClose = true; |
5579 | |
5580 | try |
5581 | { |
5582 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Locator Message" ), locationInfo, (Object) null ); |
5583 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5584 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5585 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5586 | |
5587 | String line; |
5588 | while ( ( line = reader.readLine() ) != null ) |
5589 | { |
5590 | builder.append( lineSeparator ).append( line ); |
5591 | } |
5592 | |
5593 | suppressExceptionOnClose = false; |
5594 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5595 | } |
5596 | catch( final java.lang.ClassCastException e ) |
5597 | { |
5598 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5599 | } |
5600 | catch( final java.lang.IllegalArgumentException e ) |
5601 | { |
5602 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5603 | } |
5604 | catch( final java.util.MissingResourceException e ) |
5605 | { |
5606 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5607 | } |
5608 | catch( final java.io.IOException e ) |
5609 | { |
5610 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5611 | } |
5612 | finally |
5613 | { |
5614 | try |
5615 | { |
5616 | if( reader != null ) |
5617 | { |
5618 | reader.close(); |
5619 | } |
5620 | } |
5621 | catch( final java.io.IOException e ) |
5622 | { |
5623 | if( !suppressExceptionOnClose ) |
5624 | { |
5625 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5626 | } |
5627 | } |
5628 | } |
5629 | } |
5630 | /** |
5631 | * Gets the text of the {@code <Missing Message Message>} message. |
5632 | * <p><dl> |
5633 | * <dt><b>Languages:</b></dt> |
5634 | * <dd>English (default)</dd> |
5635 | * <dd>Deutsch</dd> |
5636 | * <dt><b>Final:</b></dt><dd>No</dd> |
5637 | * </dl></p> |
5638 | * @param locale The locale of the message to return. |
5639 | * @param implementationIdentifier Format argument. |
5640 | * @param messageName Format argument. |
5641 | * @return The text of the {@code <Missing Message Message>} message for {@code locale}. |
5642 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5643 | */ |
5644 | @SuppressWarnings("unused") |
5645 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5646 | private static String getMissingMessageMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String messageName ) |
5647 | { |
5648 | java.io.BufferedReader reader = null; |
5649 | boolean suppressExceptionOnClose = true; |
5650 | |
5651 | try |
5652 | { |
5653 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Message Message" ), implementationIdentifier, messageName, (Object) null ); |
5654 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5655 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5656 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5657 | |
5658 | String line; |
5659 | while ( ( line = reader.readLine() ) != null ) |
5660 | { |
5661 | builder.append( lineSeparator ).append( line ); |
5662 | } |
5663 | |
5664 | suppressExceptionOnClose = false; |
5665 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5666 | } |
5667 | catch( final java.lang.ClassCastException e ) |
5668 | { |
5669 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5670 | } |
5671 | catch( final java.lang.IllegalArgumentException e ) |
5672 | { |
5673 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5674 | } |
5675 | catch( final java.util.MissingResourceException e ) |
5676 | { |
5677 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5678 | } |
5679 | catch( final java.io.IOException e ) |
5680 | { |
5681 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5682 | } |
5683 | finally |
5684 | { |
5685 | try |
5686 | { |
5687 | if( reader != null ) |
5688 | { |
5689 | reader.close(); |
5690 | } |
5691 | } |
5692 | catch( final java.io.IOException e ) |
5693 | { |
5694 | if( !suppressExceptionOnClose ) |
5695 | { |
5696 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5697 | } |
5698 | } |
5699 | } |
5700 | } |
5701 | /** |
5702 | * Gets the text of the {@code <Missing Object Instance Message>} message. |
5703 | * <p><dl> |
5704 | * <dt><b>Languages:</b></dt> |
5705 | * <dd>English (default)</dd> |
5706 | * <dd>Deutsch</dd> |
5707 | * <dt><b>Final:</b></dt><dd>No</dd> |
5708 | * </dl></p> |
5709 | * @param locale The locale of the message to return. |
5710 | * @param objectInfo Format argument. |
5711 | * @return The text of the {@code <Missing Object Instance Message>} message for {@code locale}. |
5712 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5713 | */ |
5714 | @SuppressWarnings("unused") |
5715 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5716 | private static String getMissingObjectInstanceMessage( final java.util.Locale locale, final java.lang.String objectInfo ) |
5717 | { |
5718 | java.io.BufferedReader reader = null; |
5719 | boolean suppressExceptionOnClose = true; |
5720 | |
5721 | try |
5722 | { |
5723 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Object Instance Message" ), objectInfo, (Object) null ); |
5724 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5725 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5726 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5727 | |
5728 | String line; |
5729 | while ( ( line = reader.readLine() ) != null ) |
5730 | { |
5731 | builder.append( lineSeparator ).append( line ); |
5732 | } |
5733 | |
5734 | suppressExceptionOnClose = false; |
5735 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5736 | } |
5737 | catch( final java.lang.ClassCastException e ) |
5738 | { |
5739 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5740 | } |
5741 | catch( final java.lang.IllegalArgumentException e ) |
5742 | { |
5743 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5744 | } |
5745 | catch( final java.util.MissingResourceException e ) |
5746 | { |
5747 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5748 | } |
5749 | catch( final java.io.IOException e ) |
5750 | { |
5751 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5752 | } |
5753 | finally |
5754 | { |
5755 | try |
5756 | { |
5757 | if( reader != null ) |
5758 | { |
5759 | reader.close(); |
5760 | } |
5761 | } |
5762 | catch( final java.io.IOException e ) |
5763 | { |
5764 | if( !suppressExceptionOnClose ) |
5765 | { |
5766 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5767 | } |
5768 | } |
5769 | } |
5770 | } |
5771 | /** |
5772 | * Gets the text of the {@code <Missing Object Message>} message. |
5773 | * <p><dl> |
5774 | * <dt><b>Languages:</b></dt> |
5775 | * <dd>English (default)</dd> |
5776 | * <dd>Deutsch</dd> |
5777 | * <dt><b>Final:</b></dt><dd>No</dd> |
5778 | * </dl></p> |
5779 | * @param locale The locale of the message to return. |
5780 | * @param implementationIdentifier Format argument. |
5781 | * @param implementationName Format argument. |
5782 | * @return The text of the {@code <Missing Object Message>} message for {@code locale}. |
5783 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5784 | */ |
5785 | @SuppressWarnings("unused") |
5786 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5787 | private static String getMissingObjectMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String implementationName ) |
5788 | { |
5789 | java.io.BufferedReader reader = null; |
5790 | boolean suppressExceptionOnClose = true; |
5791 | |
5792 | try |
5793 | { |
5794 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Object Message" ), implementationIdentifier, implementationName, (Object) null ); |
5795 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5796 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5797 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5798 | |
5799 | String line; |
5800 | while ( ( line = reader.readLine() ) != null ) |
5801 | { |
5802 | builder.append( lineSeparator ).append( line ); |
5803 | } |
5804 | |
5805 | suppressExceptionOnClose = false; |
5806 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5807 | } |
5808 | catch( final java.lang.ClassCastException e ) |
5809 | { |
5810 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5811 | } |
5812 | catch( final java.lang.IllegalArgumentException e ) |
5813 | { |
5814 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5815 | } |
5816 | catch( final java.util.MissingResourceException e ) |
5817 | { |
5818 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5819 | } |
5820 | catch( final java.io.IOException e ) |
5821 | { |
5822 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5823 | } |
5824 | finally |
5825 | { |
5826 | try |
5827 | { |
5828 | if( reader != null ) |
5829 | { |
5830 | reader.close(); |
5831 | } |
5832 | } |
5833 | catch( final java.io.IOException e ) |
5834 | { |
5835 | if( !suppressExceptionOnClose ) |
5836 | { |
5837 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5838 | } |
5839 | } |
5840 | } |
5841 | } |
5842 | /** |
5843 | * Gets the text of the {@code <Missing Property Message>} message. |
5844 | * <p><dl> |
5845 | * <dt><b>Languages:</b></dt> |
5846 | * <dd>English (default)</dd> |
5847 | * <dd>Deutsch</dd> |
5848 | * <dt><b>Final:</b></dt><dd>No</dd> |
5849 | * </dl></p> |
5850 | * @param locale The locale of the message to return. |
5851 | * @param implementationIdentifier Format argument. |
5852 | * @param propertyName Format argument. |
5853 | * @return The text of the {@code <Missing Property Message>} message for {@code locale}. |
5854 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5855 | */ |
5856 | @SuppressWarnings("unused") |
5857 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5858 | private static String getMissingPropertyMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String propertyName ) |
5859 | { |
5860 | java.io.BufferedReader reader = null; |
5861 | boolean suppressExceptionOnClose = true; |
5862 | |
5863 | try |
5864 | { |
5865 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Property Message" ), implementationIdentifier, propertyName, (Object) null ); |
5866 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5867 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5868 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5869 | |
5870 | String line; |
5871 | while ( ( line = reader.readLine() ) != null ) |
5872 | { |
5873 | builder.append( lineSeparator ).append( line ); |
5874 | } |
5875 | |
5876 | suppressExceptionOnClose = false; |
5877 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5878 | } |
5879 | catch( final java.lang.ClassCastException e ) |
5880 | { |
5881 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5882 | } |
5883 | catch( final java.lang.IllegalArgumentException e ) |
5884 | { |
5885 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5886 | } |
5887 | catch( final java.util.MissingResourceException e ) |
5888 | { |
5889 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5890 | } |
5891 | catch( final java.io.IOException e ) |
5892 | { |
5893 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5894 | } |
5895 | finally |
5896 | { |
5897 | try |
5898 | { |
5899 | if( reader != null ) |
5900 | { |
5901 | reader.close(); |
5902 | } |
5903 | } |
5904 | catch( final java.io.IOException e ) |
5905 | { |
5906 | if( !suppressExceptionOnClose ) |
5907 | { |
5908 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5909 | } |
5910 | } |
5911 | } |
5912 | } |
5913 | /** |
5914 | * Gets the text of the {@code <Missing Scope Message>} message. |
5915 | * <p><dl> |
5916 | * <dt><b>Languages:</b></dt> |
5917 | * <dd>English (default)</dd> |
5918 | * <dd>Deutsch</dd> |
5919 | * <dt><b>Final:</b></dt><dd>No</dd> |
5920 | * </dl></p> |
5921 | * @param locale The locale of the message to return. |
5922 | * @param scopeIdentifier Format argument. |
5923 | * @return The text of the {@code <Missing Scope Message>} message for {@code locale}. |
5924 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5925 | */ |
5926 | @SuppressWarnings("unused") |
5927 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5928 | private static String getMissingScopeMessage( final java.util.Locale locale, final java.lang.String scopeIdentifier ) |
5929 | { |
5930 | java.io.BufferedReader reader = null; |
5931 | boolean suppressExceptionOnClose = true; |
5932 | |
5933 | try |
5934 | { |
5935 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Scope Message" ), scopeIdentifier, (Object) null ); |
5936 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
5937 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
5938 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
5939 | |
5940 | String line; |
5941 | while ( ( line = reader.readLine() ) != null ) |
5942 | { |
5943 | builder.append( lineSeparator ).append( line ); |
5944 | } |
5945 | |
5946 | suppressExceptionOnClose = false; |
5947 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
5948 | } |
5949 | catch( final java.lang.ClassCastException e ) |
5950 | { |
5951 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5952 | } |
5953 | catch( final java.lang.IllegalArgumentException e ) |
5954 | { |
5955 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5956 | } |
5957 | catch( final java.util.MissingResourceException e ) |
5958 | { |
5959 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5960 | } |
5961 | catch( final java.io.IOException e ) |
5962 | { |
5963 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5964 | } |
5965 | finally |
5966 | { |
5967 | try |
5968 | { |
5969 | if( reader != null ) |
5970 | { |
5971 | reader.close(); |
5972 | } |
5973 | } |
5974 | catch( final java.io.IOException e ) |
5975 | { |
5976 | if( !suppressExceptionOnClose ) |
5977 | { |
5978 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
5979 | } |
5980 | } |
5981 | } |
5982 | } |
5983 | /** |
5984 | * Gets the text of the {@code <Missing Specification Class Message>} message. |
5985 | * <p><dl> |
5986 | * <dt><b>Languages:</b></dt> |
5987 | * <dd>English (default)</dd> |
5988 | * <dd>Deutsch</dd> |
5989 | * <dt><b>Final:</b></dt><dd>No</dd> |
5990 | * </dl></p> |
5991 | * @param locale The locale of the message to return. |
5992 | * @param specificationIdentifier Format argument. |
5993 | * @return The text of the {@code <Missing Specification Class Message>} message for {@code locale}. |
5994 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
5995 | */ |
5996 | @SuppressWarnings("unused") |
5997 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
5998 | private static String getMissingSpecificationClassMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier ) |
5999 | { |
6000 | java.io.BufferedReader reader = null; |
6001 | boolean suppressExceptionOnClose = true; |
6002 | |
6003 | try |
6004 | { |
6005 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Specification Class Message" ), specificationIdentifier, (Object) null ); |
6006 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6007 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6008 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6009 | |
6010 | String line; |
6011 | while ( ( line = reader.readLine() ) != null ) |
6012 | { |
6013 | builder.append( lineSeparator ).append( line ); |
6014 | } |
6015 | |
6016 | suppressExceptionOnClose = false; |
6017 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6018 | } |
6019 | catch( final java.lang.ClassCastException e ) |
6020 | { |
6021 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6022 | } |
6023 | catch( final java.lang.IllegalArgumentException e ) |
6024 | { |
6025 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6026 | } |
6027 | catch( final java.util.MissingResourceException e ) |
6028 | { |
6029 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6030 | } |
6031 | catch( final java.io.IOException e ) |
6032 | { |
6033 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6034 | } |
6035 | finally |
6036 | { |
6037 | try |
6038 | { |
6039 | if( reader != null ) |
6040 | { |
6041 | reader.close(); |
6042 | } |
6043 | } |
6044 | catch( final java.io.IOException e ) |
6045 | { |
6046 | if( !suppressExceptionOnClose ) |
6047 | { |
6048 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6049 | } |
6050 | } |
6051 | } |
6052 | } |
6053 | /** |
6054 | * Gets the text of the {@code <Missing Specification Message>} message. |
6055 | * <p><dl> |
6056 | * <dt><b>Languages:</b></dt> |
6057 | * <dd>English (default)</dd> |
6058 | * <dd>Deutsch</dd> |
6059 | * <dt><b>Final:</b></dt><dd>No</dd> |
6060 | * </dl></p> |
6061 | * @param locale The locale of the message to return. |
6062 | * @param specificationIdentifier Format argument. |
6063 | * @return The text of the {@code <Missing Specification Message>} message for {@code locale}. |
6064 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
6065 | */ |
6066 | @SuppressWarnings("unused") |
6067 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
6068 | private static String getMissingSpecificationMessage( final java.util.Locale locale, final java.lang.String specificationIdentifier ) |
6069 | { |
6070 | java.io.BufferedReader reader = null; |
6071 | boolean suppressExceptionOnClose = true; |
6072 | |
6073 | try |
6074 | { |
6075 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Missing Specification Message" ), specificationIdentifier, (Object) null ); |
6076 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6077 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6078 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6079 | |
6080 | String line; |
6081 | while ( ( line = reader.readLine() ) != null ) |
6082 | { |
6083 | builder.append( lineSeparator ).append( line ); |
6084 | } |
6085 | |
6086 | suppressExceptionOnClose = false; |
6087 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6088 | } |
6089 | catch( final java.lang.ClassCastException e ) |
6090 | { |
6091 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6092 | } |
6093 | catch( final java.lang.IllegalArgumentException e ) |
6094 | { |
6095 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6096 | } |
6097 | catch( final java.util.MissingResourceException e ) |
6098 | { |
6099 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6100 | } |
6101 | catch( final java.io.IOException e ) |
6102 | { |
6103 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6104 | } |
6105 | finally |
6106 | { |
6107 | try |
6108 | { |
6109 | if( reader != null ) |
6110 | { |
6111 | reader.close(); |
6112 | } |
6113 | } |
6114 | catch( final java.io.IOException e ) |
6115 | { |
6116 | if( !suppressExceptionOnClose ) |
6117 | { |
6118 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6119 | } |
6120 | } |
6121 | } |
6122 | } |
6123 | /** |
6124 | * Gets the text of the {@code <Modules Report Message>} message. |
6125 | * <p><dl> |
6126 | * <dt><b>Languages:</b></dt> |
6127 | * <dd>English (default)</dd> |
6128 | * <dd>Deutsch</dd> |
6129 | * <dt><b>Final:</b></dt><dd>No</dd> |
6130 | * </dl></p> |
6131 | * @param locale The locale of the message to return. |
6132 | * @return The text of the {@code <Modules Report Message>} message for {@code locale}. |
6133 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
6134 | */ |
6135 | @SuppressWarnings("unused") |
6136 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
6137 | private static String getModulesReportMessage( final java.util.Locale locale ) |
6138 | { |
6139 | java.io.BufferedReader reader = null; |
6140 | boolean suppressExceptionOnClose = true; |
6141 | |
6142 | try |
6143 | { |
6144 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Modules Report Message" ), (Object) null ); |
6145 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6146 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6147 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6148 | |
6149 | String line; |
6150 | while ( ( line = reader.readLine() ) != null ) |
6151 | { |
6152 | builder.append( lineSeparator ).append( line ); |
6153 | } |
6154 | |
6155 | suppressExceptionOnClose = false; |
6156 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6157 | } |
6158 | catch( final java.lang.ClassCastException e ) |
6159 | { |
6160 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6161 | } |
6162 | catch( final java.lang.IllegalArgumentException e ) |
6163 | { |
6164 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6165 | } |
6166 | catch( final java.util.MissingResourceException e ) |
6167 | { |
6168 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6169 | } |
6170 | catch( final java.io.IOException e ) |
6171 | { |
6172 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6173 | } |
6174 | finally |
6175 | { |
6176 | try |
6177 | { |
6178 | if( reader != null ) |
6179 | { |
6180 | reader.close(); |
6181 | } |
6182 | } |
6183 | catch( final java.io.IOException e ) |
6184 | { |
6185 | if( !suppressExceptionOnClose ) |
6186 | { |
6187 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6188 | } |
6189 | } |
6190 | } |
6191 | } |
6192 | /** |
6193 | * Gets the text of the {@code <Scope Contention Failure>} message. |
6194 | * <p><dl> |
6195 | * <dt><b>Languages:</b></dt> |
6196 | * <dd>English (default)</dd> |
6197 | * <dd>Deutsch</dd> |
6198 | * <dt><b>Final:</b></dt><dd>No</dd> |
6199 | * </dl></p> |
6200 | * @param locale The locale of the message to return. |
6201 | * @param objectIdentifier Format argument. |
6202 | * @return The text of the {@code <Scope Contention Failure>} message for {@code locale}. |
6203 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
6204 | */ |
6205 | @SuppressWarnings("unused") |
6206 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
6207 | private static String getScopeContentionFailure( final java.util.Locale locale, final java.lang.String objectIdentifier ) |
6208 | { |
6209 | java.io.BufferedReader reader = null; |
6210 | boolean suppressExceptionOnClose = true; |
6211 | |
6212 | try |
6213 | { |
6214 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Scope Contention Failure" ), objectIdentifier, (Object) null ); |
6215 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6216 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6217 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6218 | |
6219 | String line; |
6220 | while ( ( line = reader.readLine() ) != null ) |
6221 | { |
6222 | builder.append( lineSeparator ).append( line ); |
6223 | } |
6224 | |
6225 | suppressExceptionOnClose = false; |
6226 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6227 | } |
6228 | catch( final java.lang.ClassCastException e ) |
6229 | { |
6230 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6231 | } |
6232 | catch( final java.lang.IllegalArgumentException e ) |
6233 | { |
6234 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6235 | } |
6236 | catch( final java.util.MissingResourceException e ) |
6237 | { |
6238 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6239 | } |
6240 | catch( final java.io.IOException e ) |
6241 | { |
6242 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6243 | } |
6244 | finally |
6245 | { |
6246 | try |
6247 | { |
6248 | if( reader != null ) |
6249 | { |
6250 | reader.close(); |
6251 | } |
6252 | } |
6253 | catch( final java.io.IOException e ) |
6254 | { |
6255 | if( !suppressExceptionOnClose ) |
6256 | { |
6257 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6258 | } |
6259 | } |
6260 | } |
6261 | } |
6262 | /** |
6263 | * Gets the text of the {@code <Scope Info Message>} message. |
6264 | * <p><dl> |
6265 | * <dt><b>Languages:</b></dt> |
6266 | * <dd>English (default)</dd> |
6267 | * <dd>Deutsch</dd> |
6268 | * <dt><b>Final:</b></dt><dd>No</dd> |
6269 | * </dl></p> |
6270 | * @param locale The locale of the message to return. |
6271 | * @param implementationIdentifier Format argument. |
6272 | * @param scopeIdentifier Format argument. |
6273 | * @param classLoaderInfo Format argument. |
6274 | * @return The text of the {@code <Scope Info Message>} message for {@code locale}. |
6275 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
6276 | */ |
6277 | @SuppressWarnings("unused") |
6278 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
6279 | private static String getScopeInfoMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String scopeIdentifier, final java.lang.String classLoaderInfo ) |
6280 | { |
6281 | java.io.BufferedReader reader = null; |
6282 | boolean suppressExceptionOnClose = true; |
6283 | |
6284 | try |
6285 | { |
6286 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Scope Info Message" ), implementationIdentifier, scopeIdentifier, classLoaderInfo, (Object) null ); |
6287 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6288 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6289 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6290 | |
6291 | String line; |
6292 | while ( ( line = reader.readLine() ) != null ) |
6293 | { |
6294 | builder.append( lineSeparator ).append( line ); |
6295 | } |
6296 | |
6297 | suppressExceptionOnClose = false; |
6298 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6299 | } |
6300 | catch( final java.lang.ClassCastException e ) |
6301 | { |
6302 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6303 | } |
6304 | catch( final java.lang.IllegalArgumentException e ) |
6305 | { |
6306 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6307 | } |
6308 | catch( final java.util.MissingResourceException e ) |
6309 | { |
6310 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6311 | } |
6312 | catch( final java.io.IOException e ) |
6313 | { |
6314 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6315 | } |
6316 | finally |
6317 | { |
6318 | try |
6319 | { |
6320 | if( reader != null ) |
6321 | { |
6322 | reader.close(); |
6323 | } |
6324 | } |
6325 | catch( final java.io.IOException e ) |
6326 | { |
6327 | if( !suppressExceptionOnClose ) |
6328 | { |
6329 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6330 | } |
6331 | } |
6332 | } |
6333 | } |
6334 | /** |
6335 | * Gets the text of the {@code <Unexpected Dependency Objects Message>} message. |
6336 | * <p><dl> |
6337 | * <dt><b>Languages:</b></dt> |
6338 | * <dd>English (default)</dd> |
6339 | * <dd>Deutsch</dd> |
6340 | * <dt><b>Final:</b></dt><dd>No</dd> |
6341 | * </dl></p> |
6342 | * @param locale The locale of the message to return. |
6343 | * @param implementationIdentifier Format argument. |
6344 | * @param dependencyName Format argument. |
6345 | * @param expectedNumber Format argument. |
6346 | * @param computedNumber Format argument. |
6347 | * @return The text of the {@code <Unexpected Dependency Objects Message>} message for {@code locale}. |
6348 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
6349 | */ |
6350 | @SuppressWarnings("unused") |
6351 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) |
6352 | private static String getUnexpectedDependencyObjectsMessage( final java.util.Locale locale, final java.lang.String implementationIdentifier, final java.lang.String dependencyName, final java.lang.Number expectedNumber, final java.lang.Number computedNumber ) |
6353 | { |
6354 | java.io.BufferedReader reader = null; |
6355 | boolean suppressExceptionOnClose = true; |
6356 | |
6357 | try |
6358 | { |
6359 | final String message = java.text.MessageFormat.format( java.util.ResourceBundle.getBundle( "org.jomc.ri.DefaultObjectManager", locale ).getString( "Unexpected Dependency Objects Message" ), implementationIdentifier, dependencyName, expectedNumber, computedNumber, (Object) null ); |
6360 | final java.lang.StringBuilder builder = new java.lang.StringBuilder( message.length() ); |
6361 | reader = new java.io.BufferedReader( new java.io.StringReader( message ) ); |
6362 | final String lineSeparator = System.getProperty( "line.separator", "\n" ); |
6363 | |
6364 | String line; |
6365 | while ( ( line = reader.readLine() ) != null ) |
6366 | { |
6367 | builder.append( lineSeparator ).append( line ); |
6368 | } |
6369 | |
6370 | suppressExceptionOnClose = false; |
6371 | return builder.length() > 0 ? builder.substring( lineSeparator.length() ) : ""; |
6372 | } |
6373 | catch( final java.lang.ClassCastException e ) |
6374 | { |
6375 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6376 | } |
6377 | catch( final java.lang.IllegalArgumentException e ) |
6378 | { |
6379 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6380 | } |
6381 | catch( final java.util.MissingResourceException e ) |
6382 | { |
6383 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6384 | } |
6385 | catch( final java.io.IOException e ) |
6386 | { |
6387 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6388 | } |
6389 | finally |
6390 | { |
6391 | try |
6392 | { |
6393 | if( reader != null ) |
6394 | { |
6395 | reader.close(); |
6396 | } |
6397 | } |
6398 | catch( final java.io.IOException e ) |
6399 | { |
6400 | if( !suppressExceptionOnClose ) |
6401 | { |
6402 | throw new org.jomc.ObjectManagementException( e.getMessage(), e ); |
6403 | } |
6404 | } |
6405 | } |
6406 | } |
6407 | // </editor-fold> |
6408 | // SECTION-END |
6409 | } |