@@ -182,10 +182,12 @@ public GroovyBeanDefinitionReader(XmlBeanDefinitionReader xmlBeanDefinitionReade
182
182
}
183
183
184
184
185
+ @ Override
185
186
public void setMetaClass (MetaClass metaClass ) {
186
187
this .metaClass = metaClass ;
187
188
}
188
189
190
+ @ Override
189
191
public MetaClass getMetaClass () {
190
192
return this .metaClass ;
191
193
}
@@ -216,6 +218,7 @@ public Binding getBinding() {
216
218
* @return the number of bean definitions found
217
219
* @throws BeanDefinitionStoreException in case of loading or parsing errors
218
220
*/
221
+ @ Override
219
222
public int loadBeanDefinitions (Resource resource ) throws BeanDefinitionStoreException {
220
223
return loadBeanDefinitions (new EncodedResource (resource ));
221
224
}
@@ -240,10 +243,11 @@ public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefin
240
243
logger .trace ("Loading Groovy bean definitions from " + encodedResource );
241
244
}
242
245
243
- Closure beans = new Closure (this ) {
246
+ @ SuppressWarnings ("serial" )
247
+ Closure <Object > beans = new Closure <Object >(this ) {
244
248
@ Override
245
- public Object call (Object [] args ) {
246
- invokeBeanDefiningClosure ((Closure ) args [0 ]);
249
+ public Object call (Object ... args ) {
250
+ invokeBeanDefiningClosure ((Closure <?> ) args [0 ]);
247
251
return null ;
248
252
}
249
253
};
@@ -285,7 +289,7 @@ public void setVariable(String name, Object value) {
285
289
* @param closure the block or closure
286
290
* @return this {@code GroovyBeanDefinitionReader} instance
287
291
*/
288
- public GroovyBeanDefinitionReader beans (Closure closure ) {
292
+ public GroovyBeanDefinitionReader beans (Closure <?> closure ) {
289
293
return invokeBeanDefiningClosure (closure );
290
294
}
291
295
@@ -309,13 +313,13 @@ public GenericBeanDefinition bean(Class<?> type) {
309
313
public AbstractBeanDefinition bean (Class <?> type , Object ...args ) {
310
314
GroovyBeanDefinitionWrapper current = this .currentBeanDefinition ;
311
315
try {
312
- Closure callable = null ;
316
+ Closure <?> callable = null ;
313
317
Collection <Object > constructorArgs = null ;
314
318
if (!ObjectUtils .isEmpty (args )) {
315
319
int index = args .length ;
316
320
Object lastArg = args [index - 1 ];
317
- if (lastArg instanceof Closure ) {
318
- callable = (Closure ) lastArg ;
321
+ if (lastArg instanceof Closure <?> ) {
322
+ callable = (Closure <?> ) lastArg ;
319
323
index --;
320
324
}
321
325
constructorArgs = resolveConstructorArguments (args , 0 , index );
@@ -370,10 +374,11 @@ public void importBeans(String resourcePattern) throws IOException {
370
374
* This method overrides method invocation to create beans for each method name that
371
375
* takes a class argument.
372
376
*/
377
+ @ Override
373
378
public Object invokeMethod (String name , Object arg ) {
374
379
Object [] args = (Object [])arg ;
375
380
if ("beans" .equals (name ) && args .length == 1 && args [0 ] instanceof Closure ) {
376
- return beans ((Closure ) args [0 ]);
381
+ return beans ((Closure <?> ) args [0 ]);
377
382
}
378
383
else if ("ref" .equals (name )) {
379
384
String refName ;
@@ -426,10 +431,10 @@ private boolean addDeferredProperty(String property, Object newValue) {
426
431
private void finalizeDeferredProperties () {
427
432
for (DeferredProperty dp : this .deferredProperties .values ()) {
428
433
if (dp .value instanceof List ) {
429
- dp .value = manageListIfNecessary ((List ) dp .value );
434
+ dp .value = manageListIfNecessary ((List <?> ) dp .value );
430
435
}
431
436
else if (dp .value instanceof Map ) {
432
- dp .value = manageMapIfNecessary ((Map ) dp .value );
437
+ dp .value = manageMapIfNecessary ((Map <?, ?> ) dp .value );
433
438
}
434
439
dp .apply ();
435
440
}
@@ -441,7 +446,7 @@ else if (dp.value instanceof Map) {
441
446
* @param callable the closure argument
442
447
* @return this {@code GroovyBeanDefinitionReader} instance
443
448
*/
444
- protected GroovyBeanDefinitionReader invokeBeanDefiningClosure (Closure callable ) {
449
+ protected GroovyBeanDefinitionReader invokeBeanDefiningClosure (Closure <?> callable ) {
445
450
callable .setDelegate (this );
446
451
callable .call ();
447
452
finalizeDeferredProperties ();
@@ -480,9 +485,10 @@ else if (args[0] instanceof RuntimeBeanReference) {
480
485
else if (args [0 ] instanceof Map ) {
481
486
// named constructor arguments
482
487
if (args .length > 1 && args [1 ] instanceof Class ) {
483
- List constructorArgs = resolveConstructorArguments (args , 2 , hasClosureArgument ? args .length - 1 : args .length );
484
- this .currentBeanDefinition = new GroovyBeanDefinitionWrapper (beanName , (Class )args [1 ], constructorArgs );
485
- Map namedArgs = (Map )args [0 ];
488
+ List <Object > constructorArgs =
489
+ resolveConstructorArguments (args , 2 , hasClosureArgument ? args .length - 1 : args .length );
490
+ this .currentBeanDefinition = new GroovyBeanDefinitionWrapper (beanName , (Class <?>) args [1 ], constructorArgs );
491
+ Map <?, ?> namedArgs = (Map <?, ?>) args [0 ];
486
492
for (Object o : namedArgs .keySet ()) {
487
493
String propName = (String ) o ;
488
494
setProperty (propName , namedArgs .get (propName ));
@@ -491,8 +497,8 @@ else if (args[0] instanceof Map) {
491
497
// factory method syntax
492
498
else {
493
499
this .currentBeanDefinition = new GroovyBeanDefinitionWrapper (beanName );
494
- //First arg is the map containing factoryBean : factoryMethod
495
- Map .Entry factoryBeanEntry = (Map . Entry ) (( Map ) args [0 ]).entrySet ().iterator ().next ();
500
+ // First arg is the map containing factoryBean : factoryMethod
501
+ Map .Entry <?, ?> factoryBeanEntry = (( Map <?, ?> ) args [0 ]).entrySet ().iterator ().next ();
496
502
// If we have a closure body, that will be the last argument.
497
503
// In between are the constructor args
498
504
int constructorArgsTest = (hasClosureArgument ? 2 : 1 );
@@ -516,12 +522,13 @@ else if (args[0] instanceof Closure) {
516
522
this .currentBeanDefinition .getBeanDefinition ().setAbstract (true );
517
523
}
518
524
else {
519
- List constructorArgs = resolveConstructorArguments (args , 0 , hasClosureArgument ? args .length - 1 : args .length );
525
+ List <Object > constructorArgs =
526
+ resolveConstructorArguments (args , 0 , hasClosureArgument ? args .length - 1 : args .length );
520
527
this .currentBeanDefinition = new GroovyBeanDefinitionWrapper (beanName , null , constructorArgs );
521
528
}
522
529
523
530
if (hasClosureArgument ) {
524
- Closure callable = (Closure ) args [args .length - 1 ];
531
+ Closure <?> callable = (Closure <?> ) args [args .length - 1 ];
525
532
callable .setDelegate (this );
526
533
callable .setResolveStrategy (Closure .DELEGATE_FIRST );
527
534
callable .call (this .currentBeanDefinition );
@@ -541,10 +548,10 @@ protected List<Object> resolveConstructorArguments(Object[] args, int start, int
541
548
constructorArgs [i ] = constructorArgs [i ].toString ();
542
549
}
543
550
else if (constructorArgs [i ] instanceof List ) {
544
- constructorArgs [i ] = manageListIfNecessary ((List ) constructorArgs [i ]);
551
+ constructorArgs [i ] = manageListIfNecessary ((List <?> ) constructorArgs [i ]);
545
552
}
546
553
else if (constructorArgs [i ] instanceof Map ){
547
- constructorArgs [i ] = manageMapIfNecessary ((Map ) constructorArgs [i ]);
554
+ constructorArgs [i ] = manageMapIfNecessary ((Map <?, ?> ) constructorArgs [i ]);
548
555
}
549
556
}
550
557
return Arrays .asList (constructorArgs );
@@ -598,6 +605,7 @@ private Object manageListIfNecessary(List<?> list) {
598
605
* This method overrides property setting in the scope of the {@code GroovyBeanDefinitionReader}
599
606
* to set properties on the current bean definition.
600
607
*/
608
+ @ Override
601
609
public void setProperty (String name , Object value ) {
602
610
if (this .currentBeanDefinition != null ) {
603
611
applyPropertyToBeanDefinition (name , value );
@@ -614,7 +622,7 @@ protected void applyPropertyToBeanDefinition(String name, Object value) {
614
622
else if (value instanceof Closure ) {
615
623
GroovyBeanDefinitionWrapper current = this .currentBeanDefinition ;
616
624
try {
617
- Closure callable = (Closure ) value ;
625
+ Closure <?> callable = (Closure <?> ) value ;
618
626
Class <?> parameterType = callable .getParameterTypes ()[0 ];
619
627
if (Object .class == parameterType ) {
620
628
this .currentBeanDefinition = new GroovyBeanDefinitionWrapper ("" );
@@ -644,6 +652,7 @@ else if (value instanceof Closure) {
644
652
* properties from the {@code GroovyBeanDefinitionReader} itself
645
653
* </ul>
646
654
*/
655
+ @ Override
647
656
public Object getProperty (String name ) {
648
657
Binding binding = getBinding ();
649
658
if (binding != null && binding .hasVariable (name )) {
@@ -687,8 +696,8 @@ else if (this.currentBeanDefinition != null) {
687
696
}
688
697
689
698
private GroovyDynamicElementReader createDynamicElementReader (String namespace ) {
690
- XmlReaderContext readerContext = this .groovyDslXmlBeanDefinitionReader .createReaderContext (new DescriptiveResource (
691
- "Groovy" ));
699
+ XmlReaderContext readerContext = this .groovyDslXmlBeanDefinitionReader .createReaderContext (
700
+ new DescriptiveResource ( "Groovy" ));
692
701
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate (readerContext );
693
702
boolean decorating = (this .currentBeanDefinition != null );
694
703
if (!decorating ) {
@@ -746,10 +755,12 @@ public GroovyRuntimeBeanReference(String beanName, GroovyBeanDefinitionWrapper b
746
755
this .metaClass = InvokerHelper .getMetaClass (this );
747
756
}
748
757
758
+ @ Override
749
759
public MetaClass getMetaClass () {
750
760
return this .metaClass ;
751
761
}
752
762
763
+ @ Override
753
764
public Object getProperty (String property ) {
754
765
if (property .equals ("beanName" )) {
755
766
return getBeanName ();
@@ -766,14 +777,17 @@ else if (this.beanDefinition != null) {
766
777
}
767
778
}
768
779
780
+ @ Override
769
781
public Object invokeMethod (String name , Object args ) {
770
782
return this .metaClass .invokeMethod (this , name , args );
771
783
}
772
784
785
+ @ Override
773
786
public void setMetaClass (MetaClass metaClass ) {
774
787
this .metaClass = metaClass ;
775
788
}
776
789
790
+ @ Override
777
791
public void setProperty (String property , Object newValue ) {
778
792
if (!addDeferredProperty (property , newValue )) {
779
793
this .beanDefinition .getBeanDefinition ().getPropertyValues ().add (property , newValue );
@@ -782,7 +796,7 @@ public void setProperty(String property, Object newValue) {
782
796
783
797
784
798
/**
785
- * Wraps a bean definition property an ensures that any RuntimeBeanReference
799
+ * Wraps a bean definition property and ensures that any RuntimeBeanReference
786
800
* additions to it are deferred for resolution later.
787
801
*/
788
802
private class GroovyPropertyValue extends GroovyObjectSupport {
@@ -796,17 +810,20 @@ public GroovyPropertyValue(String propertyName, Object propertyValue) {
796
810
this .propertyValue = propertyValue ;
797
811
}
798
812
813
+ @ SuppressWarnings ("unused" )
799
814
public void leftShift (Object value ) {
800
815
InvokerHelper .invokeMethod (this .propertyValue , "leftShift" , value );
801
816
updateDeferredProperties (value );
802
817
}
803
818
819
+ @ SuppressWarnings ("unused" )
804
820
public boolean add (Object value ) {
805
821
boolean retVal = (Boolean ) InvokerHelper .invokeMethod (this .propertyValue , "add" , value );
806
822
updateDeferredProperties (value );
807
823
return retVal ;
808
824
}
809
825
826
+ @ SuppressWarnings ("unused" )
810
827
public boolean addAll (Collection <?> values ) {
811
828
boolean retVal = (Boolean ) InvokerHelper .invokeMethod (this .propertyValue , "addAll" , values );
812
829
for (Object value : values ) {
0 commit comments