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

com.lazerycode.jmeter.mojo.JMeterConfigurationHolder Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
/**
 * 
 */
package com.lazerycode.jmeter.mojo;

import java.io.File;
import java.util.Collections;
import java.util.Map;

import com.lazerycode.jmeter.properties.ConfigurationFiles;
import com.lazerycode.jmeter.properties.PropertiesMapping;

/**
 * Holds configuration 
 */
public class JMeterConfigurationHolder {
    private static final JMeterConfigurationHolder INSTANCE = new JMeterConfigurationHolder();
    private String runtimeJarName;
    private File workingDirectory;
    private Map propertiesMap;
    
    private boolean configurationFreezed;

    /**
     * 
     */
    private JMeterConfigurationHolder() {
        super();
    }

    public static final JMeterConfigurationHolder getInstance() {
        return INSTANCE;
    }

    /**
     * @return the runtimeJarName
     */
    public String getRuntimeJarName() {
        return runtimeJarName;
    }

    /**
     * @param runtimeJarName the runtimeJarName to set
     */
    void setRuntimeJarName(String runtimeJarName) {
        if(configurationFreezed) {
            throw new IllegalStateException("setRuntimeJarName called while JMeter configuration already freezed");
        }
        this.runtimeJarName = runtimeJarName;
    }

    /**
     * @return the workingDirectory
     */
    public File getWorkingDirectory() {
        return workingDirectory;
    }

    /**
     * @param workingDirectory the workingDirectory to set
     */
    void setWorkingDirectory(File workingDirectory) {
        if(configurationFreezed) {
            throw new IllegalStateException("setWorkingDirectory called while JMeter configuration already freezed");
        }
        this.workingDirectory = workingDirectory;
    }

    /**
     * @return the propertiesMap
     */
    public Map getPropertiesMap() {
        return propertiesMap;
    }

    /**
     * @param propertiesMap the propertiesMap to set
     */
    void setPropertiesMap(Map propertiesMap) {
        if(configurationFreezed) {
            throw new IllegalStateException("setPropertiesMap called while JMeter configuration already freezed");
        }
        this.propertiesMap = Collections.unmodifiableMap(propertiesMap);
    }

    /**
     * Freeze configuration
     */
    void freezeConfiguration() {
        this.configurationFreezed = true;
    }
    
    /**
     * Allow to reset configuration
     */
    void resetConfiguration() {
        workingDirectory = null;
        runtimeJarName = null;
        propertiesMap = null;
        this.configurationFreezed = false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy