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

import java.net.InetAddress;
import java.util.Properties;

public class RmsEnvProperties  {

    /** The properties. */
    private Properties properties;

    public void init() throws Exception {
        InetAddress inetAddress = InetAddress.getLocalHost();
        String serverIp = inetAddress.getHostAddress();
        this.properties = new Properties();
        this.properties.setProperty(RmsProperties.LOCAL_HOST_IP, serverIp);
        if (Boolean.getBoolean("rms.standalone")){
        	this.properties.setProperty(RmsProperties.LOCAL_HOST_NAME, System.getProperty("rms.hostname"));
        }else{
        	this.properties.setProperty(RmsProperties.LOCAL_HOST_NAME, inetAddress.getHostName());
        }
        this.properties.setProperty("standalone", String.valueOf(Boolean.getBoolean("rms.standalone")));
        this.properties.putAll(System.getProperties());
    }

    /* (non-Javadoc)
     * @see com.eactive.eai.rms.client.context.RmsProperties#getProperties()
     */
    public Properties getProperties() {
        return properties;
    }

    /* (non-Javadoc)
     * @see com.eactive.eai.rms.client.context.RmsProperties#refresh()
     */
    public void refresh() throws Exception {
        init();
    }

    /* (non-Javadoc)
     * @see com.eactive.eai.rms.client.context.RmsProperties#setProperties(java.util.Properties)
     */
    public void setProperties(Properties properties) {
        this.properties = properties;
    }


}
