Search in sources :

Example 1 with ISystemInformation

use of com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.ISystemInformation in project ats-framework by Axway.

the class SystemInformationFactory method get.

/**
 * Depending on the System property {@link AtsSystemProperties.SYSTEM_INFORMATION_CLASS}, a {@link ISystemInformation} will be returned.</br>
 */
public static synchronized ISystemInformation get() {
    String providerName = AtsSystemProperties.getPropertyAsString(AtsSystemProperties.SYSTEM_MONITORING_PROVIDER, "sigar");
    if (!MONITORING_PROVIDERS_MAP.containsKey(providerName)) {
        throw new UnsupportedOperationException("Provider '" + providerName + "' is not supported as implementation for system information/monitoring provider. Currently available once are: " + Arrays.toString(MONITORING_PROVIDERS_MAP.keySet().toArray(new String[MONITORING_PROVIDERS_MAP.size()])));
    }
    LOG.info("System information/monitoring provider will be: '" + providerName + "'");
    ISystemInformation providerInstance = null;
    try {
        Class<?> clazz = Class.forName(MONITORING_PROVIDERS_MAP.get(providerName));
        providerInstance = (ISystemInformation) clazz.getConstructors()[0].newInstance(new Object[] {});
    } catch (Exception e) {
        throw new SystemInformationException("Error while initializing monitoring provider '" + providerName + "'", e);
    }
    return providerInstance;
}
Also used : ISystemInformation(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.ISystemInformation) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)

Aggregations

ISystemInformation (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.ISystemInformation)1 SystemInformationException (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)1