com.bootcamp.utils.config.Global.java Source code

Java tutorial

Introduction

Here is the source code for com.bootcamp.utils.config.Global.java

Source

/**
 * Copyright &copy; 2012-2013 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.bootcamp.utils.config;

import com.bootcamp.utils.PropertiesLoader;
import com.google.common.collect.Maps;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * ?
 * @author ThinkGem
 * @version 2013-03-23
 */
public class Global {

    /**
     * ?
     */
    private static Map<String, String> map = Maps.newHashMap();

    /**
     * 
     */
    private static PropertiesLoader propertiesLoader = new PropertiesLoader("szdfc.properties");

    /**
     * ??
     */
    public static String getConfig(String key) {
        String value = map.get(key);
        if (value == null) {
            value = propertiesLoader.getProperty(key);
            map.put(key, value);
        }
        return value;
    }

    /////////////////////////////////////////////////////////

    /**
     * ??
     */
    public static String getAdminPath() {
        return getConfig("adminPath");
    }

    /**
     * ??
     */
    public static String getFrontPath() {
        return getConfig("frontPath");
    }

    /**
     * ?URL?
     */
    public static String getUrlSuffix() {
        return getConfig("urlSuffix");
    }

    /**
     * ????????????
     */
    public static Boolean isDemoMode() {
        String dm = getConfig("demoMode");
        return "true".equals(dm) || "1".equals(dm);
    }

    /**
     * ??Activiti
     */
    public static Boolean isSynActivitiIndetity() {
        String dm = getConfig("activiti.isSynActivitiIndetity");
        return "true".equals(dm) || "1".equals(dm);
    }

    /**
     * ?CKFinder
     * @return
     */
    public static String getCkBaseDir() {
        String dir = getConfig("userfiles.basedir");
        Assert.hasText(dir, "??userfiles.basedir");
        if (!dir.endsWith("/")) {
            dir += "/";
        }
        return dir;
    }

}