1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package org.jomc.ri.model;
37
38 import java.util.List;
39 import java.util.Map;
40 import javax.xml.bind.annotation.XmlTransient;
41 import org.jomc.model.Dependencies;
42 import org.jomc.model.Dependency;
43 import org.jomc.model.Implementation;
44 import org.jomc.model.Implementations;
45 import org.jomc.model.Instance;
46 import org.jomc.model.Message;
47 import org.jomc.model.Messages;
48 import org.jomc.model.ModelObjectException;
49 import org.jomc.model.Module;
50 import org.jomc.model.Modules;
51 import org.jomc.model.Properties;
52 import org.jomc.model.Property;
53 import org.jomc.model.Specification;
54 import org.jomc.model.Specifications;
55 import static org.jomc.ri.model.RuntimeModelObjects.createMap;
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
80
81
82 public class RuntimeModules extends Modules implements RuntimeModelObject
83 {
84
85
86
87 @XmlTransient
88 private transient final Map<String, Module> modulesByNameCache = createMap();
89
90
91 @XmlTransient
92 private transient final Map<String, Specifications> specificationsCache = createMap();
93
94
95 @XmlTransient
96 private transient final Map<String, Implementations> implementationsCache = createMap();
97
98
99 @XmlTransient
100 private transient final Map<String, Module> moduleBySpecificationIdentifierCache = createMap();
101
102
103 @XmlTransient
104 private transient final Map<String, Module> moduleByImplementationIdentifierCache = createMap();
105
106
107 @XmlTransient
108 private transient final Map<String, Specification> specificationByIdentifierCache = createMap();
109
110
111 @XmlTransient
112 private transient final Map<String, Specification> specificationByClassNameCache = createMap();
113
114
115 @XmlTransient
116 private transient final Map<String, Specifications> specificationsByImplemenationIdentifierCache = createMap();
117
118
119 @XmlTransient
120 private transient final Map<String, Implementation> implementationByIdentifierCache = createMap();
121
122
123 @XmlTransient
124 private transient final Map<String, Implementation> implementationByClassNameCache = createMap();
125
126
127 @XmlTransient
128 private transient final Map<String, Implementation> implementationByObjectClassNameCache = createMap();
129
130
131 @XmlTransient
132 private transient final Map<String, Implementation> implementationBySpecificationAndNameCache = createMap();
133
134
135 @XmlTransient
136 private transient final Map<String, Dependencies> dependenciesByImplementationIdentifierCache = createMap();
137
138
139 @XmlTransient
140 private transient final Map<String, Properties> propertiesByImplementationIdentifierCache = createMap();
141
142
143 @XmlTransient
144 private transient final Map<String, Properties> specifiedPropertiesByImplementationIdentifierCache = createMap();
145
146
147 @XmlTransient
148 private transient final Map<String, Messages> messagesByImplementationIdentifierCache = createMap();
149
150
151 @XmlTransient
152 private transient final Map<String, Implementations> implementationsBySpecificationIdentifierCache = createMap();
153
154
155 @XmlTransient
156 private transient final Map<String, List<Object>> anyObjectsByImplemenationIdentifierCache = createMap();
157
158
159
160
161
162
163
164
165 public RuntimeModules( final Modules modules )
166 {
167 super( modules );
168
169 if ( this.getAuthors() != null )
170 {
171 this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
172 }
173 if ( this.getDocumentation() != null )
174 {
175 this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
176 }
177
178 this.copyModules();
179 }
180
181
182
183
184
185
186
187
188
189
190 public RuntimeModules( final Modules modules, final Map<Object, Instance> objects )
191 {
192 super( modules, objects );
193
194 if ( this.getAuthors() != null )
195 {
196 this.setAuthors( RuntimeModelObjects.getInstance().copyOf( this.getAuthors() ) );
197 }
198 if ( this.getDocumentation() != null )
199 {
200 this.setDocumentation( RuntimeModelObjects.getInstance().copyOf( this.getDocumentation() ) );
201 }
202
203 this.copyModules();
204 }
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224 @Override
225 public Module getModule( final String name )
226 {
227 if ( name == null )
228 {
229 throw new NullPointerException( "name" );
230 }
231
232 synchronized ( this.modulesByNameCache )
233 {
234 Module m = this.modulesByNameCache.get( name );
235
236 if ( m == null && !this.modulesByNameCache.containsKey( name ) )
237 {
238 m = super.getModule( name );
239 this.modulesByNameCache.put( name, m );
240 }
241
242 return m;
243 }
244 }
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 @Override
260 public Specifications getSpecifications()
261 {
262 synchronized ( this.specificationsCache )
263 {
264 Specifications s = this.specificationsCache.get( RuntimeModules.class.getName() );
265
266 if ( s == null && !this.specificationsCache.containsKey( RuntimeModules.class.getName() ) )
267 {
268 s = super.getSpecifications();
269
270 if ( s != null )
271 {
272 s = RuntimeModelObjects.getInstance().copyOf( s );
273 }
274
275 this.specificationsCache.put( RuntimeModules.class.getName(), s );
276 }
277
278 return s;
279 }
280 }
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 @Override
296 public Implementations getImplementations()
297 {
298 synchronized ( this.implementationsCache )
299 {
300 Implementations i = this.implementationsCache.get( RuntimeModules.class.getName() );
301
302 if ( i == null && !this.implementationsCache.containsKey( RuntimeModules.class.getName() ) )
303 {
304 i = super.getImplementations();
305
306 if ( i != null )
307 {
308 i = RuntimeModelObjects.getInstance().copyOf( i );
309 }
310
311 this.implementationsCache.put( RuntimeModules.class.getName(), i );
312 }
313
314 return i;
315 }
316 }
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337 @Override
338 public Module getModuleOfSpecification( final String specification )
339 {
340 if ( specification == null )
341 {
342 throw new NullPointerException( "specification" );
343 }
344
345 synchronized ( this.moduleBySpecificationIdentifierCache )
346 {
347 Module m = this.moduleBySpecificationIdentifierCache.get( specification );
348
349 if ( m == null && !this.moduleBySpecificationIdentifierCache.containsKey( specification ) )
350 {
351 m = super.getModuleOfSpecification( specification );
352 this.moduleBySpecificationIdentifierCache.put( specification, m );
353 }
354
355 return m;
356 }
357 }
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378 @Override
379 public Module getModuleOfImplementation( final String implementation )
380 {
381 if ( implementation == null )
382 {
383 throw new NullPointerException( "implementation" );
384 }
385
386 synchronized ( this.moduleByImplementationIdentifierCache )
387 {
388 Module m = this.moduleByImplementationIdentifierCache.get( implementation );
389
390 if ( m == null && !this.moduleByImplementationIdentifierCache.containsKey( implementation ) )
391 {
392 m = super.getModuleOfImplementation( implementation );
393 this.moduleByImplementationIdentifierCache.put( implementation, m );
394 }
395
396 return m;
397 }
398 }
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419 @Override
420 public Specification getSpecification( final String specification )
421 {
422 if ( specification == null )
423 {
424 throw new NullPointerException( "specification" );
425 }
426
427 synchronized ( this.specificationByIdentifierCache )
428 {
429 Specification s = this.specificationByIdentifierCache.get( specification );
430
431 if ( s == null && !this.specificationByIdentifierCache.containsKey( specification ) )
432 {
433 s = super.getSpecification( specification );
434 this.specificationByIdentifierCache.put( specification, s );
435 }
436
437 return s;
438 }
439 }
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461 @Override
462 public Specification getSpecification( final Class<?> specification ) throws ModelObjectException
463 {
464 if ( specification == null )
465 {
466 throw new NullPointerException( "specification" );
467 }
468
469 synchronized ( this.specificationByClassNameCache )
470 {
471 Specification s = this.specificationByClassNameCache.get( specification.getName() );
472
473 if ( s == null && !this.specificationByClassNameCache.containsKey( specification.getName() ) )
474 {
475 s = super.getSpecification( specification );
476 this.specificationByClassNameCache.put( specification.getName(), s );
477 }
478
479 return s;
480 }
481 }
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504 @Override
505 public Specifications getSpecifications( final String implementation )
506 {
507 if ( implementation == null )
508 {
509 throw new NullPointerException( "implementation" );
510 }
511
512 synchronized ( this.specificationsByImplemenationIdentifierCache )
513 {
514 Specifications s = this.specificationsByImplemenationIdentifierCache.get( implementation );
515
516 if ( s == null && !this.specificationsByImplemenationIdentifierCache.containsKey( implementation ) )
517 {
518 s = super.getSpecifications( implementation );
519
520 if ( s != null )
521 {
522 s = RuntimeModelObjects.getInstance().copyOf( s );
523 }
524
525 this.specificationsByImplemenationIdentifierCache.put( implementation, s );
526 }
527
528 return s;
529 }
530 }
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551 @Override
552 public Implementation getImplementation( final String implementation )
553 {
554 if ( implementation == null )
555 {
556 throw new NullPointerException( "implementation" );
557 }
558
559 synchronized ( this.implementationByIdentifierCache )
560 {
561 Implementation i = this.implementationByIdentifierCache.get( implementation );
562
563 if ( i == null && !this.implementationByIdentifierCache.containsKey( implementation ) )
564 {
565 i = super.getImplementation( implementation );
566 this.implementationByIdentifierCache.put( implementation, i );
567 }
568
569 return i;
570 }
571 }
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593 @Override
594 public Implementation getImplementation( final Class<?> implementation ) throws ModelObjectException
595 {
596 if ( implementation == null )
597 {
598 throw new NullPointerException( "implementation" );
599 }
600
601 synchronized ( this.implementationByClassNameCache )
602 {
603 Implementation i = this.implementationByClassNameCache.get( implementation.getName() );
604
605 if ( i == null && !this.implementationByClassNameCache.containsKey( implementation.getName() ) )
606 {
607 i = super.getImplementation( implementation );
608 this.implementationByClassNameCache.put( implementation.getName(), i );
609 }
610
611 return i;
612 }
613 }
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634 @Override
635 public Implementation getImplementation( final Object object ) throws ModelObjectException
636 {
637 if ( object == null )
638 {
639 throw new NullPointerException( "object" );
640 }
641
642 synchronized ( this.implementationByObjectClassNameCache )
643 {
644 Implementation i = this.implementationByObjectClassNameCache.get( object.getClass().getName() );
645
646 if ( i == null && !this.implementationByObjectClassNameCache.containsKey( object.getClass().getName() ) )
647 {
648 i = super.getImplementation( object );
649 this.implementationByObjectClassNameCache.put( object.getClass().getName(), i );
650 }
651
652 return i;
653 }
654 }
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676 @Override
677 public Implementation getImplementation( final String specification, final String name )
678 {
679 if ( specification == null )
680 {
681 throw new NullPointerException( "specification" );
682 }
683 if ( name == null )
684 {
685 throw new NullPointerException( "name" );
686 }
687
688 synchronized ( this.implementationBySpecificationAndNameCache )
689 {
690 final String key = specification + "|" + name;
691 Implementation i = this.implementationBySpecificationAndNameCache.get( key );
692
693 if ( i == null && !this.implementationBySpecificationAndNameCache.containsKey( key ) )
694 {
695 i = super.getImplementation( specification, name );
696 this.implementationBySpecificationAndNameCache.put( key, i );
697 }
698
699 return i;
700 }
701 }
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724 @Override
725 public Dependencies getDependencies( final String implementation )
726 {
727 if ( implementation == null )
728 {
729 throw new NullPointerException( "implementation" );
730 }
731
732 synchronized ( this.dependenciesByImplementationIdentifierCache )
733 {
734 Dependencies d = this.dependenciesByImplementationIdentifierCache.get( implementation );
735
736 if ( d == null && !this.dependenciesByImplementationIdentifierCache.containsKey( implementation ) )
737 {
738 d = super.getDependencies( implementation );
739
740 if ( d != null )
741 {
742 d = RuntimeModelObjects.getInstance().copyOf( d );
743 }
744
745 this.dependenciesByImplementationIdentifierCache.put( implementation, d );
746 }
747
748 return d;
749 }
750 }
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773 @Override
774 public Properties getProperties( final String implementation )
775 {
776 if ( implementation == null )
777 {
778 throw new NullPointerException( "implementation" );
779 }
780
781 synchronized ( this.propertiesByImplementationIdentifierCache )
782 {
783 Properties p = this.propertiesByImplementationIdentifierCache.get( implementation );
784
785 if ( p == null && !this.propertiesByImplementationIdentifierCache.containsKey( implementation ) )
786 {
787 p = super.getProperties( implementation );
788
789 if ( p != null )
790 {
791 p = RuntimeModelObjects.getInstance().copyOf( p );
792 }
793
794 this.propertiesByImplementationIdentifierCache.put( implementation, p );
795 }
796
797 return p;
798 }
799 }
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821 @Override
822 public Properties getSpecifiedProperties( final String implementation )
823 {
824 if ( implementation == null )
825 {
826 throw new NullPointerException( "implementation" );
827 }
828
829 synchronized ( this.specifiedPropertiesByImplementationIdentifierCache )
830 {
831 Properties p = this.specifiedPropertiesByImplementationIdentifierCache.get( implementation );
832
833 if ( p == null && !this.specifiedPropertiesByImplementationIdentifierCache.containsKey( implementation ) )
834 {
835 p = super.getSpecifiedProperties( implementation );
836
837 if ( p != null )
838 {
839 p = RuntimeModelObjects.getInstance().copyOf( p );
840 }
841
842 this.specifiedPropertiesByImplementationIdentifierCache.put( implementation, p );
843 }
844
845 return p;
846 }
847 }
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870 @Override
871 public Messages getMessages( final String implementation )
872 {
873 if ( implementation == null )
874 {
875 throw new NullPointerException( "implementation" );
876 }
877
878 synchronized ( this.messagesByImplementationIdentifierCache )
879 {
880 Messages m = this.messagesByImplementationIdentifierCache.get( implementation );
881
882 if ( m == null && !this.messagesByImplementationIdentifierCache.containsKey( implementation ) )
883 {
884 m = super.getMessages( implementation );
885
886 if ( m != null )
887 {
888 m = RuntimeModelObjects.getInstance().copyOf( m );
889 }
890
891 this.messagesByImplementationIdentifierCache.put( implementation, m );
892 }
893
894 return m;
895 }
896 }
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917 @Override
918 public Implementations getImplementations( final String specification )
919 {
920 if ( specification == null )
921 {
922 throw new NullPointerException( "specification" );
923 }
924
925 synchronized ( this.implementationsBySpecificationIdentifierCache )
926 {
927 Implementations i = this.implementationsBySpecificationIdentifierCache.get( specification );
928
929 if ( i == null && !this.implementationsBySpecificationIdentifierCache.containsKey( specification ) )
930 {
931 i = super.getImplementations( specification );
932
933 if ( i != null )
934 {
935 i = RuntimeModelObjects.getInstance().copyOf( i );
936 }
937
938 this.implementationsBySpecificationIdentifierCache.put( specification, i );
939 }
940
941 return i;
942 }
943 }
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965 @Override
966 public List<Object> getAnyObjects( final String implementation )
967 {
968 if ( implementation == null )
969 {
970 throw new NullPointerException( "implementation" );
971 }
972
973 synchronized ( this.anyObjectsByImplemenationIdentifierCache )
974 {
975 List<Object> any = this.anyObjectsByImplemenationIdentifierCache.get( implementation );
976
977 if ( any == null && !this.anyObjectsByImplemenationIdentifierCache.containsKey( implementation ) )
978 {
979 any = super.getAnyObjects( implementation );
980 this.anyObjectsByImplemenationIdentifierCache.put( implementation, any );
981 }
982
983 return any;
984 }
985 }
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004 @Override
1005 public Instance getInstance( final String implementation )
1006 {
1007 if ( implementation == null )
1008 {
1009 throw new NullPointerException( "implementation" );
1010 }
1011
1012 final Implementation i = this.getImplementation( implementation );
1013
1014 if ( i != null && i.getClazz() != null )
1015 {
1016 final Instance instance = new RuntimeInstance();
1017 instance.setIdentifier( i.getIdentifier() );
1018 instance.setName( i.getName() );
1019 instance.setClazz( i.getClazz() );
1020 instance.setStateless( i.isStateless() );
1021 instance.setDependencies( this.getDependencies( implementation ) );
1022 instance.setProperties( this.getProperties( implementation ) );
1023 instance.setMessages( this.getMessages( implementation ) );
1024 instance.setSpecifications( this.getSpecifications( implementation ) );
1025 instance.getAny().addAll( this.getAnyObjects( implementation ) );
1026 return instance;
1027 }
1028
1029 return null;
1030 }
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046 @Override
1047 public Instance getInstance( final String implementation, final Dependency dependency )
1048 {
1049 if ( implementation == null )
1050 {
1051 throw new NullPointerException( "implementation" );
1052 }
1053 if ( dependency == null )
1054 {
1055 throw new NullPointerException( "dependency" );
1056 }
1057
1058 Instance instance = this.getInstance( implementation );
1059
1060 if ( instance != null )
1061 {
1062 final Specification dependencySpecification = this.getSpecification( dependency.getIdentifier() );
1063
1064 if ( dependencySpecification != null && dependencySpecification.getScope() == null )
1065 {
1066 if ( dependency.getDependencies() != null && !dependency.getDependencies().getDependency().isEmpty() )
1067 {
1068 final Dependencies dependencies =
1069 RuntimeModelObjects.getInstance().copyOf( dependency.getDependencies() );
1070
1071 if ( instance.getDependencies() != null )
1072 {
1073 for ( int i = 0, s0 = instance.getDependencies().getDependency().size(); i < s0; i++ )
1074 {
1075 final Dependency d = instance.getDependencies().getDependency().get( i );
1076 final Dependency td = dependencies.getDependency( d.getName() );
1077
1078 if ( td == null )
1079 {
1080 dependencies.getDependency().add( d );
1081
1082 if ( dependencies instanceof RuntimeModelObject )
1083 {
1084 ( (RuntimeModelObject) dependencies ).clear();
1085 }
1086 }
1087 else
1088 {
1089 this.collectDependencies( d, td );
1090 }
1091 }
1092 }
1093
1094 instance.setDependencies( dependencies );
1095 }
1096
1097 if ( dependency.getMessages() != null && !dependency.getMessages().getMessage().isEmpty() )
1098 {
1099 final Messages messages =
1100 RuntimeModelObjects.getInstance().copyOf( dependency.getMessages() );
1101
1102 if ( instance.getMessages() != null )
1103 {
1104 for ( int i = 0, s0 = instance.getMessages().getMessage().size(); i < s0; i++ )
1105 {
1106 final Message m = instance.getMessages().getMessage().get( i );
1107
1108 if ( messages.getMessage( m.getName() ) == null )
1109 {
1110 messages.getMessage().add( m );
1111
1112 if ( messages instanceof RuntimeModelObject )
1113 {
1114 ( (RuntimeModelObject) messages ).clear();
1115 }
1116 }
1117 }
1118 }
1119
1120 instance.setMessages( messages );
1121 }
1122
1123 if ( dependency.getProperties() != null && !dependency.getProperties().getProperty().isEmpty() )
1124 {
1125 final Properties properties =
1126 RuntimeModelObjects.getInstance().copyOf( dependency.getProperties() );
1127
1128 if ( instance.getProperties() != null )
1129 {
1130 for ( int i = 0, s0 = instance.getProperties().getProperty().size(); i < s0; i++ )
1131 {
1132 final Property p = instance.getProperties().getProperty().get( i );
1133
1134 if ( properties.getProperty( p.getName() ) == null )
1135 {
1136 properties.getProperty().add( p );
1137
1138 if ( properties instanceof RuntimeModelObject )
1139 {
1140 ( (RuntimeModelObject) properties ).clear();
1141 }
1142 }
1143 }
1144 }
1145
1146 instance.setProperties( properties );
1147 }
1148 }
1149 }
1150
1151 return instance;
1152 }
1153
1154 private void collectDependencies( final Dependency source, final Dependency target )
1155 {
1156 if ( source.getMessages() != null )
1157 {
1158 if ( target.getMessages() == null )
1159 {
1160 target.setMessages( new RuntimeMessages() );
1161 }
1162
1163 for ( int i = 0, s0 = source.getMessages().getMessage().size(); i < s0; i++ )
1164 {
1165 final Message m = source.getMessages().getMessage().get( i );
1166
1167 if ( target.getMessages().getMessage( m.getName() ) == null )
1168 {
1169 target.getMessages().getMessage().add( m );
1170
1171 if ( target.getMessages() instanceof RuntimeModelObject )
1172 {
1173 ( (RuntimeModelObject) target.getMessages() ).clear();
1174 }
1175 }
1176 }
1177 }
1178
1179 if ( source.getProperties() != null )
1180 {
1181 if ( target.getProperties() == null )
1182 {
1183 target.setProperties( new RuntimeProperties() );
1184 }
1185
1186 for ( int i = 0, s0 = source.getProperties().getProperty().size(); i < s0; i++ )
1187 {
1188 final Property p = source.getProperties().getProperty().get( i );
1189
1190 if ( target.getProperties().getProperty( p.getName() ) == null )
1191 {
1192 target.getProperties().getProperty().add( p );
1193
1194 if ( target.getProperties() instanceof RuntimeModelObject )
1195 {
1196 ( (RuntimeModelObject) target.getProperties() ).clear();
1197 }
1198 }
1199 }
1200 }
1201
1202 if ( source.getDependencies() != null )
1203 {
1204 if ( target.getDependencies() == null )
1205 {
1206 target.setDependencies( new RuntimeDependencies() );
1207 }
1208
1209 for ( int i = 0, s0 = source.getDependencies().getDependency().size(); i < s0; i++ )
1210 {
1211 final Dependency sd = source.getDependencies().getDependency().get( i );
1212 final Dependency td = target.getDependencies().getDependency( sd.getName() );
1213
1214 if ( td == null )
1215 {
1216 target.getDependencies().getDependency().add( sd );
1217
1218 if ( target.getDependencies() instanceof RuntimeModelObject )
1219 {
1220 ( (RuntimeModelObject) target.getDependencies() ).clear();
1221 }
1222 }
1223 else
1224 {
1225 this.collectDependencies( sd, td );
1226 }
1227 }
1228 }
1229 }
1230
1231 private void copyModules()
1232 {
1233 for ( int i = 0, s0 = this.getModule().size(); i < s0; i++ )
1234 {
1235 final Module m = this.getModule().get( i );
1236 this.getModule().set( i, RuntimeModelObjects.getInstance().copyOf( m ) );
1237 }
1238 }
1239
1240
1241
1242 public void gc()
1243 {
1244 gcMap( this.specificationsCache );
1245 gcMap( this.implementationsCache );
1246 gcMap( this.specificationsByImplemenationIdentifierCache );
1247 gcMap( this.dependenciesByImplementationIdentifierCache );
1248 gcMap( this.propertiesByImplementationIdentifierCache );
1249 gcMap( this.specifiedPropertiesByImplementationIdentifierCache );
1250 gcMap( this.messagesByImplementationIdentifierCache );
1251 gcMap( this.implementationsBySpecificationIdentifierCache );
1252 this.gcOrClear( true, false );
1253 }
1254
1255 public void clear()
1256 {
1257 synchronized ( this.anyObjectsByImplemenationIdentifierCache )
1258 {
1259 this.anyObjectsByImplemenationIdentifierCache.clear();
1260 }
1261 synchronized ( this.dependenciesByImplementationIdentifierCache )
1262 {
1263 this.dependenciesByImplementationIdentifierCache.clear();
1264 }
1265 synchronized ( this.implementationByClassNameCache )
1266 {
1267 this.implementationByClassNameCache.clear();
1268 }
1269 synchronized ( this.implementationByIdentifierCache )
1270 {
1271 this.implementationByIdentifierCache.clear();
1272 }
1273 synchronized ( this.implementationByObjectClassNameCache )
1274 {
1275 this.implementationByObjectClassNameCache.clear();
1276 }
1277 synchronized ( this.implementationBySpecificationAndNameCache )
1278 {
1279 this.implementationBySpecificationAndNameCache.clear();
1280 }
1281 synchronized ( this.implementationsBySpecificationIdentifierCache )
1282 {
1283 this.implementationsBySpecificationIdentifierCache.clear();
1284 }
1285 synchronized ( this.implementationsCache )
1286 {
1287 this.implementationsCache.clear();
1288 }
1289 synchronized ( this.messagesByImplementationIdentifierCache )
1290 {
1291 this.messagesByImplementationIdentifierCache.clear();
1292 }
1293 synchronized ( this.moduleByImplementationIdentifierCache )
1294 {
1295 this.moduleByImplementationIdentifierCache.clear();
1296 }
1297 synchronized ( this.moduleBySpecificationIdentifierCache )
1298 {
1299 this.moduleBySpecificationIdentifierCache.clear();
1300 }
1301 synchronized ( this.modulesByNameCache )
1302 {
1303 this.modulesByNameCache.clear();
1304 }
1305 synchronized ( this.propertiesByImplementationIdentifierCache )
1306 {
1307 this.propertiesByImplementationIdentifierCache.clear();
1308 }
1309 synchronized ( this.specificationByClassNameCache )
1310 {
1311 this.specificationByClassNameCache.clear();
1312 }
1313 synchronized ( this.specificationByIdentifierCache )
1314 {
1315 this.specificationByIdentifierCache.clear();
1316 }
1317 synchronized ( this.specificationsByImplemenationIdentifierCache )
1318 {
1319 this.specificationsByImplemenationIdentifierCache.clear();
1320 }
1321 synchronized ( this.specificationsCache )
1322 {
1323 this.specificationsCache.clear();
1324 }
1325 synchronized ( this.specifiedPropertiesByImplementationIdentifierCache )
1326 {
1327 this.specifiedPropertiesByImplementationIdentifierCache.clear();
1328 }
1329
1330 this.gcOrClear( false, true );
1331 }
1332
1333 private void gcOrClear( final boolean gc, final boolean clear )
1334 {
1335 if ( this.getAuthors() instanceof RuntimeModelObject )
1336 {
1337 if ( gc )
1338 {
1339 ( (RuntimeModelObject) this.getAuthors() ).gc();
1340 }
1341 if ( clear )
1342 {
1343 ( (RuntimeModelObject) this.getAuthors() ).clear();
1344 }
1345 }
1346 if ( this.getDocumentation() instanceof RuntimeModelObject )
1347 {
1348 if ( gc )
1349 {
1350 ( (RuntimeModelObject) this.getDocumentation() ).gc();
1351 }
1352 if ( clear )
1353 {
1354 ( (RuntimeModelObject) this.getDocumentation() ).clear();
1355 }
1356 }
1357
1358 this.gcOrClearModules( gc, clear );
1359 }
1360
1361 private void gcOrClearModules( final boolean gc, final boolean clear )
1362 {
1363
1364 for ( int i = 0, s0 = this.getModule().size(); i < s0; i++ )
1365 {
1366 final Module m = this.getModule().get( i );
1367 if ( m instanceof RuntimeModelObject )
1368 {
1369 if ( gc )
1370 {
1371 ( (RuntimeModelObject) m ).gc();
1372 }
1373 if ( clear )
1374 {
1375 ( (RuntimeModelObject) m ).clear();
1376 }
1377 }
1378 }
1379 }
1380
1381 private static void gcMap( final Map<?, ?> map )
1382 {
1383 synchronized ( map )
1384 {
1385 for ( Map.Entry<?, ?> e : map.entrySet() )
1386 {
1387 if ( e.getValue() instanceof RuntimeModelObject )
1388 {
1389 ( (RuntimeModelObject) e.getValue() ).gc();
1390 }
1391 }
1392 }
1393 }
1394
1395
1396
1397
1398
1399 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" )
1400 public RuntimeModules()
1401 {
1402
1403 super();
1404
1405 }
1406
1407
1408
1409
1410
1411
1412
1413
1414 }