本文整理匯總了Java中org.springframework.context.support.GenericApplicationContext.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericApplicationContext.refresh方法的具體用法?Java GenericApplicationContext.refresh怎麽用?Java GenericApplicationContext.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.GenericApplicationContext
的用法示例。
在下文中一共展示了GenericApplicationContext.refresh方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例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[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();
}
示例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 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();
}
示例5: 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);
}
示例6: 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);
}
示例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: testAutowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testAutowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition() {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
// qualifier added, and non-default value specified
person1.addQualifier(new AutowireCandidateQualifier(TestQualifierWithDefaultValue.class, "not the default"));
ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
cavs2.addGenericArgumentValue(MARK);
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
context.registerBeanDefinition(JUERGEN, person1);
context.registerBeanDefinition(MARK, person2);
context.registerBeanDefinition("autowired",
new RootBeanDefinition(QualifiedFieldWithDefaultValueTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
try {
context.refresh();
fail("expected BeanCreationException");
}
catch (BeanCreationException e) {
assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
assertEquals("autowired", e.getBeanName());
}
}
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:26,代碼來源:QualifierAnnotationAutowireContextTests.java
示例9: testAutowiredFieldResolvesQualifiedCandidate
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testAutowiredFieldResolvesQualifiedCandidate() {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
cavs1.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
person1.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
cavs2.addGenericArgumentValue(MARK);
RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
context.registerBeanDefinition(JUERGEN, person1);
context.registerBeanDefinition(MARK, person2);
context.registerBeanDefinition("autowired",
new RootBeanDefinition(QualifiedFieldTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
context.refresh();
QualifiedFieldTestBean bean = (QualifiedFieldTestBean) context.getBean("autowired");
assertEquals(JUERGEN, bean.getPerson().getName());
}
示例10: testSimpleScanWithDefaultFiltersAndPrimaryLazyBean
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testSimpleScanWithDefaultFiltersAndPrimaryLazyBean() {
GenericApplicationContext context = new GenericApplicationContext();
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
scanner.scan(BASE_PACKAGE);
scanner.scan("org.springframework.context.annotation5");
assertTrue(context.containsBean("serviceInvocationCounter"));
assertTrue(context.containsBean("fooServiceImpl"));
assertTrue(context.containsBean("stubFooDao"));
assertTrue(context.containsBean("myNamedComponent"));
assertTrue(context.containsBean("myNamedDao"));
assertTrue(context.containsBean("otherFooDao"));
context.refresh();
assertFalse(context.getBeanFactory().containsSingleton("otherFooDao"));
assertFalse(context.getBeanFactory().containsSingleton("fooServiceImpl"));
FooServiceImpl service = context.getBean("fooServiceImpl", FooServiceImpl.class);
assertTrue(context.getBeanFactory().containsSingleton("otherFooDao"));
assertEquals("other", service.foo(1));
}
示例11: testViewScopedClass
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testViewScopedClass() {
GenericApplicationContext acx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);
acx.registerBeanDefinition("viewScopedClass", new AnnotatedGenericBeanDefinition(
new StandardAnnotationMetadata(ViewScopedClass.class)));
acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(
ScopedBeansConfiguration.class));
acx.addBeanFactoryPostProcessor(JsfScopeAnnotationsAutoConfiguration.jsfScopeAnnotationsConfigurer(acx.getEnvironment()));
acx.addBeanFactoryPostProcessor(CdiScopeAnnotationsAutoConfiguration.cdiScopeAnnotationsConfigurer(acx.getEnvironment()));
acx.refresh();
assertThat(acx.getBeanDefinition("viewScopedClass").getScope())
.isEqualTo(ViewScope.SCOPE_VIEW);
assertThat(acx.getBeanDefinition("viewScopedBean").getScope())
.isEqualTo(ViewScope.SCOPE_VIEW);
}
開發者ID:joinfaces,項目名稱:joinfaces,代碼行數:19,代碼來源:JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java
示例12: testChangeScriptWithRefreshableBeanFunctionality
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.registerBeanDefinition(PROCESSOR_BEAN_NAME, processorBeanDefinition);
ctx.registerBeanDefinition(MESSENGER_BEAN_NAME, scriptedBeanDefinition);
ctx.refresh();
Messenger messenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
assertEquals(MESSAGE_TEXT, messenger.getMessage());
// cool; now let's change the script and check the refresh behaviour...
pauseToLetRefreshDelayKickIn(DEFAULT_SECONDS_TO_PAUSE);
StaticScriptSource source = getScriptSource(ctx);
source.setScript(CHANGED_SCRIPT);
Messenger refreshedMessenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
// the updated script surrounds the message in quotes before returning...
assertEquals(EXPECTED_CHANGED_MESSAGE_TEXT, refreshedMessenger.getMessage());
}
示例13: testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person = new RootBeanDefinition(QualifiedPerson.class, cavs, null);
ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
cavs2.addGenericArgumentValue(MARK);
RootBeanDefinition person2 = new RootBeanDefinition(DefaultValueQualifiedPerson.class, cavs2, null);
context.registerBeanDefinition(JUERGEN, person);
context.registerBeanDefinition(MARK, person2);
context.registerBeanDefinition("autowired",
new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
context.refresh();
QualifiedMethodParameterTestBean bean =
(QualifiedMethodParameterTestBean) context.getBean("autowired");
assertEquals(JUERGEN, bean.getPerson().getName());
}
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:20,代碼來源:QualifierAnnotationAutowireContextTests.java
示例14: testPublicPersistenceUnitSetterWithUnitIdentifiedThroughBeanName
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testPublicPersistenceUnitSetterWithUnitIdentifiedThroughBeanName() {
EntityManagerFactory mockEmf2 = mock(EntityManagerFactory.class);
GenericApplicationContext gac = new GenericApplicationContext();
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory2", mockEmf2);
gac.registerAlias("entityManagerFactory2", "Person");
RootBeanDefinition processorDef = new RootBeanDefinition(PersistenceAnnotationBeanPostProcessor.class);
processorDef.getPropertyValues().add("defaultPersistenceUnitName", "entityManagerFactory");
gac.registerBeanDefinition("annotationProcessor", processorDef);
gac.registerBeanDefinition(DefaultPublicPersistenceUnitSetter.class.getName(),
new RootBeanDefinition(DefaultPublicPersistenceUnitSetter.class));
gac.registerBeanDefinition(DefaultPublicPersistenceUnitSetterNamedPerson.class.getName(),
new RootBeanDefinition(DefaultPublicPersistenceUnitSetterNamedPerson.class));
gac.refresh();
DefaultPublicPersistenceUnitSetter bean = (DefaultPublicPersistenceUnitSetter)
gac.getBean(DefaultPublicPersistenceUnitSetter.class.getName());
DefaultPublicPersistenceUnitSetterNamedPerson bean2 = (DefaultPublicPersistenceUnitSetterNamedPerson)
gac.getBean(DefaultPublicPersistenceUnitSetterNamedPerson.class.getName());
assertSame(mockEmf, bean.emf);
assertSame(mockEmf2, bean2.emf);
}
示例15: testAutowiredFieldWithSingleNonQualifiedCandidate
import org.springframework.context.support.GenericApplicationContext; //導入方法依賴的package包/類
@Test
public void testAutowiredFieldWithSingleNonQualifiedCandidate() {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addGenericArgumentValue(JUERGEN);
RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
context.registerBeanDefinition(JUERGEN, person);
context.registerBeanDefinition("autowired",
new RootBeanDefinition(QualifiedFieldTestBean.class));
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
try {
context.refresh();
fail("expected BeanCreationException");
}
catch (BeanCreationException e) {
assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
assertEquals("autowired", e.getBeanName());
}
}