当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesLoaderUtils类代码示例

本文整理汇总了Java中org.springframework.core.io.support.PropertiesLoaderUtils的典型用法代码示例。如果您正苦于以下问题:Java PropertiesLoaderUtils类的具体用法?Java PropertiesLoaderUtils怎么用?Java PropertiesLoaderUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertiesLoaderUtils类属于org.springframework.core.io.support包,在下文中一共展示了PropertiesLoaderUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
/**
 * Load the lease config from properties, and init the lockConfigMap.
 */
@PostConstruct
public void init() {
    try {
        // Using default path if no specified
        confPath = StringUtils.isBlank(confPath) ? DEFAULT_CONF_PATH : confPath;

        // Load lock config from properties
        Properties properties = PropertiesLoaderUtils.loadAllProperties(confPath);

        // Build the lockConfigMap
        for (Entry<Object, Object> propEntry : properties.entrySet()) {
            DLockType lockType = EnumUtils.valueOf(DLockType.class, propEntry.getKey().toString());
            Integer lease = Integer.valueOf(propEntry.getValue().toString());

            if (lockType != null && lease != null) {
                lockConfigMap.put(lockType, lease);
            }
        }

    } catch (Exception e) {
        throw new RuntimeException("Load distributed lock config fail", e);
    }
}
 
开发者ID:baidu,项目名称:dlock,代码行数:27,代码来源:DLockGenerator.java

