34
34
import org .springframework .util .StringUtils ;
35
35
import org .springframework .util .xml .DomUtils ;
36
36
37
+ import static org .springframework .util .StringUtils .hasLength ;
38
+
37
39
/**
38
40
* BeanDefinitionParser implementation for the '{@code <lang:groovy/>}',
39
41
* '{@code <lang:std/>}' and '{@code <lang:bsh/>}' tags.
@@ -125,7 +127,7 @@ public ScriptBeanDefinitionParser(String scriptFactoryClassName) {
125
127
126
128
// Determine bean scope.
127
129
String scope = element .getAttribute (SCOPE_ATTRIBUTE );
128
- if (StringUtils . hasLength (scope )) {
130
+ if (hasLength (scope )) {
129
131
bd .setScope (scope );
130
132
}
131
133
@@ -143,7 +145,7 @@ else if (autowireMode == AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR) {
143
145
144
146
// Parse depends-on list of bean names.
145
147
String dependsOn = element .getAttribute (DEPENDS_ON_ATTRIBUTE );
146
- if (StringUtils . hasLength (dependsOn )) {
148
+ if (hasLength (dependsOn )) {
147
149
bd .setDependsOn (StringUtils .tokenizeToStringArray (
148
150
dependsOn , BeanDefinitionParserDelegate .MULTI_VALUE_ATTRIBUTE_DELIMITERS ));
149
151
}
@@ -153,7 +155,7 @@ else if (autowireMode == AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR) {
153
155
154
156
// Determine init method and destroy method.
155
157
String initMethod = element .getAttribute (INIT_METHOD_ATTRIBUTE );
156
- if (StringUtils . hasLength (initMethod )) {
158
+ if (hasLength (initMethod )) {
157
159
bd .setInitMethodName (initMethod );
158
160
}
159
161
else if (beanDefinitionDefaults .getInitMethodName () != null ) {
@@ -183,7 +185,7 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
183
185
// Add constructor arguments.
184
186
ConstructorArgumentValues cav = bd .getConstructorArgumentValues ();
185
187
int constructorArgNum = 0 ;
186
- if (StringUtils . hasLength (engine )) {
188
+ if (hasLength (engine )) {
187
189
cav .addIndexedArgumentValue (constructorArgNum ++, engine );
188
190
}
189
191
cav .addIndexedArgumentValue (constructorArgNum ++, value );
@@ -194,12 +196,11 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
194
196
195
197
// This is used for Groovy. It's a bean reference to a customizer bean.
196
198
if (element .hasAttribute (CUSTOMIZER_REF_ATTRIBUTE )) {
197
- String customizerBeanName = element .getAttribute (CUSTOMIZER_REF_ATTRIBUTE );
198
- if (!StringUtils .hasText (customizerBeanName )) {
199
+ if (!StringUtils .hasText (element .getAttribute (CUSTOMIZER_REF_ATTRIBUTE ))) {
199
200
parserContext .getReaderContext ().error ("Attribute 'customizer-ref' has empty value" , element );
200
201
}
201
202
else {
202
- cav .addIndexedArgumentValue (constructorArgNum ++ , new RuntimeBeanReference (customizerBeanName ));
203
+ cav .addIndexedArgumentValue (constructorArgNum , new RuntimeBeanReference (element . getAttribute ( CUSTOMIZER_REF_ATTRIBUTE ) ));
203
204
}
204
205
}
205
206
0 commit comments