本文整理汇总了Java中org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.postProcessBeanFactory方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyPlaceholderConfigurer.postProcessBeanFactory方法的具体用法?Java PropertyPlaceholderConfigurer.postProcessBeanFactory怎么用?Java PropertyPlaceholderConfigurer.postProcessBeanFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
的用法示例。
在下文中一共展示了PropertyPlaceholderConfigurer.postProcessBeanFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IdentifiersNAServiceImpl
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public IdentifiersNAServiceImpl() throws RemoteException {
super();
try {
String naConfigurationFile = getConfiguration().getNaConfigurationFile();
String naProperties = getConfiguration().getNaPropertiesFile();
FileSystemResource naConfResource = new FileSystemResource(naConfigurationFile);
FileSystemResource naPropertiesResource = new FileSystemResource(naProperties);
XmlBeanFactory factory = new XmlBeanFactory(naConfResource);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(naPropertiesResource);
cfg.postProcessBeanFactory(factory);
this.namingAuthority = (MaintainerNamingAuthority) factory.getBean(NA_BEAN_NAME,
MaintainerNamingAuthority.class);
}
catch (Exception e) {
String message = "Problem inititializing NamingAuthority while loading configuration:" + e.getMessage();
LOG.error(message, e);
throw new RemoteException(message, e);
}
}
示例2: GlobalModelExchangeImpl
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public GlobalModelExchangeImpl() throws RemoteException {
super();
try {
String gmeConfigurationFile = getConfiguration().getGmeConfigurationFile();
String gmeProperties = getConfiguration().getGmePropertiesFile();
FileSystemResource gmeConfResource = new FileSystemResource(gmeConfigurationFile);
FileSystemResource gmePropertiesResource = new FileSystemResource(gmeProperties);
XmlBeanFactory factory = new XmlBeanFactory(gmeConfResource);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(gmePropertiesResource);
cfg.postProcessBeanFactory(factory);
this.gme = (GME) factory.getBean(GME_BEAN_NAME, GME.class);
} catch (Exception e) {
String message = "Problem inititializing GME while loading configuration:" + e.getMessage();
LOG.error(message, e);
throw new RemoteException(message, e);
}
}
示例3: CredentialDelegationServiceImpl
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public CredentialDelegationServiceImpl() throws RemoteException {
super();
try {
this.log = LogFactory.getLog(this.getClass().getName());
String conf = this.getConfiguration().getCdsConfiguration();
String properties = this.getConfiguration().getCdsProperties();
FileSystemResource fsr = new FileSystemResource(conf);
XmlBeanFactory factory = new XmlBeanFactory(fsr);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new FileSystemResource(properties));
cfg.postProcessBeanFactory(factory);
Database db = (Database) factory
.getBean(ConfigurationConstants.DATABASE_CONFIGURATION_BEAN);
db.createDatabaseIfNeeded();
cds = (DelegationManager) factory
.getBean(ConfigurationConstants.CDS_BEAN);
home = (DelegatedCredentialResourceHome) getDelegatedCredentialResourceHome();
home.setCDS(cds);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw Errors.getInternalFault(
"Error initializing the Credential Delegation Service.", e);
}
}
示例4: IdentifiersNAServiceImpl
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public IdentifiersNAServiceImpl() throws RemoteException {
super();
try {
String naConfigurationFile = getConfiguration().getNaConfigurationFile();
String naProperties = getConfiguration().getNaPropertiesFile();
FileSystemResource naConfResource = new FileSystemResource(naConfigurationFile);
FileSystemResource naPropertiesResource = new FileSystemResource(naProperties);
XmlBeanFactory factory = new XmlBeanFactory(naConfResource);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(naPropertiesResource);
cfg.postProcessBeanFactory(factory);
this.namingAuthority = (MaintainerNamingAuthority) factory.getBean(NA_BEAN_NAME, MaintainerNamingAuthority.class);
} catch (Exception e) {
String message = "Problem inititializing NamingAuthority while loading configuration:" + e.getMessage();
LOG.error(message, e);
throw new RemoteException(message, e);
}
}
示例5: testResourceInjectionWithResolvableDependencyType
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testResourceInjectionWithResolvableDependencyType() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
bpp.setBeanFactory(bf);
bf.addBeanPostProcessor(bpp);
RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
abd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("annotatedBean", abd);
RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class);
tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bf.registerBeanDefinition("testBean4", tbd);
bf.registerResolvableDependency(BeanFactory.class, bf);
bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return new NestedTestBean();
}
});
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean4");
ppc.setProperties(props);
ppc.postProcessBeanFactory(bf);
ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
INestedTestBean tb = bean.getTestBean6();
assertNotNull(tb);
ExtendedResourceInjectionBean anotherBean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
assertNotSame(anotherBean, bean);
assertNotSame(anotherBean.getTestBean6(), tb);
String[] depBeans = bf.getDependenciesForBean("annotatedBean");
assertEquals(1, depBeans.length);
assertEquals("testBean4", depBeans[0]);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:CommonAnnotationBeanPostProcessorTests.java
示例6: iocStart
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public static void iocStart() {
// BeanFactory方式启动
ConfigurableListableBeanFactory beanFactory = new XmlBeanFactory(
new ClassPathResource("spring.xml"));
// 读取外部properties文件属性值填充xml中的bean,property
PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setLocation(new ClassPathResource(
"config.properties"));
// 应用postProcessBeanFactory
propertyPlaceholderConfigurer.postProcessBeanFactory(beanFactory);
// 读取外部properties文件,覆盖xml中bean指定的property值
PropertyOverrideConfigurer propertyOverrideConfigurer = new PropertyOverrideConfigurer();
propertyOverrideConfigurer.setLocation(new ClassPathResource(
"spring-adjustment.properties"));
propertyOverrideConfigurer.postProcessBeanFactory(beanFactory);
// CustomEditorConfigurer,对bean的property值,做类型转换支持
CustomEditorConfigurer customEditorConfigurer = new CustomEditorConfigurer();
Map customEditors = new HashMap();
customEditors.put(Date.class, new DatePropertyEditor());
customEditorConfigurer.setCustomEditors(customEditors);
customEditorConfigurer.postProcessBeanFactory(beanFactory);
FXNewsProvider newsProvider = (FXNewsProvider) beanFactory
.getBean("newsProvider");
System.out.println(newsProvider.getClientId());
System.out.println(newsProvider.getBaseUrl());
System.out.println(newsProvider.getAddDate().toLocaleString());
}
示例7: testProperties
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testProperties() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan(TestSpringInit.class.getPackage().getName());
PropertyPlaceholderConfigurer config = new PropertyPlaceholderConfigurer();
config.setProperties(props);
config.postProcessBeanFactory(ctx.getDefaultListableBeanFactory());
ctx.refresh();
TestBean b = ctx.getBean(TestBean.class);
assertEquals("hello", b.getText());
assertEquals(propsFile.getAbsolutePath(), b.getFilename());
ctx.close();
}
示例8: BeanUtils
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public BeanUtils(AbstractResource conf,
AbstractResource properties) throws Exception {
this.factory = new XmlBeanFactory(conf);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(properties);
cfg.postProcessBeanFactory(factory);
}
示例9: loadConfiguration
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public static XmlBeanFactory loadConfiguration() throws Exception {
ClassPathResource cpr = new ClassPathResource(
Constants.CDS_CONFIGURATION);
XmlBeanFactory factory = new XmlBeanFactory(cpr);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new ClassPathResource(Constants.CDS_PROPERTIES));
cfg.postProcessBeanFactory(factory);
return factory;
}
示例10: loadConfiguration
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public static XmlBeanFactory loadConfiguration() throws Exception {
ClassPathResource cpr = new ClassPathResource("event-manager.xml");
XmlBeanFactory factory = new XmlBeanFactory(cpr);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new ClassPathResource("events.properties"));
cfg.postProcessBeanFactory(factory);
return factory;
}
示例11: SpringUtils
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public SpringUtils(AbstractResource conf, Properties properties) {
this.context = new XmlBeanFactory(conf);
if (properties != null) {
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setProperties(properties);
cfg.postProcessBeanFactory(context);
}
}
示例12: testExtendedResourceInjection
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testExtendedResourceInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
bpp.setBeanFactory(bf);
bf.addBeanPostProcessor(bpp);
bf.registerResolvableDependency(BeanFactory.class, bf);
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean3");
ppc.setProperties(props);
ppc.postProcessBeanFactory(bf);
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ExtendedResourceInjectionBean.class));
bf.registerBeanDefinition("annotatedBean2", new RootBeanDefinition(NamedResourceInjectionBean.class));
bf.registerBeanDefinition("annotatedBean3", new RootBeanDefinition(ConvertedResourceInjectionBean.class));
TestBean tb = new TestBean();
bf.registerSingleton("testBean", tb);
TestBean tb2 = new TestBean();
bf.registerSingleton("testBean2", tb2);
TestBean tb3 = new TestBean();
bf.registerSingleton("testBean3", tb3);
TestBean tb4 = new TestBean();
bf.registerSingleton("testBean4", tb4);
NestedTestBean tb6 = new NestedTestBean();
bf.registerSingleton("value", "5");
bf.registerSingleton("xy", tb6);
bf.registerAlias("xy", "testBean9");
ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
assertTrue(bean.initCalled);
assertTrue(bean.init2Called);
assertSame(tb, bean.getTestBean());
assertSame(tb2, bean.getTestBean2());
assertSame(tb4, bean.getTestBean3());
assertSame(tb3, bean.getTestBean4());
assertSame(tb6, bean.testBean5);
assertSame(tb6, bean.testBean6);
assertSame(bf, bean.beanFactory);
NamedResourceInjectionBean bean2 = (NamedResourceInjectionBean) bf.getBean("annotatedBean2");
assertSame(tb6, bean2.testBean);
ConvertedResourceInjectionBean bean3 = (ConvertedResourceInjectionBean) bf.getBean("annotatedBean3");
assertSame(5, bean3.value);
bf.destroySingletons();
assertTrue(bean.destroyCalled);
assertTrue(bean.destroy2Called);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:52,代码来源:CommonAnnotationBeanPostProcessorTests.java
示例13: testExtendedResourceInjectionWithOverriding
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
@Test
public void testExtendedResourceInjectionWithOverriding() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
bpp.setBeanFactory(bf);
bf.addBeanPostProcessor(bpp);
bf.registerResolvableDependency(BeanFactory.class, bf);
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean3");
ppc.setProperties(props);
ppc.postProcessBeanFactory(bf);
RootBeanDefinition annotatedBd = new RootBeanDefinition(ExtendedResourceInjectionBean.class);
TestBean tb5 = new TestBean();
annotatedBd.getPropertyValues().add("testBean2", tb5);
bf.registerBeanDefinition("annotatedBean", annotatedBd);
bf.registerBeanDefinition("annotatedBean2", new RootBeanDefinition(NamedResourceInjectionBean.class));
TestBean tb = new TestBean();
bf.registerSingleton("testBean", tb);
TestBean tb2 = new TestBean();
bf.registerSingleton("testBean2", tb2);
TestBean tb3 = new TestBean();
bf.registerSingleton("testBean3", tb3);
TestBean tb4 = new TestBean();
bf.registerSingleton("testBean4", tb4);
NestedTestBean tb6 = new NestedTestBean();
bf.registerSingleton("xy", tb6);
ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean");
assertTrue(bean.initCalled);
assertTrue(bean.init2Called);
assertSame(tb, bean.getTestBean());
assertSame(tb5, bean.getTestBean2());
assertSame(tb4, bean.getTestBean3());
assertSame(tb3, bean.getTestBean4());
assertSame(tb6, bean.testBean5);
assertSame(tb6, bean.testBean6);
assertSame(bf, bean.beanFactory);
try {
bf.getBean("annotatedBean2");
}
catch (BeanCreationException ex) {
assertTrue(ex.getRootCause() instanceof NoSuchBeanDefinitionException);
NoSuchBeanDefinitionException innerEx = (NoSuchBeanDefinitionException) ex.getRootCause();
assertEquals("testBean9", innerEx.getBeanName());
}
bf.destroySingletons();
assertTrue(bean.destroyCalled);
assertTrue(bean.destroy2Called);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:55,代码来源:CommonAnnotationBeanPostProcessorTests.java
示例14: addAdmin
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public static void addAdmin(String naConfigurationFile,
String naProperties, String adminUser)
throws
InvalidIdentifierException,
URISyntaxException,
NamingAuthorityConfigurationException,
NamingAuthoritySecurityException, InvalidIdentifierValuesException {
FileSystemResource naConfResource = new FileSystemResource(naConfigurationFile);
FileSystemResource naPropertiesResource = new FileSystemResource(naProperties);
XmlBeanFactory factory = new XmlBeanFactory(naConfResource);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(naPropertiesResource);
cfg.postProcessBeanFactory(factory);
NamingAuthorityImpl na = (NamingAuthorityImpl) factory.getBean("NamingAuthority", MaintainerNamingAuthority.class);
na.getIdentifierDao().createInitialAdministrator(adminUser);
// KeyData kd = na.getKeyData(null, na.getSystemIdentifier(), Keys.ADMIN_USERS);
// if (kd == null) {
// System.err.println("KD IS NULL");
// kd = new KeyData();
// }
//
// List<String> values = kd.getValues();
// if (values == null) {
// System.err.println("VALUES IS NULL");
// values = new ArrayList<String>();
// }
//
// if (values.contains(adminUser)) {
// throw new NamingAuthorityConfigurationException("Provided identity [" + adminUser + "] is already an administrator");
// }
//
// values.add(adminUser);
//
// IdentifierValues ivalues = new IdentifierValues();
// ivalues.put(Keys.ADMIN_USERS, kd);
// na.replaceKeys(null, na.getSystemIdentifier(), ivalues);
}
示例15: BeanUtils
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; //导入方法依赖的package包/类
public BeanUtils(AbstractResource dorianConf, AbstractResource dorianProperties) throws DorianInternalFault {
this.factory = new XmlBeanFactory(dorianConf);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(dorianProperties);
cfg.postProcessBeanFactory(factory);
}