|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -94,7 +94,7 @@ import org.springframework.util.StringUtils; |
|
|
|
* <property name="message" value="Hello World!"/> |
|
|
|
* <property name="message" value="Hello World!"/> |
|
|
|
* </bean> |
|
|
|
* </bean> |
|
|
|
* |
|
|
|
* |
|
|
|
* <bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"> |
|
|
|
* <bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"> |
|
|
|
* <constructor-arg value="classpath:mypackage/Messenger.groovy"/> |
|
|
|
* <constructor-arg value="classpath:mypackage/Messenger.groovy"/> |
|
|
|
* <property name="message" value="Hello World!"/> |
|
|
|
* <property name="message" value="Hello World!"/> |
|
|
|
* </bean></pre> |
|
|
|
* </bean></pre> |
|
|
|
@ -325,7 +325,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces |
|
|
|
if (proxyTargetClass && (language == null || !language.equals("groovy"))) { |
|
|
|
if (proxyTargetClass && (language == null || !language.equals("groovy"))) { |
|
|
|
throw new BeanDefinitionValidationException( |
|
|
|
throw new BeanDefinitionValidationException( |
|
|
|
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" + |
|
|
|
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" + |
|
|
|
language + "'"); |
|
|
|
language + "'"); |
|
|
|
} |
|
|
|
} |
|
|
|
ts.setRefreshCheckDelay(refreshCheckDelay); |
|
|
|
ts.setRefreshCheckDelay(refreshCheckDelay); |
|
|
|
return createRefreshableProxy(ts, interfaces, proxyTargetClass); |
|
|
|
return createRefreshableProxy(ts, interfaces, proxyTargetClass); |
|
|
|
@ -346,17 +346,16 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces |
|
|
|
* @param scriptedObjectBeanName the name of the internal scripted object bean |
|
|
|
* @param scriptedObjectBeanName the name of the internal scripted object bean |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) { |
|
|
|
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) { |
|
|
|
|
|
|
|
|
|
|
|
// Avoid recreation of the script bean definition in case of a prototype.
|
|
|
|
// Avoid recreation of the script bean definition in case of a prototype.
|
|
|
|
synchronized (this.scriptBeanFactory) { |
|
|
|
synchronized (this.scriptBeanFactory) { |
|
|
|
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) { |
|
|
|
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) { |
|
|
|
|
|
|
|
|
|
|
|
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName, |
|
|
|
this.scriptBeanFactory.registerBeanDefinition( |
|
|
|
createScriptFactoryBeanDefinition(bd)); |
|
|
|
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd)); |
|
|
|
ScriptFactory scriptFactory = this.scriptBeanFactory |
|
|
|
ScriptFactory scriptFactory = |
|
|
|
.getBean(scriptFactoryBeanName, ScriptFactory.class); |
|
|
|
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class); |
|
|
|
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, |
|
|
|
ScriptSource scriptSource = |
|
|
|
scriptFactory.getScriptSourceLocator()); |
|
|
|
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator()); |
|
|
|
Class<?>[] interfaces = scriptFactory.getScriptInterfaces(); |
|
|
|
Class<?>[] interfaces = scriptFactory.getScriptInterfaces(); |
|
|
|
|
|
|
|
|
|
|
|
Class<?>[] scriptedInterfaces = interfaces; |
|
|
|
Class<?>[] scriptedInterfaces = interfaces; |
|
|
|
@ -365,8 +364,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces |
|
|
|
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface); |
|
|
|
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource, |
|
|
|
BeanDefinition objectBd = createScriptedObjectBeanDefinition( |
|
|
|
scriptedInterfaces); |
|
|
|
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces); |
|
|
|
long refreshCheckDelay = resolveRefreshCheckDelay(bd); |
|
|
|
long refreshCheckDelay = resolveRefreshCheckDelay(bd); |
|
|
|
if (refreshCheckDelay >= 0) { |
|
|
|
if (refreshCheckDelay >= 0) { |
|
|
|
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
@ -569,7 +568,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces |
|
|
|
proxyFactory.setInterfaces(interfaces); |
|
|
|
proxyFactory.setInterfaces(interfaces); |
|
|
|
if (proxyTargetClass) { |
|
|
|
if (proxyTargetClass) { |
|
|
|
classLoader = null; // force use of Class.getClassLoader()
|
|
|
|
classLoader = null; // force use of Class.getClassLoader()
|
|
|
|
proxyFactory.setProxyTargetClass(proxyTargetClass); |
|
|
|
proxyFactory.setProxyTargetClass(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts); |
|
|
|
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts); |
|
|
|
|