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>
clazz
protected static String
clusterName
protected com.fasterxml.jackson.databind.JsonNode
clusterNode
protected Path
clusterPath
protected T
current
protected com.fasterxml.jackson.databind.JsonNode
domainNode
protected Path
domainPath
protected com.fasterxml.jackson.databind.ObjectMapper
mapper
protected com.fasterxml.jackson.databind.JsonNode
mergedNode
protected ObjectName
objectName
protected ObjectInstance
oi
protected T
sample
protected Path
samplePath
protected Path
schemaPath
protected MBeanServer
server
protected static String
serverName
protected com.fasterxml.jackson.databind.JsonNode
serverNode
protected Path
serverPath
protected String
servletContextName
protected Settings<T>
settings
static SipFactory
sipFactory
static Logger
sipLogger
static SipSessionsUtil
sipUtil
-
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 String
basename(String name)
Removes the version number from the deployed application name.void
build(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper _mapper)
String
getClusterJson()
static String
getClusterName()
T
getCurrent()
String
getDomainJson()
com.fasterxml.jackson.databind.ObjectMapper
getMapper()
String
getName()
String
getServerJson()
static String
getServerName()
String
getServletContextName()
static SipFactory
getSipFactory()
static Logger
getSipLogger()
static SipSessionsUtil
getSipUtil()
void
initialize(T config)
This method is intended to be overridden to allow configurations that require additional work before they are ready to use.void
logCurrent()
Logs the current configuration.com.fasterxml.jackson.databind.JsonNode
merge(com.fasterxml.jackson.databind.JsonNode mainNode, com.fasterxml.jackson.databind.JsonNode updateNode)
void
register()
void
saveConfigFile(T t)
void
saveSchema(T t)
void
setClusterJson(String clusterJson)
static void
setClusterName(String clusterName)
void
setDomainJson(String domainJson)
void
setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
void
setServerJson(String serverJson)
static void
setServerName(String serverName)
void
setServletContextName(String servletContextName)
static void
setSipLogger(Logger sipLogger)
void
unregister()
-
-
-
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:
ServletException
IOException
-
SettingsManager
public SettingsManager(String name, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(String name, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(SipServletContextEvent event, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletException
IOException
-
SettingsManager
public SettingsManager(ServletContextEvent event, Class<T> clazz, T sample) throws ServletException, IOException
- Throws:
ServletException
IOException
-
-
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.JsonMappingException
com.fasterxml.jackson.core.JsonProcessingException
IOException
-
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.JsonMappingException
com.fasterxml.jackson.core.JsonProcessingException
IOException
-
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.JsonMappingException
com.fasterxml.jackson.core.JsonProcessingException
IOException
-
build
public void build(String name, Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper _mapper) throws ServletException, IOException
- Throws:
ServletException
IOException
-
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:
InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException
com.fasterxml.jackson.core.JsonGenerationException
com.fasterxml.jackson.databind.JsonMappingException
InstantiationException
IllegalAccessException
IOException
ServletParseException
-
unregister
public void unregister() throws ServletException, IOException
- Throws:
ServletException
IOException
-
saveSchema
public void saveSchema(T t) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
- Throws:
com.fasterxml.jackson.core.JsonGenerationException
com.fasterxml.jackson.databind.JsonMappingException
IOException
-
saveConfigFile
public void saveConfigFile(T t) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
- Throws:
com.fasterxml.jackson.core.JsonGenerationException
com.fasterxml.jackson.databind.JsonMappingException
IOException
-
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)
-
-