示例2: loadProperties

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
protected void loadProperties(Properties props) throws IOException {
	if (this.locations != null) {
		for (Resource location : this.locations) {
			logger.info("Loading properties file from " + location);
			try {
				PropertiesLoaderUtils.fillProperties(props,
						new EncodedResource(location, this.fileEncoding));
			} catch (IOException ex) {
				if (this.ignoreResourceNotFound) {
					logger.warn("Could not load properties from " + location + ": " + ex.getMessage());
				} else {
					throw ex;
				}
			}
		}
	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:18,代码来源:GlobalPropertySources.java

示例3: afterPropertiesSet

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
/**
 * Merges the {@code Properties} configured in the {@code mappings} and
 * {@code mappingLocations} into the final {@code Properties} instance
 * used for {@code ObjectName} resolution.
 * @throws IOException
 */
@Override
public void afterPropertiesSet() throws IOException {
	this.mergedMappings = new Properties();

	CollectionUtils.mergePropertiesIntoMap(this.mappings, this.mergedMappings);

	if (this.mappingLocations != null) {
		for (int i = 0; i < this.mappingLocations.length; i++) {
			Resource location = this.mappingLocations[i];
			if (logger.isInfoEnabled()) {
				logger.info("Loading JMX object name mappings file from " + location);
			}
			PropertiesLoaderUtils.fillProperties(this.mergedMappings, location);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:KeyNamingStrategy.java

示例4: newScheduler

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
protected Scheduler newScheduler()throws SchedulerException{
	StdSchedulerFactory factory=new StdSchedulerFactory();
	Properties mergedProps = new Properties();
	mergedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());
	mergedProps.setProperty("org.quartz.scheduler.instanceName", "BDF2Scheduler");
	mergedProps.setProperty("org.quartz.scheduler.instanceId", "CoreBDF2Scheduler");
	mergedProps.setProperty("org.quartz.scheduler.makeSchedulerThreadDaemon", makeSchedulerThreadDaemon);
	mergedProps.setProperty("org.quartz.threadPool.threadCount", Integer.toString(threadCount));
	if (this.configLocation != null) {
		try {
			PropertiesLoaderUtils.fillProperties(mergedProps, this.configLocation);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	factory.initialize(mergedProps);
	Scheduler scheduler=factory.getScheduler();
	Collection<JobExecutionListener> jobListeners = this.getApplicationContext().getBeansOfType(JobExecutionListener.class).values();
	for(JobExecutionListener jobListener:jobListeners){
		jobListener.setSessionFactory(getSessionFactory());
		scheduler.getListenerManager().addJobListener(jobListener);
	}
	return scheduler;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:SchedulerServiceImpl.java

示例5: getPropertiesFromFile

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
private Properties getPropertiesFromFile(String baseName, Resource resource) {
    Properties properties = new Properties();

    String fileType = FileUtils.getFileExt(resource.getFilename());

    try {
        if (SUFFIX_OF_PROPERTIES.equals(fileType)) {
            //1.properties
            PropertiesLoaderUtils.fillProperties(properties, new EncodedResource(resource, "UTF-8"));
        } else if (SUFFIX_OF_TEXT.equals(fileType) || SUFFIX_OF_HTML.equals(fileType)) {
            //2.txt/html
            properties.put(baseName, ResourceUtils.getContent(resource));
        } else {
            //do nothing!
            logger.debug("this file '{}' is not properties, txt, html!", resource);
        }
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        return null;
    }

    return properties;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:24,代码来源:ResourceBundleHolder.java

示例6: initExtResources

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
private static void initExtResources() {
    String filePath = System.getProperty(EXT_PARAMS_FILE_NAME);
    if (StringUtils.isBlank(filePath)) {
        return;
    }

    System.out.println(String.format("获取到%s路径为'{%s}'!", EXT_PARAMS_FILE_NAME, filePath));

    Resource resource = new FileSystemResource(filePath);
    if (!resource.exists()) {
        System.err.println(String.format("找不到外部文件'[%s]'!", filePath));
        return;
    }

    try {
        PropertiesLoaderUtils.fillProperties(EXT_PARAMS_PROPERTIES, new EncodedResource(resource, "UTF-8"));
    } catch (IOException e) {
        e.printStackTrace();
        System.err.println(String.format("读取路径为'%s'的文件失败!失败原因是'%s'!", filePath, e.getMessage()));
    }
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:22,代码来源:ParamsHome.java

示例7: init

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
public static void init() {
    Resource resource = new ClassPathResource("/META-INF/log4j.properties", Thread.currentThread().getContextClassLoader());

    if (!resource.exists()) {
        resource = Env.getFileEnv("log4j.properties");
    }

    if (resource == null || !resource.exists()) {
        throw new RuntimeException("配置文件'log4j.properties'找不到!");
    }

    Properties prop = null;
    try {
        prop = PropertiesLoaderUtils.loadProperties(resource);
    } catch (IOException e) {
        System.err.println("no log4j configuration file!");
    }

    PropertyConfigurator.configure(prop);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:21,代码来源:Log4JConfiguration.java

示例8: processConfigFile

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
private void processConfigFile(Resource resource)
    throws IOException
{
	String absPath = null;
	if (null != resource.getURL() && !resource.getURL().getFile().contains("jar!"))
	{
		absPath = resource.getFile().getAbsolutePath();
	}
    LOGGER.info("Loading configuration file " + resource.getFilename() + " from " + absPath + "|" + resource);
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    ConfigFile configFile = new ConfigFile();
    configFile.setFileName(resource.getFilename());
    configFile.setFilePath(absPath);
    configFile.setConfigList(parseConfigFile(props));
    CONFIG_FILES.add(configFile);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:17,代码来源:ConfigManagerNoDecrypt.java

示例9: processConfigFile

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
private static void processConfigFile(Resource resource)
    throws IOException
{
    String absPath = null;
    if (null != resource.getURL() && !resource.getURL().getFile().contains("jar!"))
    {
        absPath = resource.getFile().getAbsolutePath();
    }
    LOGGER.info("Loading configuration file " + resource.getFilename() + " from " + absPath + "|" + resource);
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    ConfigFile configFile = new ConfigFile();
    configFile.setFileName(resource.getFilename());
    configFile.setFilePath(absPath);
    configFile.setConfigList(parseConfigFile(props));
    CONFIG_FILES.add(configFile);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:17,代码来源:ConfigManagerUpdate.java

示例10: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
@Override
public void getPropert() {
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("ns_envPRDHost"));
        provider.setMarket(Integer.parseInt(props.getProperty("ns_market")));
        provider.setFirstKey(props.getProperty("ns_firstKey"));
        provider.setSecondKey(props.getProperty("ns_secondKey"));
        providerMap.put("provider", provider);
    } catch (Exception e) {
        throw new RuntimeException("读取配置文件出错!", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:17,代码来源:NsTradeProvider.java

示例11: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
@Override
public void getPropert() {
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("nj_envPRDHost"));
        provider.setMarket(Integer.parseInt(props.getProperty("nj_market")));
        provider.setFirstKey(props.getProperty("nj_firstKey"));
        provider.setSecondKey(props.getProperty("nj_secondKey"));
        providerMap.put("provider", provider);
    } catch (Exception e) {
        throw new RuntimeException("读取配置文件出错!", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:17,代码来源:NjTradeProvider.java

示例12: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
@Override
public void getPropert() {
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        Provider provider = new Provider();
        provider.setHost(props.getProperty("host"));
        provider.setHostNext(props.getProperty("host_next"));
        provider.setHostUser(props.getProperty("host_user"));
        provider.setReferenceInformation(props.getProperty("reference_information"));
        provider.setHostConnect(props.getProperty("host_connect"));
        provider.setTelphone(props.getProperty("telphone"));
        provider.setBankType(props.getProperty("bank_type"));
        provider.setSection(props.getProperty("section"));
        providerMap.put("provider", provider);
    } catch (Exception e) {
        LOG.warn("An error occours when reading profiles", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:20,代码来源:Entrace.java

示例13: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
@Override
public void getPropert() {
    filter = new HashMap<String, String>();
    allMassage = new ArrayList<String>();
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("host"));
        provider.setTurnPage(props.getProperty("turn_page"));
        provider.setBankType(props.getProperty("bank_type"));
        provider.setReferenceInformation(props.getProperty("reference_information"));
        provider.setThreadNum(props.getProperty("user_thread"));

        providerMap.put("provider", provider);
    } catch (Exception e) {
        LOG.warn("read profiles from yichen", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:21,代码来源:Entrace.java

示例14: getUrl

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
public static String getUrl(String propertyName, String from, String to) {
    try {
        Resource resource = new ClassPathResource(propertyName);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        String fetchUrl = "";
        if (from.contains("blog")) {
            fetchUrl = props.getProperty("blog_url");
        } else {
            fetchUrl = props.getProperty("notice_url");
        }
        from = "{" + from + "}";
        return StringUtils.replace(fetchUrl, from, to);
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:17,代码来源:Property.java

示例15: getOpenAccount

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入依赖的package包/类
public static Object getOpenAccount(String propertyName, Object obj, String openAccountStr,
        String openAccountUrlStr) {
    try {
        Resource resource = new ClassPathResource(propertyName);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        String openAccount = props.getProperty(openAccountStr);
        String openAccountUrl = props.getProperty(openAccountUrlStr);
        if (obj instanceof BlogModel) {
            BlogModel blogModel = (BlogModel) obj;
            blogModel.setOpenAccount(openAccount);
            blogModel.setOpenAccountUrl(openAccountUrl);
            return blogModel;
        } else {
            NoticeModel noticeModel = (NoticeModel) obj;
            noticeModel.setOpenAccount(openAccount);
            noticeModel.setOpenAccountUrl(openAccountUrl);
            return noticeModel;
        }
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:23,代码来源:Property.java


注:本文中的org.springframework.core.io.support.PropertiesLoaderUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。