本文整理汇总了Java中org.springframework.scripting.ScriptFactory类的典型用法代码示例。如果您正苦于以下问题:Java ScriptFactory类的具体用法?Java ScriptFactory怎么用?Java ScriptFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptFactory类属于org.springframework.scripting包,在下文中一共展示了ScriptFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: RefreshableScriptTargetSource
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
/**
* Create a new RefreshableScriptTargetSource.
* @param beanFactory the BeanFactory to fetch the scripted bean from
* @param beanName the name of the target bean
* @param scriptFactory the ScriptFactory to delegate to for determining
* whether a refresh is required
* @param scriptSource the ScriptSource for the script definition
* @param isFactoryBean whether the target script defines a FactoryBean
*/
public RefreshableScriptTargetSource(BeanFactory beanFactory, String beanName,
ScriptFactory scriptFactory, ScriptSource scriptSource, boolean isFactoryBean) {
super(beanFactory, beanName);
Assert.notNull(scriptFactory, "ScriptFactory must not be null");
Assert.notNull(scriptSource, "ScriptSource must not be null");
this.scriptFactory = scriptFactory;
this.scriptSource = scriptSource;
this.isFactoryBean = isFactoryBean;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:RefreshableScriptTargetSource.java
示例2: prepareScriptBeans
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
/**
* Prepare the script beans in the internal BeanFactory that this
* post-processor uses. Each original bean definition will be split
* into a ScriptFactory definition and a scripted object definition.
* @param bd the original bean definition in the main BeanFactory
* @param scriptFactoryBeanName the name of the internal ScriptFactory bean
* @param scriptedObjectBeanName the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory
.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
Class<?> configInterface = createConfigInterface(bd, interfaces);
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
}
this.scriptBeanFactory.registerBeanDefinition(scriptedObjectBeanName, objectBd);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:ScriptFactoryPostProcessor.java
示例3: prepareScriptBeans
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
/**
* Prepare the script beans in the internal BeanFactory that this
* post-processor uses. Each original bean definition will be split into a
* ScriptFactory definition and a scripted object definition.
*
* @param bd
* the original bean definition in the main BeanFactory
* @param scriptFactoryBeanName
* the name of the internal ScriptFactory bean
* @param scriptedObjectBeanName
* the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a
// prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName,
ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
Class<?> configInterface = createConfigInterface(bd, interfaces);
scriptedInterfaces = (Class<?>[]) ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
}
this.scriptBeanFactory.registerBeanDefinition(scriptedObjectBeanName, objectBd);
}
}
}
开发者ID:ilivoo,项目名称:game,代码行数:45,代码来源:MyScriptFactoryPostProcessor.java
示例4: prepareScriptBeans
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
/**
* Prepare the script beans in the internal BeanFactory that this
* post-processor uses. Each original bean definition will be split
* into a ScriptFactory definition and a scripted object definition.
* @param bd the original bean definition in the main BeanFactory
* @param scriptFactoryBeanName the name of the internal ScriptFactory bean
* @param scriptedObjectBeanName the name of the internal scripted object bean
*/
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
// Avoid recreation of the script bean definition in case of a prototype.
synchronized (this.scriptBeanFactory) {
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
this.scriptBeanFactory.registerBeanDefinition(
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
ScriptFactory scriptFactory =
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource =
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?>[] scriptedInterfaces = interfaces;
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
Class<?> configInterface = createConfigInterface(bd, interfaces);
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
}
this.scriptBeanFactory.registerBeanDefinition(scriptedObjectBeanName, objectBd);
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:ScriptFactoryPostProcessor.java
示例5: predictBeanType
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
@Override
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
try {
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?> scriptedType = scriptFactory.getScriptedObjectType(scriptSource);
if (scriptedType != null) {
return scriptedType;
}
else if (!ObjectUtils.isEmpty(interfaces)) {
return (interfaces.length == 1 ? interfaces[0] : createCompositeInterface(interfaces));
}
else {
if (bd.isSingleton()) {
Object bean = this.scriptBeanFactory.getBean(scriptedObjectBeanName);
if (bean != null) {
return bean.getClass();
}
}
}
}
catch (Exception ex) {
if (ex instanceof BeanCreationException
&& ((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
if (logger.isTraceEnabled()) {
logger.trace("Could not determine scripted object type for bean '" + beanName + "': "
+ ex.getMessage());
}
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Could not determine scripted object type for bean '" + beanName + "'", ex);
}
}
}
return null;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:ScriptFactoryPostProcessor.java
示例6: postProcessBeforeInstantiation
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
boolean isFactoryBean = false;
try {
Class<?> scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
// Returned type may be null if the factory is unable to determine the type.
if (scriptedObjectType != null) {
isFactoryBean = FactoryBean.class.isAssignableFrom(scriptedObjectType);
}
}
catch (Exception ex) {
throw new BeanCreationException(beanName,
"Could not determine scripted object type for " + scriptFactory, ex);
}
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
RefreshableScriptTargetSource ts = new RefreshableScriptTargetSource(this.scriptBeanFactory,
scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
boolean proxyTargetClass = resolveProxyTargetClass(bd);
String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
language + "'");
}
ts.setRefreshCheckDelay(refreshCheckDelay);
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
}
if (isFactoryBean) {
scriptedObjectBeanName = BeanFactory.FACTORY_BEAN_PREFIX + scriptedObjectBeanName;
}
return this.scriptBeanFactory.getBean(scriptedObjectBeanName);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:ScriptFactoryPostProcessor.java
示例7: predictBeanType
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
@Override
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations
// here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
try {
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
Class<?> scriptedType = scriptFactory.getScriptedObjectType(scriptSource);
if (scriptedType != null) {
return scriptedType;
} else if (!ObjectUtils.isEmpty(interfaces)) {
return (interfaces.length == 1 ? interfaces[0] : createCompositeInterface(interfaces));
} else {
if (bd.isSingleton()) {
Object bean = this.scriptBeanFactory.getBean(scriptedObjectBeanName);
if (bean != null) {
return bean.getClass();
}
}
}
} catch (Exception ex) {
if (ex instanceof BeanCreationException && ((BeanCreationException) ex)
.getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
if (logger.isTraceEnabled()) {
logger.trace(
"Could not determine scripted object type for bean '" + beanName + "': " + ex.getMessage());
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Could not determine scripted object type for bean '" + beanName + "'", ex);
}
}
}
return null;
}
开发者ID:ilivoo,项目名称:game,代码行数:49,代码来源:MyScriptFactoryPostProcessor.java
示例8: postProcessBeforeInstantiation
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations
// here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
boolean isFactoryBean = false;
try {
Class<?> scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
// Returned type may be null if the factory is unable to determine
// the type.
if (scriptedObjectType != null) {
isFactoryBean = FactoryBean.class.isAssignableFrom(scriptedObjectType);
}
} catch (Exception ex) {
throw new BeanCreationException(beanName, "Could not determine scripted object type for " + scriptFactory,
ex);
}
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
RefreshableScriptTargetSource ts = new RefreshableScriptTargetSource(this.scriptBeanFactory,
scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
boolean proxyTargetClass = resolveProxyTargetClass(bd);
String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '"
+ language + "'");
}
ts.setRefreshCheckDelay(refreshCheckDelay);
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
}
if (isFactoryBean) {
scriptedObjectBeanName = BeanFactory.FACTORY_BEAN_PREFIX + scriptedObjectBeanName;
}
return this.scriptBeanFactory.getBean(scriptedObjectBeanName);
}
开发者ID:ilivoo,项目名称:game,代码行数:51,代码来源:MyScriptFactoryPostProcessor.java
示例9: postProcessBeforeInstantiation
import org.springframework.scripting.ScriptFactory; //导入依赖的package包/类
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
return null;
}
BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
boolean isFactoryBean = false;
try {
Class<?> scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
// Returned type may be null if the factory is unable to determine the type.
if (scriptedObjectType != null) {
isFactoryBean = FactoryBean.class.isAssignableFrom(scriptedObjectType);
}
}
catch (Exception ex) {
throw new BeanCreationException(beanName,
"Could not determine scripted object type for " + scriptFactory, ex);
}
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
if (refreshCheckDelay >= 0) {
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
RefreshableScriptTargetSource ts = new RefreshableScriptTargetSource(this.scriptBeanFactory,
scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
boolean proxyTargetClass = resolveProxyTargetClass(bd);
String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
language + "'");
}
ts.setRefreshCheckDelay(refreshCheckDelay);
return createRefreshableProxy(ts, interfaces, proxyTargetClass);
}
if (isFactoryBean) {
scriptedObjectBeanName = BeanFactory.FACTORY_BEAN_PREFIX + scriptedObjectBeanName;
}
return this.scriptBeanFactory.getBean(scriptedObjectBeanName);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:49,代码来源:ScriptFactoryPostProcessor.java
注:本文中的org.springframework.scripting.ScriptFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论