package com.eactive.eai.rms.client.context;

import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * The Class RmsContext.
 * <ul>
 * <li>1. Function :스프링의 {@link org.springframework.context.support.ClassPathXmlApplicationContext}의 확장 클래스 입니다. </li>
 * <li>2. Summary :</li>
 * <li>3. Notification :</li>
 * </ul>
 * 
 * @see org.springframework.context.support.ClassPathXmlApplicationContext
 * @author  : $Author: 박기섭 $
 * @version : $Revision: 1.6 $
 */
public class RmsContext extends ClassPathXmlApplicationContext {

    /** The Constant CONFIGLOCATIONS. */
    private static final String[] CONFIGLOCATIONS = { "com/eactive/eai/rms/client/context/applicationContext-agent.xml" };

    /**
     * The Constructor.
     * 
     * @throws BeansException the beans exception
     */
    private RmsContext() throws BeansException {
        this(CONFIGLOCATIONS);
    }

    /**
     * Instantiates a new agent context.
     * 
     * @param configlocations the configlocations
     * 
     * @throws BeansException the beans exception
     */
    private RmsContext(String[] configlocations) throws BeansException {
        super(configlocations);
    }

    /** The ctx. */
    private static RmsContext ctx = null;

    /**
     * Gets the single instance of RmsContext.
     * 
     * @return single instance of RmsContext
     */
    public static RmsContext getInstance() {
        if (ctx == null) {
            synchronized (RmsContext.class) {
                if (ctx == null) {
                    ctx = new RmsContext();
                }
            }
        }
        return ctx;
    }

    /**
     * Gets the single instance of RmsContext.
     * 
     * @param configlocations the configlocations
     * 
     * @return single instance of RmsContext
     */
    public static RmsContext getInstance(String[] configlocations) {
        if (ctx == null) {
            synchronized (RmsContext.class) {
                if (ctx == null) {
                    ctx = new RmsContext(configlocations);
                }
            }
        }
        return ctx;
    }
}
