• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScriptFactoryPostProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.scripting.support.ScriptFactoryPostProcessor的典型用法代码示例。如果您正苦于以下问题:Java ScriptFactoryPostProcessor类的具体用法?Java ScriptFactoryPostProcessor怎么用?Java ScriptFactoryPostProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScriptFactoryPostProcessor类属于org.springframework.scripting.support包,在下文中一共展示了ScriptFactoryPostProcessor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testScriptedClassThatDoesNotHaveANoArgCtor

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
@Test
public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
	ScriptSource script = mock(ScriptSource.class);
	final String badScript = "class Foo { public Foo(String foo) {}}";
	given(script.getScriptAsString()).willReturn(badScript);
	given(script.suggestedClassName()).willReturn("someName");
	GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
			+ badScript);
	try {
		factory.getScriptedObject(script);
		fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
	}
	catch (ScriptCompilationException expected) {
		assertTrue(expected.contains(InstantiationException.class));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:GroovyScriptFactoryTests.java


示例2: testScriptedClassThatHasNoPublicNoArgCtor

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
@Test
public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
	ScriptSource script = mock(ScriptSource.class);
	final String badScript = "class Foo { protected Foo() {}}";
	given(script.getScriptAsString()).willReturn(badScript);
	given(script.suggestedClassName()).willReturn("someName");
	GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
			+ badScript);
	try {
		factory.getScriptedObject(script);
		fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
	}
	catch (ScriptCompilationException expected) {
		assertTrue(expected.contains(IllegalAccessException.class));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:GroovyScriptFactoryTests.java


示例3: scriptThatCompilesButIsJustPlainBad

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
@Test
public void scriptThatCompilesButIsJustPlainBad() throws Exception {
	ScriptSource script = mock(ScriptSource.class);
	final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
	given(script.getScriptAsString()).willReturn(badScript);
	given(script.isModified()).willReturn(true);
	BshScriptFactory factory = new BshScriptFactory(
			ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript, Messenger.class);
	try {
		Messenger messenger = (Messenger) factory.getScriptedObject(script, Messenger.class);
		messenger.getMessage();
		fail("Must have thrown a BshScriptUtils.BshExecutionException.");
	}
	catch (BshScriptUtils.BshExecutionException expected) {
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:BshScriptFactoryTests.java


示例4: testScriptThatCompilesButIsJustPlainBad

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
public void testScriptThatCompilesButIsJustPlainBad() throws Exception {
	ScriptSource script = mock(ScriptSource.class);
	final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
	given(script.getScriptAsString()).willReturn(badScript);
	given(script.isModified()).willReturn(true);
	BshScriptFactory factory = new BshScriptFactory(
			ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript,
			new Class<?>[] {Messenger.class});
	try {
		Messenger messenger = (Messenger) factory.getScriptedObject(script, new Class<?>[]{Messenger.class});
		messenger.getMessage();
		fail("Must have thrown a BshScriptUtils.BshExecutionException.");
	}
	catch (BshScriptUtils.BshExecutionException expected) {
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:BshScriptFactoryTests.java


示例5: createAndRegisterBean

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
private void createAndRegisterBean(BeanDefinitionRegistry registry,
		String beanName,  Class<?>[] interfaces, ResourceScriptSource rs,
		long refreshCheckDelay) {
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setFactoryBeanName(DEFAULT_SCRIPT_FACTORY_NAME + beanName);
	beanDefinition.setFactoryMethodName(DEFAULT_SCRIPT_FACTORY_METHOD_NAME);
	beanDefinition.getConstructorArgumentValues().clear();
	beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, rs);
	beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, interfaces);
	beanDefinition.setAutowireCandidate(true);
	beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	beanDefinition.setAttribute(
			ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, refreshCheckDelay);		
    registry.registerBeanDefinition(beanName,beanDefinition);		

}
 
开发者ID:valliappanr,项目名称:refreshable-beans,代码行数:17,代码来源:SpringContextWrapper.java


示例6: registerScriptFactoryPostProcessorIfNecessary

import org.springframework.scripting.support.ScriptFactoryPostProcessor; //导入依赖的package包/类
/**
 * Register a {@link ScriptFactoryPostProcessor} bean definition in the supplied
 * {@link BeanDefinitionRegistry} if the {@link ScriptFactoryPostProcessor} hasn't
 * already been registered.
 * @param registry the {@link BeanDefinitionRegistry} to register the script processor with
 * @return the {@link ScriptFactoryPostProcessor} bean definition (new or already registered)
 */
public static BeanDefinition registerScriptFactoryPostProcessorIfNecessary(BeanDefinitionRegistry registry) {
	BeanDefinition beanDefinition = null;
	if (registry.containsBeanDefinition(SCRIPT_FACTORY_POST_PROCESSOR_BEAN_NAME)) {
		beanDefinition = registry.getBeanDefinition(SCRIPT_FACTORY_POST_PROCESSOR_BEAN_NAME);
	}
	else {
		beanDefinition = new RootBeanDefinition(ScriptFactoryPostProcessor.class);
		registry.registerBeanDefinition(SCRIPT_FACTORY_POST_PROCESSOR_BEAN_NAME, beanDefinition);
	}
	return beanDefinition;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:LangNamespaceUtils.java



注:本文中的org.springframework.scripting.support.ScriptFactoryPostProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KieScanner类代码示例发布时间:2022-05-22
下一篇:
Java HMacSP800DRBG类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap