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