public Properties getConfig(ConfigurableEnvironment env) throws IOException {
PropertiesFactoryBean config = new PropertiesFactoryBean();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
List<Resource> resouceList = InstanceUtil.newArrayList();
try {
Resource[] resources = resolver.getResources("classpath*:config/*.properties");
for (Resource resource : resources) {
resouceList.add(resource);
}
} catch (Exception e) {
logger.error("", e);
}
config.setLocations(resouceList.toArray(new Resource[]{}));
config.afterPropertiesSet();
return config.getObject();
}
java类org.springframework.beans.factory.config.PropertiesFactoryBean的实例源码
Configs.java 文件源码
项目:iBase4J-Common
阅读 23
收藏 0
点赞 0
评论 0
CdiUtils.java 文件源码
项目:spring-data-snowdrop
阅读 37
收藏 0
点赞 0
评论 0
static NamedQueries findNamedQueries(Class<?> repositoryClass) {
try {
RepositoryConfigurationExtension config = new SnowdropRepositoryConfigExtension();
String location = config.getDefaultNamedQueryLocation();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(repositoryClass.getClassLoader());
ResourceArrayPropertyEditor editor = new ResourceArrayPropertyEditor(resolver, null);
editor.setAsText(location);
Resource[] resources = (Resource[]) editor.getValue();
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setSingleton(false);
pfb.setLocations(resources);
pfb.setFileEncoding("UTF-8");
Properties properties = pfb.getObject();
return new PropertiesBasedNamedQueries(properties);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
AutowireWithExclusionTests.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void byTypeAutowireWithPrimaryInParentFactory() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
AutowireWithExclusionTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void byTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
propsDef.setPrimary(true);
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props3", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
AutowireWithExclusionTests.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void byTypeAutowireWithPrimaryInParentAndChild() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
propsDef.setPrimary(true);
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props3", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
DefaultListableBeanFactoryTests.java 文件源码
项目:spring4-understanding
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void testExpressionInStringArray() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
BeanExpressionResolver beanExpressionResolver = mock(BeanExpressionResolver.class);
when(beanExpressionResolver.evaluate(eq("#{foo}"), Matchers.any(BeanExpressionContext.class)))
.thenReturn("classpath:/org/springframework/beans/factory/xml/util.properties");
bf.setBeanExpressionResolver(beanExpressionResolver);
RootBeanDefinition rbd = new RootBeanDefinition(PropertiesFactoryBean.class);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("locations", new String[]{"#{foo}"});
rbd.setPropertyValues(pvs);
bf.registerBeanDefinition("myProperties", rbd);
Properties properties = (Properties) bf.getBean("myProperties");
assertEquals("bar", properties.getProperty("foo"));
}
QuartzFactory.java 文件源码
项目:api-server-seed
阅读 21
收藏 0
点赞 0
评论 0
public SchedulerFactoryBean build() throws Exception {
SchedulerFactoryBean bean = new SchedulerFactoryBean();
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource(config));
propertiesFactoryBean.afterPropertiesSet();
Properties props = propertiesFactoryBean.getObject();
List<Trigger> triggers = Lists.newArrayList();
List<JobModel> jobList = getJobs(props);
for (JobModel job : jobList) {
if (!job.isEnable()) {
continue;
}
JobDetailFactoryBean detail = createJobDetail(job.getName(), Class.forName(job.getJob()));
CronTriggerFactoryBean trigger = createCronTrigger(job.getName(), detail.getObject(), job.getCorn());
CronTrigger t = trigger.getObject();
triggers.add(t);
}
bean.setTriggers(triggers.toArray(new Trigger[0]));
//bean.afterPropertiesSet();
return bean;
}
CloudConfigSupportConfiguration.java 文件源码
项目:spring-cloud-config-support
阅读 21
收藏 0
点赞 0
评论 0
private Properties loadBackupProperty(String filePath) {
PropertiesFactoryBean propertiesFactory = new PropertiesFactoryBean();
Properties props = new Properties();
try {
FileSystemResource fileSystemResource = new FileSystemResource(filePath);
propertiesFactory.setLocation(fileSystemResource);
propertiesFactory.afterPropertiesSet();
props = propertiesFactory.getObject();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return props;
}
TestProperty.java 文件源码
项目:spring-cloud-config-support
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void testWithPropertiesFile() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
FileSystemResource pathResource = new FileSystemResource("test.properties");
File file = pathResource.getFile();
if (!file.exists()) {
file.createNewFile();
}
System.out.println("pathResource:" + pathResource.getPath());
System.out.println("pathResource:" + pathResource.getFile());
pfb.setLocation(pathResource);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
System.out.println(props.get("a"));
props.setProperty("a", "DDD");
System.out.println(props.get("a"));
FileOutputStream oFile = new FileOutputStream(pathResource.getFile());
props.store(oFile, "Comment");
oFile.close();
file.deleteOnExit();
}
SubsystemWithClassLoaderState.java 文件源码
项目:alfresco-utility
阅读 18
收藏 0
点赞 0
评论 0
protected void populateSubsystemBeanFactory(final ConfigurableListableBeanFactory beanFactory)
{
try
{
// build effective properties
final PropertiesFactoryBean factory = new PropertiesFactoryBean();
factory.setPropertiesArray(new Properties[] { this.fixedConfigProperties, this.runtimeProperties });
factory.afterPropertiesSet();
final Properties subsystemProperties = factory.getObject();
beanFactory.registerSingleton(BEAN_NAME_SUBSYSTEM_PROPERTIES, subsystemProperties);
}
catch (final IOException e)
{
throw new AlfrescoRuntimeException("Error instantiating effective subsystem properties", e);
}
}
PropertyFileConfig.java 文件源码
项目:micro-server
阅读 23
收藏 0
点赞 0
评论 0
@Bean
public Properties propertyFactory() throws IOException {
List<Resource> resources = loadPropertyResource();
PropertiesFactoryBean factory = new PropertiesFactoryBean();
factory.setLocations(resources.toArray(new Resource[resources.size()]));
factory.afterPropertiesSet();
Properties props = factory.getObject();
new ConfigAccessor().get()
.getProperties()
.stream()
.forEach(e -> {
if (props.getProperty(e._1()) == null) {
props.put(e._1(), e._2());
}
});
System.getProperties()
.entrySet()
.forEach(e -> props.put(e.getKey(), e.getValue()));
return props;
}
SSLConfig.java 文件源码
项目:micro-server
阅读 18
收藏 0
点赞 0
评论 0
@Bean
public static SSLProperties sslProperties() throws IOException {
PropertiesFactoryBean factory = new PropertiesFactoryBean();
URL url = SSLConfig.class.getClassLoader().getResource("ssl.properties");
if (url != null) {
Resource reource = new UrlResource(url);
factory.setLocation(reource);
factory.afterPropertiesSet();
Properties properties = factory.getObject();
return SSLProperties.builder()
.keyStoreFile(properties.getProperty(keyStoreFile))
.keyStorePass(properties.getProperty(keyStorePass))
.trustStoreFile(properties.getProperty(trustStoreFile))
.trustStorePass(properties.getProperty(trustStorePass))
.keyStoreType(properties.getProperty(keyStoreType))
.keyStoreProvider(properties.getProperty(keyStoreProvider))
.trustStoreType(properties.getProperty(trustStoreType))
.trustStoreProvider(properties.getProperty(trustStoreProvider))
.clientAuth(properties.getProperty(clientAuth))
.ciphers(properties.getProperty(ciphers))
.protocol(properties.getProperty(protocol)).build();
}
return null;
}
CoreAppConfig.java 文件源码
项目:logsniffer
阅读 23
收藏 0
点赞 0
评论 0
@Bean(name = { BEAN_LOGSNIFFER_PROPS })
@Autowired
public PropertiesFactoryBean logSnifferProperties(final ApplicationContext ctx) throws IOException {
if (ctx.getEnvironment().acceptsProfiles("!" + ContextProvider.PROFILE_NONE_QA)) {
final File qaFile = File.createTempFile("logsniffer", "qa");
qaFile.delete();
final String qaHomeDir = qaFile.getPath();
logger.info("QA mode active, setting random home directory: {}", qaHomeDir);
System.setProperty("logsniffer.home", qaHomeDir);
}
final PathMatchingResourcePatternResolver pathMatcher = new PathMatchingResourcePatternResolver();
Resource[] classPathProperties = pathMatcher.getResources("classpath*:/config/**/logsniffer-*.properties");
final Resource[] metainfProperties = pathMatcher
.getResources("classpath*:/META-INF/**/logsniffer-*.properties");
final PropertiesFactoryBean p = new PropertiesFactoryBean();
for (final Resource r : metainfProperties) {
classPathProperties = (Resource[]) ArrayUtils.add(classPathProperties, r);
}
classPathProperties = (Resource[]) ArrayUtils.add(classPathProperties,
new FileSystemResource(System.getProperty("logsniffer.home") + "/" + LOGSNIFFER_PROPERTIES_FILE));
p.setLocations(classPathProperties);
p.setProperties(System.getProperties());
p.setLocalOverride(true);
p.setIgnoreResourceNotFound(true);
return p;
}
SecurityConfig.java 文件源码
项目:iris
阅读 18
收藏 0
点赞 0
评论 0
@Bean
public InMemoryUserDetailsManager propertyUserDetailsService() throws IOException {
String env = System.getenv(ENVIRONMENT);
if (env == null) {
env = System.getProperty(ENVIRONMENT, "dev");
}
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocations(new ClassPathResource("usercredentials-" + env + ".properties"));
propertiesFactoryBean.afterPropertiesSet();
Properties users = propertiesFactoryBean.getObject();
return new InMemoryUserDetailsManager(users);
}
AutowireWithExclusionTests.java 文件源码
项目:class-guard
阅读 21
收藏 0
点赞 0
评论 0
public void testByTypeAutowireWithPrimaryInParentFactory() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props1", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
AutowireWithExclusionTests.java 文件源码
项目:class-guard
阅读 21
收藏 0
点赞 0
评论 0
public void testByTypeAutowireWithPrimaryOverridingParentFactory() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
propsDef.setPrimary(true);
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props3", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
AutowireWithExclusionTests.java 文件源码
项目:class-guard
阅读 22
收藏 0
点赞 0
评论 0
public void testByTypeAutowireWithPrimaryInParentAndChild() throws Exception {
CountingFactory.reset();
DefaultListableBeanFactory parent = getBeanFactory("autowire-with-exclusion.xml");
parent.getBeanDefinition("props1").setPrimary(true);
parent.preInstantiateSingletons();
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
RootBeanDefinition robDef = new RootBeanDefinition(TestBean.class);
robDef.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE);
robDef.getPropertyValues().add("spouse", new RuntimeBeanReference("sally"));
child.registerBeanDefinition("rob2", robDef);
RootBeanDefinition propsDef = new RootBeanDefinition(PropertiesFactoryBean.class);
propsDef.getPropertyValues().add("properties", "name=props3");
propsDef.setPrimary(true);
child.registerBeanDefinition("props3", propsDef);
TestBean rob = (TestBean) child.getBean("rob2");
assertEquals("props3", rob.getSomeProperties().getProperty("name"));
assertEquals(1, CountingFactory.getFactoryBeanInstanceCount());
}
ChildApplicationContextFactory.java 文件源码
项目:alfresco-repository
阅读 33
收藏 0
点赞 0
评论 0
/**
* Instantiates a new application context state.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
protected ApplicationContextState(boolean allowInitAccess ) throws IOException
{
this.allowInitAccess = allowInitAccess;
// Load the property defaults
PropertiesFactoryBean factory = new PropertiesFactoryBean();
factory.setPropertiesPersister(getPersister());
factory.setLocations(getParent().getResources(
ChildApplicationContextFactory.CLASSPATH_PREFIX + getCategory() + '/' + getTypeName()
+ ChildApplicationContextFactory.PROPERTIES_SUFFIX));
factory.afterPropertiesSet();
this.properties = (Properties) factory.getObject();
}
QuartzSchedulerConfig.java 文件源码
项目:spring-boot-quartz-demo
阅读 17
收藏 0
点赞 0
评论 0
/**
* Configure quartz using properties file
*/
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
SchedulerConfiguration.java 文件源码
项目:sentry
阅读 38
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocations(new FileSystemResource("quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
QuartzConfig.java 文件源码
项目:webcron
阅读 27
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
QuartzSchedulerAutoConfiguration.java 文件源码
项目:spring-boot-starter-quartz
阅读 28
收藏 0
点赞 0
评论 0
private Properties loadConfigLocationProperties(ApplicationContext applicationContext,
QuartzSchedulerProperties properties) throws IOException {
String location = properties.getPropertiesConfigLocation();
if(null == location || location.trim().length() == 0) {
location = QuartzSchedulerProperties.DEFAULT_CONFIG_LOCATION;
LOGGER.debug("using default 'quartz.properties' from classpath: " + location);
} else {
LOGGER.debug("using 'quartz.properties' from location: " + location);
}
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(applicationContext.getResource(location));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
TestContextConfiguration3.java 文件源码
项目:spring-boot-starter-quartz
阅读 21
收藏 0
点赞 0
评论 0
@Bean(name = QuartzSchedulerAutoConfiguration.QUARTZ_PROPERTIES_BEAN_NAME)
public Properties quartzProperties(
@Autowired ApplicationContext applicationContext,
@Autowired QuartzSchedulerProperties properties) throws IOException {
System.out.println("my overridden quartz.properties loading");
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(applicationContext.getResource("classpath:overriddenQuartzScheduler.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
WebMvcApplicationConfig.java 文件源码
项目:backbone
阅读 24
收藏 0
点赞 0
评论 0
@Bean(name = Global.BEAN_NAME_ROOT_PROPS)
public PropertiesFactoryBean getPropertiesFactoryBean() {
PropertiesFactoryBean bean = new PropertiesFactoryBean();
Resource[] resources = getPropsResources(resourceLoader);
bean.setLocations(resources);
return bean;
}
SchedulerConfig.java 文件源码
项目:springboot-quartz
阅读 28
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
QuartzConfig.java 文件源码
项目:oma-riista-web
阅读 22
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() throws IOException {
final PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/configuration/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
UtilNamespaceHandlerTests.java 文件源码
项目:spring4-understanding
阅读 26
收藏 0
点赞 0
评论 0
@Test
public void testEvents() {
ComponentDefinition propertiesComponent = this.listener.getComponentDefinition("myProperties");
assertNotNull("Event for 'myProperties' not sent", propertiesComponent);
AbstractBeanDefinition propertiesBean = (AbstractBeanDefinition) propertiesComponent.getBeanDefinitions()[0];
assertEquals("Incorrect BeanDefinition", PropertiesFactoryBean.class, propertiesBean.getBeanClass());
ComponentDefinition constantComponent = this.listener.getComponentDefinition("min");
assertNotNull("Event for 'min' not sent", propertiesComponent);
AbstractBeanDefinition constantBean = (AbstractBeanDefinition) constantComponent.getBeanDefinitions()[0];
assertEquals("Incorrect BeanDefinition", FieldRetrievingFactoryBean.class, constantBean.getBeanClass());
}
DefaultListableBeanFactoryTests.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void testRegisterExistingSingletonWithNameOverriding() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
Properties p = new Properties();
p.setProperty("test.(class)", TestBean.class.getName());
p.setProperty("test.name", "Tony");
p.setProperty("test.age", "48");
p.setProperty("test.spouse(ref)", "singletonObject");
(new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p);
lbf.registerBeanDefinition("singletonObject", new RootBeanDefinition(PropertiesFactoryBean.class));
Object singletonObject = new TestBean();
lbf.registerSingleton("singletonObject", singletonObject);
lbf.preInstantiateSingletons();
assertTrue(lbf.isSingleton("singletonObject"));
assertEquals(TestBean.class, lbf.getType("singletonObject"));
TestBean test = (TestBean) lbf.getBean("test");
assertEquals(singletonObject, lbf.getBean("singletonObject"));
assertEquals(singletonObject, test.getSpouse());
Map<?, ?> beansOfType = lbf.getBeansOfType(TestBean.class, false, true);
assertEquals(2, beansOfType.size());
assertTrue(beansOfType.containsValue(test));
assertTrue(beansOfType.containsValue(singletonObject));
beansOfType = lbf.getBeansOfType(null, false, true);
Iterator<String> beanNames = lbf.getBeanNamesIterator();
assertEquals("test", beanNames.next());
assertEquals("singletonObject", beanNames.next());
assertFalse(beanNames.hasNext());
assertEquals(2, beansOfType.size());
assertTrue(lbf.containsSingleton("test"));
assertTrue(lbf.containsSingleton("singletonObject"));
assertTrue(lbf.containsBeanDefinition("test"));
assertTrue(lbf.containsBeanDefinition("singletonObject"));
}
QuartzConfig.java 文件源码
项目:lemonaid
阅读 27
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
Properties properties = null;
try {
propertiesFactoryBean.afterPropertiesSet();
properties = propertiesFactoryBean.getObject();
} catch (IOException e) {
log.warn("Cannot load quartz.properties.");
}
return properties;
}
SchedulerConfiguration.java 文件源码
项目:sentry
阅读 27
收藏 0
点赞 0
评论 0
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocations(new FileSystemResource("quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}