Java 类org.springframework.beans.factory.config.PropertiesFactoryBean 实例源码

项目:iBase4J-Common    文件:Configs.java   
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();
}
项目:spring-data-snowdrop    文件:CdiUtils.java   
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);
    }
}
项目:spring4-understanding    文件:AutowireWithExclusionTests.java   
@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());
}
项目:spring4-understanding    文件:AutowireWithExclusionTests.java   
@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());
}
项目:spring4-understanding    文件:AutowireWithExclusionTests.java   
@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());
}
项目:spring4-understanding    文件:DefaultListableBeanFactoryTests.java   
@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"));
}
项目:api-server-seed    文件:QuartzFactory.java   
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;

}
项目:spring-cloud-config-support    文件:CloudConfigSupportConfiguration.java   
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;
}
项目:spring-cloud-config-support    文件:TestProperty.java   
@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();
}
项目:alfresco-utility    文件:SubsystemWithClassLoaderState.java   
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);
    }
}
项目:micro-server    文件:PropertyFileConfig.java   
@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;
}
项目:micro-server    文件:SSLConfig.java   
@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;
}
项目:logsniffer    文件:CoreAppConfig.java   
@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;
}
项目:iris    文件:SecurityConfig.java   
@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);
}
项目:class-guard    文件:AutowireWithExclusionTests.java   
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());
}
项目:class-guard    文件:AutowireWithExclusionTests.java   
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());
}
项目:class-guard    文件:AutowireWithExclusionTests.java   
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());
}
项目:alfresco-repository    文件:ChildApplicationContextFactory.java   
/**
 * 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();
}
项目:spring-boot-quartz-demo    文件:QuartzSchedulerConfig.java   
/**
 * 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();
}
项目:sentry    文件:SchedulerConfiguration.java   
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocations(new FileSystemResource("quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
项目:webcron    文件:QuartzConfig.java   
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
项目:spring-boot-starter-quartz    文件:QuartzSchedulerAutoConfiguration.java   
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();
}
项目:spring-boot-starter-quartz    文件:TestContextConfiguration3.java   
@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();
}
项目:backbone    文件:WebMvcApplicationConfig.java   
@Bean(name = Global.BEAN_NAME_ROOT_PROPS)
public PropertiesFactoryBean getPropertiesFactoryBean() {
    PropertiesFactoryBean bean = new PropertiesFactoryBean();
    Resource[] resources = getPropsResources(resourceLoader);
    bean.setLocations(resources);
    return bean;
}
项目:springboot-quartz    文件:SchedulerConfig.java   
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
项目:oma-riista-web    文件:QuartzConfig.java   
@Bean
public Properties quartzProperties() throws IOException {
    final PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/configuration/quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
项目:spring4-understanding    文件:UtilNamespaceHandlerTests.java   
@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());
}
项目:spring4-understanding    文件:DefaultListableBeanFactoryTests.java   
@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"));
}
项目:lemonaid    文件:QuartzConfig.java   
@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;
}
项目:sentry    文件:SchedulerConfiguration.java   
@Bean
public Properties quartzProperties() throws IOException {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocations(new FileSystemResource("quartz.properties"));
    propertiesFactoryBean.afterPropertiesSet();
    return propertiesFactoryBean.getObject();
}
项目:spring-boot-starter    文件:MybatisAutoConfigurationTest.java   
@Bean
public PropertiesFactoryBean vendorProperties() {
    Properties properties = new Properties();
    properties.put("SQL Server", "sqlserver");
    properties.put("DB2", "db2");
    properties.put("H2", "h2");

    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setProperties(properties);
    return propertiesFactoryBean;
}
项目:owsi-core-parent    文件:AbstractJpaConfig.java   
@Bean(name = "hibernateDefaultExtraProperties")
public PropertiesFactoryBean hibernateDefaultExtraProperties(@Value("${hibernate.defaultExtraPropertiesUrl}") Resource defaultExtraPropertiesUrl) {
    PropertiesFactoryBean f = new PropertiesFactoryBean();
    f.setIgnoreResourceNotFound(false);
    f.setFileEncoding("UTF-8");
    f.setLocations(defaultExtraPropertiesUrl);
    return f;
}
项目:owsi-core-parent    文件:AbstractJpaConfig.java   
@Bean(name = "hibernateExtraProperties")
public PropertiesFactoryBean hibernateExtraProperties(@Value("${hibernate.extraPropertiesUrl}") Resource extraPropertiesUrl) {
    PropertiesFactoryBean f = new PropertiesFactoryBean();
    f.setIgnoreResourceNotFound(true);
    f.setFileEncoding("UTF-8");
    f.setLocations(extraPropertiesUrl);
    return f;
}
项目:onetwo    文件:SpringUtils.java   
public static JFishProperties loadAsJFishProperties(String... classpaths){
    PropertiesFactoryBean pfb = createPropertiesBySptring(classpaths);
    try {
        pfb.afterPropertiesSet();
        JFishProperties properties = (JFishProperties)pfb.getObject();
        return properties;
    } catch (IOException e) {
        throw new BaseException("load config error: " + e.getMessage(), e);
    }
}
项目:onetwo    文件:SpringUtils.java   
public static PropertiesFactoryBean createPropertiesBySptring(JFishProperties properties, String...classpaths) {
//      PropertiesFactoryBean pfb = new PropertiesFactoryBean();
        PropertiesFactoryBean pfb = new JFishPropertiesFactoryBean(properties);
        pfb.setIgnoreResourceNotFound(true);
        org.springframework.core.io.Resource[] resources = new org.springframework.core.io.Resource[classpaths.length];
        int index = 0;
        for(String classpath : classpaths){
            resources[index++] = classpath(classpath);
        }
        pfb.setLocations(resources);
        return pfb;
    }
项目:psi-probe    文件:ProbeConfig.java   
/**
 * Version.
 *
 * @return the properties factory bean
 */
@Bean(name = "version")
public PropertiesFactoryBean version() {
  logger.debug("Instantiated version");
  PropertiesFactoryBean bean = new PropertiesFactoryBean();
  bean.setLocation(new ClassPathResource("version.properties"));
  return bean;
}
项目:community-edition-old    文件:ChildApplicationContextFactory.java   
/**
 * 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();
}
项目:class-guard    文件:UtilNamespaceHandlerTests.java   
public void testEvents() throws Exception {
    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());
}
项目:InSpider    文件:AttributeMapping.java   
@Bean
public PropertiesFactoryBean attributeMappingValidatorMessages () {
    final PropertiesFactoryBean properties = new PropertiesFactoryBean ();

    properties.setLocation (new ClassPathResource ("nl/ipo/cds/etl/attributemapping/validator.messages"));

    return properties;
}
项目:InSpider    文件:Harvester.java   
@Bean
public PropertiesFactoryBean harvesterMessages () {
    final PropertiesFactoryBean properties = new PropertiesFactoryBean ();

    properties.setLocation (new ClassPathResource ("nl/ipo/cds/etl/harvest/harvest.messages"));

    return properties;
}