com.tacitknowledge.slowlight.proxyserver.config.ParameterizedConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of slowlight-proxy Show documentation
Show all versions of slowlight-proxy Show documentation
Standalone proxy tool for creating issues with synchronous RPC calls
The newest version!
package com.tacitknowledge.slowlight.proxyserver.config;
import java.util.HashMap;
import java.util.Map;
/**
* This class represents a parametrized configuration model.
* Whenever you need to parametrize a particular chunk of configuration you can extend from this class what will add a params
* property to you configuration, so later those parameters could be used for ex. for server, handler, etc. configuration.
*
*
* An example of parametrized configuration (JSON), please note params property for various config elements
*
* {@code
* ...
* {
* "id" : "testServer2",
* ...
* "params" : {"host" : "localhost", "port" : "8080"},
* "handlers" : [
* {
* "name" : "delayHandler",
* ...
* "params" : {"maxDataSize" : "0", "delay" : "500"}
* }
* ]
* }
* }
*
* @author Alexandr Donciu ([email protected])
*/
public class ParameterizedConfig
{
private Map params = new HashMap();
public void setParams(final Map params)
{
this.params = params;
}
public Map getParams()
{
return params;
}
public String getParam(final String key)
{
return getParam(key, true);
}
public String getParam(final String key, final boolean required)
{
final String param = params.get(key);
if (required && param == null)
{
throw new IllegalArgumentException("Config parameter [" + key + "] doesn't exists");
}
return param;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy