本文整理匯總了Java中org.springframework.context.support.GenericApplicationContext類的典型用法代碼示例。如果您正苦於以下問題:Java GenericApplicationContext類的具體用法?Java GenericApplicationContext怎麽用?Java GenericApplicationContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GenericApplicationContext類屬於org.springframework.context.support包,在下文中一共展示了GenericApplicationContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
BundleContext bundleContext = new MockBundleContext() {
// service reference already registered
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
return new ServiceReference[0];
}
};
appContext = new GenericApplicationContext();
appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
appContext.setClassLoader(getClass().getClassLoader());
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
// reader.setEventListener(this.listener);
reader.loadBeanDefinitions(new ClassPathResource("osgiReferenceNestedBeans.xml", getClass()));
appContext.refresh();
}
示例2: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
BundleContext bundleContext = new MockBundleContext() {
// service reference already registered
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
return new ServiceReference[] { new MockServiceReference(new String[] { Serializable.class.getName() }) };
}
};
appContext = new GenericApplicationContext();
appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
appContext.setClassLoader(getClass().getClassLoader());
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
reader.loadBeanDefinitions(new ClassPathResource("osgiDefaults.xml", getClass()));
appContext.refresh();
}
示例3: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
applicationContext = new GenericApplicationContext();
applicationContext.setClassLoader(getClass().getClassLoader());
applicationContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
applicationContext.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
}
});
reader = new XmlBeanDefinitionReader(applicationContext);
reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
reader.loadBeanDefinitions(new ClassPathResource(getConfig(), getClass()));
applicationContext.refresh();
blueprintContainer = new SpringBlueprintContainer(applicationContext);
}
示例4: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
context = new GenericApplicationContext();
context.setClassLoader(getClass().getClassLoader());
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
}
});
reader = new XmlBeanDefinitionReader(context);
reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
blueprintContainer = new SpringBlueprintContainer(context);
}
示例5: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
BundleContext bundleContext = new MockBundleContext() {
// service reference already registered
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
}
};
context = new GenericApplicationContext();
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
context.setClassLoader(getClass().getClassLoader());
reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
}
示例6: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
context = new GenericApplicationContext();
context.setClassLoader(getClass().getClassLoader());
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
SpringBlueprintConverterService converterService =
new SpringBlueprintConverterService(null, context.getBeanFactory());
converterService.add(new GenericConverter());
context.getBeanFactory().setConversionService(converterService);
reader = new XmlBeanDefinitionReader(context);
reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
blueprintContainer = new SpringBlueprintContainer(context);
}
示例7: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
context = new GenericApplicationContext();
context.setClassLoader(getClass().getClassLoader());
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
beanFactory.registerSingleton("blueprintContainer",
new SpringBlueprintContainer(context));
}
});
reader = new XmlBeanDefinitionReader(context);
reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
blueprintContainer = new SpringBlueprintContainer(context);
}
示例8: setUp
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
context = new GenericApplicationContext();
context.setClassLoader(getClass().getClassLoader());
context.getBeanFactory().setConversionService(
new SpringBlueprintConverterService(null, context.getBeanFactory()));
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
reader = new XmlBeanDefinitionReader(context);
reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
blueprintContainer = new SpringBlueprintContainer(context);
}
示例9: testCamelProducer
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
@Test
public void testCamelProducer() throws Exception {
// Starting Spring context.
try (GenericApplicationContext context = new AnnotationConfigApplicationContext(ExampleConfiguration.class)) {
context.start();
// Sending Camel message.
CamelContext camel = context.getBean(CamelContext.class);
ProducerTemplate producerTemplate = camel.createProducerTemplate();
producerTemplate.sendBody("direct:start", "Send me to the Sponge");
// Waiting for the engine to process an event.
Engine engine = context.getBean(Engine.class);
await().atMost(60, TimeUnit.SECONDS)
.until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "sentCamelMessage").get());
assertFalse(engine.isError());
context.stop();
}
}
示例10: KinesisTestBinder
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
public KinesisTestBinder(AmazonKinesisAsync amazonKinesis,
KinesisBinderConfigurationProperties kinesisBinderConfigurationProperties) {
this.amazonKinesis = amazonKinesis;
KinesisStreamProvisioner provisioningProvider = new KinesisStreamProvisioner(amazonKinesis,
kinesisBinderConfigurationProperties);
KinesisMessageChannelBinder binder = new KinesisMessageChannelBinder(amazonKinesis,
kinesisBinderConfigurationProperties, provisioningProvider);
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
binder.setApplicationContext(context);
setBinder(binder);
}
示例11: buildAppContext
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
public static ApplicationContext buildAppContext(ApplicationContext parent, Stream<TestBean> beans, Collection<BeanFactoryPostProcessor> postProcessors) {
final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
final GenericApplicationContext applicationContext = new GenericApplicationContext(beanFactory, parent);
postProcessors.forEach(applicationContext::addBeanFactoryPostProcessor);
beans.forEach(entry -> {
final String factoryBean = entry.getName() + "_factory";
beanFactory.registerSingleton(factoryBean, (Supplier<Object>) entry::getBean);
beanFactory.registerBeanDefinition(entry.getName(), BeanDefinitionBuilder
.rootBeanDefinition(entry.getBean() != null ? entry.getBean().getClass() : Object.class)
.setFactoryMethodOnBean("get", factoryBean)
.getBeanDefinition());
});
applicationContext.refresh();
return applicationContext;
}
示例12: registerCommonFunctionsToContext
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
private void registerCommonFunctionsToContext(GenericApplicationContext appcontext) {
DefaultListableBeanFactory beanFactory = appcontext.getDefaultListableBeanFactory();
beanFactory.registerSingleton("camera", getCamera());
beanFactory.registerSingleton("settingsManager", settingsManager);
beanFactory.registerSingleton("renderManager", renderManager);
beanFactory.registerSingleton("application", this);
beanFactory.registerSingleton("rootNode", rootNode);
beanFactory.registerSingleton("assetManager", getAssetManager());
beanFactory.registerSingleton("inputManager", getInputManager());
beanFactory.registerSingleton("flyByCamera", getFlyByCamera());
beanFactory.registerSingleton("audioRenderer", getAudioRenderer());
beanFactory.registerSingleton("guiViewPort", getGuiViewPort());
beanFactory.registerSingleton("listener", listener);
beanFactory.registerSingleton("planeRegistry", new PlaneRegistryLoader(settingsManager.assetDirectory()).planeRegistry());
OptionsManager optionsManager = new OptionsManager(APP_ROOT);
beanFactory.registerSingleton("options",optionsManager.loadOptionsFromFileSystem());
beanFactory.registerSingleton("optionsManager",optionsManager);
}
示例13: setup
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
@Before
public void setup() throws Exception {
@SuppressWarnings("resource")
GenericApplicationContext cxt = new GenericApplicationContext();
cxt.refresh();
this.resolver = new HeaderMethodArgumentResolver(new DefaultConversionService(), cxt.getBeanFactory());
Method method = getClass().getDeclaredMethod("handleMessage",
String.class, String.class, String.class, String.class, String.class);
this.paramRequired = new SynthesizingMethodParameter(method, 0);
this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 1);
this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
this.paramNotAnnotated = new SynthesizingMethodParameter(method, 3);
this.paramNativeHeader = new SynthesizingMethodParameter(method, 4);
this.paramRequired.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
GenericTypeResolver.resolveParameterType(this.paramRequired, HeaderMethodArgumentResolver.class);
}
示例14: testAutowiredFieldResolvesWithMultipleQualifierValues
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
@Test
public void testAutowiredFieldResolvesWithMultipleQualifierValues() {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(TestQualifierWithMultipleAttributes.class);
qualifier.setAttribute("number", 456);
person1.addQualifier(qualifier);
ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
cavs2.addGenericArgumentValue(MARK);
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
AutowireCandidateQualifier qualifier2 = new AutowireCandidateQualifier(TestQualifierWithMultipleAttributes.class);
qualifier2.setAttribute("number", 123);
person2.addQualifier(qualifier2);
context.registerBeanDefinition(JUERGEN, person1);
context.registerBeanDefinition(MARK, person2);
context.registerBeanDefinition("autowired",
new RootBeanDefinition(QualifiedFieldWithMultipleAttributesTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
context.refresh();
QualifiedFieldWithMultipleAttributesTestBean bean =
(QualifiedFieldWithMultipleAttributesTestBean) context.getBean("autowired");
assertEquals(MARK, bean.getPerson().getName());
}
示例15: asyncMethodsWithQualifierThroughInterface
import org.springframework.context.support.GenericApplicationContext; //導入依賴的package包/類
@Test
public void asyncMethodsWithQualifierThroughInterface() throws Exception {
originalThreadName = Thread.currentThread().getName();
GenericApplicationContext context = new GenericApplicationContext();
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(SimpleAsyncMethodWithQualifierBean.class));
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
context.registerBeanDefinition("e0", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
context.registerBeanDefinition("e1", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
context.registerBeanDefinition("e2", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
context.refresh();
SimpleInterface asyncTest = context.getBean("asyncTest", SimpleInterface.class);
asyncTest.doNothing(5);
asyncTest.doSomething(10);
Future<String> future = asyncTest.returnSomething(20);
assertEquals("20", future.get());
Future<String> future2 = asyncTest.returnSomething2(30);
assertEquals("30", future2.get());
}