本文整理汇总了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;未经允许,请勿转载。 |
请发表评论