All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.jbossts.xts.environment.XTSPropertyManager Maven / Gradle / Ivy

There is a newer version: 4.17.43.Final
Show newest version
package org.jboss.jbossts.xts.environment;

import com.arjuna.common.internal.util.propertyservice.BeanPopulator;

import java.util.Enumeration;
import java.util.Properties;

/**
 * class which ensures XTS properties are installed into the environment beans when they are created
 * and provides access to those beans
 */
public class XTSPropertyManager
{
    public static  WSCEnvironmentBean getWSCEnvironmentBean()
    {
        return BeanPopulator.getDefaultInstance(WSCEnvironmentBean.class, xtsProperties);
    }

    public static WSCFEnvironmentBean getWSCFEnvironmentBean()
    {
        return BeanPopulator.getDefaultInstance(WSCFEnvironmentBean.class, xtsProperties);
    }

    public static WSTEnvironmentBean getWSTEnvironmentBean()
    {
        return BeanPopulator.getDefaultInstance(WSTEnvironmentBean.class, xtsProperties);
    }

    public static RecoveryEnvironmentBean getRecoveryEnvironmentBean()
    {
        return BeanPopulator.getDefaultInstance(RecoveryEnvironmentBean.class, xtsProperties);
    }

    public static XTSEnvironmentBean getXTSEnvironmentBean()
    {
        return BeanPopulator.getDefaultInstance(XTSEnvironmentBean.class, xtsProperties);
    }

    private static Properties mergeSystemProperties(Properties properties)
    {
        Properties systemProperties = System.getProperties();
        Enumeration propertyNames =  systemProperties.elements();
        while (propertyNames.hasMoreElements()) {
            String propertyName = (String) propertyNames.nextElement();
            String propertyValue = (String) System.getProperty(propertyName);
            properties.setProperty(propertyName, propertyValue);
        }
        
        return properties;
    }

    static Properties xtsProperties;

    static {
        try {
            xtsProperties = XTSPropertiesFactory.getDefaultProperties();
        } catch (Exception e) {
            xtsProperties = new Properties(System.getProperties());
        }
    }
}