本文整理汇总了Java中org.springframework.jndi.support.SimpleJndiBeanFactory类的典型用法代码示例。如果您正苦于以下问题:Java SimpleJndiBeanFactory类的具体用法?Java SimpleJndiBeanFactory怎么用?Java SimpleJndiBeanFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleJndiBeanFactory类属于org.springframework.jndi.support包,在下文中一共展示了SimpleJndiBeanFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testResourceInjectionFromJndi
import org.springframework.jndi.support.SimpleJndiBeanFactory; //导入依赖的package包/类
@Test
public void testResourceInjectionFromJndi() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
SimpleJndiBeanFactory resourceFactory = new SimpleJndiBeanFactory();
ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
TestBean tb = new TestBean();
jndiTemplate.addObject("java:comp/env/testBean", tb);
TestBean tb2 = new TestBean();
jndiTemplate.addObject("java:comp/env/testBean2", tb2);
resourceFactory.setJndiTemplate(jndiTemplate);
bpp.setResourceFactory(resourceFactory);
bf.addBeanPostProcessor(bpp);
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ResourceInjectionBean.class));
ResourceInjectionBean bean = (ResourceInjectionBean) bf.getBean("annotatedBean");
assertTrue(bean.initCalled);
assertTrue(bean.init2Called);
assertSame(tb, bean.getTestBean());
assertSame(tb2, bean.getTestBean2());
bf.destroySingletons();
assertTrue(bean.destroyCalled);
assertTrue(bean.destroy2Called);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:CommonAnnotationBeanPostProcessorTests.java
示例2: makeJNDITrigger
import org.springframework.jndi.support.SimpleJndiBeanFactory; //导入依赖的package包/类
public static BeanFactory makeJNDITrigger ( String jndiUrl ) throws Exception {
SimpleJndiBeanFactory bf = new SimpleJndiBeanFactory();
bf.setShareableResources(jndiUrl);
Reflections.setFieldValue(bf, "logger", new NoOpLog());
Reflections.setFieldValue(bf.getJndiTemplate(), "logger", new NoOpLog());
return bf;
}
开发者ID:mbechler,项目名称:marshalsec,代码行数:8,代码来源:SpringUtil.java
示例3: testJavaPoetResult
import org.springframework.jndi.support.SimpleJndiBeanFactory; //导入依赖的package包/类
@Test
public void testJavaPoetResult() throws Exception{
ScriptProcessor processor = new ScriptProcessor();
CompilationUnit unit = ASTManager.parse("public class Person{}");
ChainConfigImpl dummy = new ChainConfigImpl();
dummy.setConfiguration(new ConfigurationImpl());
dummy.getConfiguration().setBeanFactory(new SimpleJndiBeanFactory());
VisitorContext vc = new VisitorContext(dummy);
processor.setContent(
"import com.squareup.javapoet.*; " +
"import javax.lang.model.element.Modifier; " +
"import org.walkmod.javalang.ASTManager; "+
"MethodSpec main = MethodSpec.methodBuilder(\"main\")\n" +
" .addModifiers(Modifier.PUBLIC, Modifier.STATIC)\n" +
" .returns(void.class)\n" +
" .addParameter(String[].class, \"args\")\n" +
" .addStatement(\"\\$T.out.println(\\$S)\", System.class, node.types[0].name)\n" +
" .build();\n" +
"\n" +
" TypeSpec helloWorld = TypeSpec.classBuilder(node.types[0].name)\n" +
" .addModifiers(Modifier.PUBLIC, Modifier.FINAL)\n" +
" .addMethod(main)\n" +
" .build();\n" +
"\n" +
" JavaFile javaFile = JavaFile.builder(\"com.example.helloworld\", helloWorld)\n" +
" .build();\n" +
"\n" +
" context.addResultNode(ASTManager.parse(javaFile.toString()));");
processor.visit(unit, vc);
Assert.assertNotNull(vc.getResultNodes());
Assert.assertEquals(1, vc.getResultNodes().size());
CompilationUnit newCu = (CompilationUnit)vc.getResultNodes().iterator().next();
Assert.assertEquals("Person", newCu.getTypes().get(0).getName());
}
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:41,代码来源:ScriptWithJavaPoetTest.java
示例4: makeSpringJndiBeanFactory
import org.springframework.jndi.support.SimpleJndiBeanFactory; //导入依赖的package包/类
private static String makeSpringJndiBeanFactory ( String jndiUrl ) {
return writeObject(SimpleJndiBeanFactory.class, Collections.singletonMap("shareableResources", writeArray(quoteString(jndiUrl))));
}
开发者ID:mbechler,项目名称:marshalsec,代码行数:4,代码来源:Jackson.java
注:本文中的org.springframework.jndi.support.SimpleJndiBeanFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论