Class SettingsManager<T>
- java.lang.Object
-
- org.vorpal.blade.framework.config.SettingsManager<T>
-
- Type Parameters:
T- any type of serializable class
public class SettingsManager<T> extends Object
The SettingsManager class automatically reads a JSON formated configuration file. Actually, there can be three configuration files, one for the DOMAIN, CLUSTER, and MACHINE. All three files are merged together.A fourth, SAMPLE, configuration file is automatically generated and saved for ease of use. (You can find it in the 'config/custom/vorpal/samples' directory.
Any serializable class (POJO) can be used as a config file. Extending the class from the Configuration class will provide extra benefits, like controlling the level of logging.
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<T>clazzprotected static StringclusterNameprotected com.fasterxml.jackson.databind.JsonNodeclusterNodeprotected PathclusterPathprotected Tcurrentprotected com.fasterxml.jackson.databind.JsonNodedomainNodeprotected PathdomainPathprotected com.fasterxml.jackson.databind.ObjectMappermapperprotected com.fasterxml.jackson.databind.JsonNodemergedNodeprotected ObjectNameobjectNameprotected ObjectInstanceoiprotected Tsampleprotected PathsamplePathprotected PathschemaPathprotected MBeanServerserverprotected static StringserverNameprotected com.fasterxml.jackson.databind.JsonNodeserverNodeprotected PathserverPathprotected StringservletContextNameprotected Settings<T>settingsstatic SipFactorysipFactorystatic LoggersipLoggerstatic SipSessionsUtilsipUtil
-
Constructor Summary
Constructors Constructor Description SettingsManager()SettingsManager(String name, Class<T> clazz)SettingsManager(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)SettingsManager(String name, Class<T> clazz, T sample)SettingsManager(ServletContextEvent event, Class<T> clazz)SettingsManager(ServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)SettingsManager(ServletContextEvent event, Class<T> clazz, T sample)SettingsManager(SipServletContextEvent event, Class<T> clazz)SettingsManager(SipServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)SettingsManager(SipServletContextEvent event, Class<T> clazz, T sample)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Stringbasename(String name)Removes the version number from the deployed application name.voidbuild(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper _mapper)StringgetClusterJson()static StringgetClusterName()TgetCurrent()StringgetDomainJson()com.fasterxml.jackson.databind.ObjectMappergetMapper()StringgetName()StringgetServerJson()static StringgetServerName()StringgetServletContextName()static SipFactorygetSipFactory()static LoggergetSipLogger()static SipSessionsUtilgetSipUtil()voidinitialize(T config)This method is intended to be overridden to allow configurations that require additional work before they are ready to use.voidlogCurrent()Logs the current configuration.com.fasterxml.jackson.databind.JsonNodemerge(com.fasterxml.jackson.databind.JsonNode mainNode, com.fasterxml.jackson.databind.JsonNode updateNode)voidregister()voidsaveConfigFile(T t)voidsaveSchema(T t)voidsetClusterJson(String clusterJson)static voidsetClusterName(String clusterName)voidsetDomainJson(String domainJson)voidsetMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)voidsetServerJson(String serverJson)static voidsetServerName(String serverName)voidsetServletContextName(String servletContextName)static voidsetSipLogger(Logger sipLogger)voidunregister()
-
-
-
Field Detail
-
sample
protected T sample
-
current
protected T current
-
objectName
protected ObjectName objectName
-
server
protected MBeanServer server
-
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper
-
oi
protected ObjectInstance oi
-
serverName
protected static String serverName
-
clusterName
protected static String clusterName
-
servletContextName
protected String servletContextName
-
domainPath
protected Path domainPath
-
clusterPath
protected Path clusterPath
-
serverPath
protected Path serverPath
-
schemaPath
protected Path schemaPath
-
samplePath
protected Path samplePath
-
sipFactory
public static SipFactory sipFactory
-
sipUtil
public static SipSessionsUtil sipUtil
-
sipLogger
public static Logger sipLogger
-
domainNode
protected com.fasterxml.jackson.databind.JsonNode domainNode
-
clusterNode
protected com.fasterxml.jackson.databind.JsonNode clusterNode
-
serverNode
protected com.fasterxml.jackson.databind.JsonNode serverNode
-
mergedNode
protected com.fasterxml.jackson.databind.JsonNode mergedNode
-
-
Constructor Detail
-
SettingsManager
public SettingsManager()
-
SettingsManager
public SettingsManager(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(String name, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(String name, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
-
Method Detail
-
getSipFactory
public static SipFactory getSipFactory()
-
getSipUtil
public static SipSessionsUtil getSipUtil()
-
getSipLogger
public static Logger getSipLogger()
-
setSipLogger
public static void setSipLogger(Logger sipLogger)
-
getDomainJson
public String getDomainJson() throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
setDomainJson
public void setDomainJson(String domainJson) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException, IOException
- Throws:
com.fasterxml.jackson.databind.JsonMappingExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionIOException
-
getServerJson
public String getServerJson() throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
setServerJson
public void setServerJson(String serverJson) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException, IOException
- Throws:
com.fasterxml.jackson.databind.JsonMappingExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionIOException
-
getClusterJson
public String getClusterJson() throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
setClusterJson
public void setClusterJson(String clusterJson) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException, IOException
- Throws:
com.fasterxml.jackson.databind.JsonMappingExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionIOException
-
build
public void build(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper _mapper) throws ServletException, IOException
- Throws:
ServletExceptionIOException
-
initialize
public void initialize(T config) throws ServletParseException
This method is intended to be overridden to allow configurations that require additional work before they are ready to use.- Parameters:
config-- Throws:
ServletParseException
-
register
public void register() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, InstantiationException, IllegalAccessException, IOException, ServletParseException- Throws:
InstanceAlreadyExistsExceptionMBeanRegistrationExceptionNotCompliantMBeanExceptioncom.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionInstantiationExceptionIllegalAccessExceptionIOExceptionServletParseException
-
unregister
public void unregister() throws ServletException, IOException- Throws:
ServletExceptionIOException
-
saveSchema
public void saveSchema(T t) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
- Throws:
com.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
saveConfigFile
public void saveConfigFile(T t) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
- Throws:
com.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
getCurrent
public T getCurrent()
- Returns:
- the current
-
getName
public String getName()
-
getClusterName
public static String getClusterName()
-
setClusterName
public static void setClusterName(String clusterName)
-
merge
public com.fasterxml.jackson.databind.JsonNode merge(com.fasterxml.jackson.databind.JsonNode mainNode, com.fasterxml.jackson.databind.JsonNode updateNode) throws IOException- Throws:
IOException
-
getServletContextName
public String getServletContextName()
-
setServletContextName
public void setServletContextName(String servletContextName)
-
getServerName
public static String getServerName()
-
setServerName
public static void setServerName(String serverName)
-
logCurrent
public void logCurrent()
Logs the current configuration.
-
getMapper
public com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
setMapper
public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
-
-