當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。