Package org.wso2.carbon.cloud.csg

Source Code of org.wso2.carbon.cloud.csg.CSGUtils

/*
* Copyright WSO2, Inc. (http://wso2.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.cloud.csg;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.cloud.csg.common.CSGException;
import org.wso2.carbon.mediation.initializer.AbstractServiceBusAdmin;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
* <code> CSGUtils </code> contains some utility methods for proxy service creation/handling etc..
*/
public class CSGUtils extends AbstractServiceBusAdmin {

    private static final Log log = LogFactory.getLog(CSGUtils.class);

    public static Properties loadProperties(String filePath) throws CSGException{
        Properties prop = new Properties();
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if(log.isDebugEnabled()){
            log.debug("Loading the property file '" + filePath + "' from the classpath");
        }
        InputStream in = cl.getResourceAsStream(filePath);
        if(in != null){
            try {
                prop.load(in);
            } catch (IOException e) {
                String msg = "Cloud not load properties from file '" + filePath + "'";
                log.error(msg, e);
                throw new CSGException(msg, e);
            }
        }
        return prop;
    }
}
TOP

Related Classes of org.wso2.carbon.cloud.csg.CSGUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.