public class PropertyService extends java.lang.Thread implements StopableObject
Modifier and Type | Field and Description |
---|---|
private PropertyServiceNotifiable |
agent
The worker which called this property service.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
changeProps
Listener for property change requests.
|
private org.w3c.dom.Document |
parameterDescription
Parameter description.
|
private java.lang.String |
parameterDescriptionFile
Path to the XML-file where the parameter description is located.
|
private java.util.Properties |
props
Basic (user-defined) properties.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
requestProps
Listener for property requests.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher |
resultProps
Publisher for property results.
|
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber |
resultPropsReader
Subscriber for other property results.
|
private boolean |
shutDown
Determines if the method
shutDown() has been called. |
private ConfigType |
type
Properties type.
|
Constructor and Description |
---|
PropertyService(PropertyServiceNotifiable theWorker,
ConfigType supportedType)
Create a new property service.
|
PropertyService(PropertyServiceNotifiable theWorker,
ConfigType supportedType,
java.lang.String parmDescFile)
Create a new property service with a well known external properties description file.
|
Modifier and Type | Method and Description |
---|---|
private void |
end()
Gracefully end this service.
|
private java.lang.String |
getID()
Returns a service ID.
|
private java.util.Map<java.lang.String,java.lang.String> |
getPropertiesAsMap(java.lang.String reqProps)
Loads the required properties for the requested type by using
loadProperties() and fetches the
requested properties defined by the reqProps parameter. |
private java.util.Map<java.lang.String,PropertyDescription> |
getPropertiesDescriptionMap()
Loads the properties descriptions from the external file and parses them out of the XML document.
|
private java.lang.String |
getServiceStateReference()
Returns the service state reference which entitles a change requests.
|
private java.lang.String |
getVersion()
Returns the agents version.
|
private void |
handleChangeRequest()
Handles a properties change requested on the ActiveMQ change topic (REACHABILITY_CONFIG_CHANGE_TOPIC).
|
private void |
handleOtherConfigurations()
There may arrive configuration results via the ActiveMQ which dosn't equal
type . |
private void |
handleRequested()
Handles a request for properties sent over the ActiveMQ request topic REACHABILITY_CONFIG_REQUEST_TOPIC
by calling
pushProperties(JsonRAPropertiesRequest) . |
private void |
init()
Initializes the ActiveMQ connections for request (REACHABILITY_CONFIG_REQUEST_TOPIC), response
(REACHABILITY_CONFIG_RESULT_TOPIC) and change (REACHABILITY_CONFIG_CHANGE_TOPIC).
|
boolean |
isActive()
Determines whether the method
StopableObject.shutDown() has been called on this object or not. |
private void |
loadProperties()
Loads the currently defined properties by delegation to the agent.
|
private void |
loadPropertiesDescription()
Loads the currently defined properties descriptions.
|
void |
pushProperties(JsonRAPropertiesRequest reqObj)
Sends a
JsonRAPropertiesResult JSON object on the result topic (REACHABILITY_CONFIG_RESULT_TOPIC)
containing the requested properties which are determined by using getPropertiesAsMap(String) and their
descriptions determined by getPropertiesDescriptionMap() . |
void |
reloadProperties()
Alias for
loadProperties() . |
void |
run()
Run as long as
shutDown() wasn't called. |
void |
shutDown()
Shuts the object down.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private java.util.Properties props
private boolean shutDown
shutDown()
has been called.private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber requestProps
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPPublisher resultProps
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber resultPropsReader
private de.hawhamburg.livingplace.messaging.activemq.wrapper.LPSubscriber changeProps
private ConfigType type
private java.lang.String parameterDescriptionFile
private org.w3c.dom.Document parameterDescription
private PropertyServiceNotifiable agent
public PropertyService(PropertyServiceNotifiable theWorker, ConfigType supportedType)
theWorker
- The PropertyServiceNotifiable
object which set up this property service reasoner
and might be updated at runtime.supportedType
- The type of properties for which this service is primary responsible as ConfigType
.public PropertyService(PropertyServiceNotifiable theWorker, ConfigType supportedType, java.lang.String parmDescFile)
theWorker
- The PropertyServiceNotifiable
object which set up this property service reasoner
and might be updated at runtime.supportedType
- The type of properties for which this service is primary responsible as ConfigType
.parmDescFile
- The path to the well known external properties description file as String
.private void loadProperties()
public final void reloadProperties()
loadProperties()
.private void loadPropertiesDescription()
public final void run()
shutDown()
wasn't called.run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void init()
private void handleRequested()
pushProperties(JsonRAPropertiesRequest)
.public final void pushProperties(JsonRAPropertiesRequest reqObj)
JsonRAPropertiesResult
JSON object on the result topic (REACHABILITY_CONFIG_RESULT_TOPIC)
containing the requested properties which are determined by using getPropertiesAsMap(String)
and their
descriptions determined by getPropertiesDescriptionMap()
.reqObj
- A JsonRAPropertiesRequest
JSON object representing the request.private java.util.Map<java.lang.String,java.lang.String> getPropertiesAsMap(java.lang.String reqProps)
loadProperties()
and fetches the
requested properties defined by the reqProps parameter.reqProps
- The requested property as String
("*ALL" is defined as wildcard for all properties).Map
of String
to String
.private java.util.Map<java.lang.String,PropertyDescription> getPropertiesDescriptionMap()
Map
of String
(property) to
PropertyDescription
(description object of the property).private void handleChangeRequest()
PropertyServiceNotifiable.updateProperties(Properties, Properties, ConfigType)
on agent
.private void handleOtherConfigurations()
private void end()
public final boolean isActive()
StopableObject
StopableObject.shutDown()
has been called on this object or not.isActive
in interface StopableObject
true
if shutDown()
wasn't called, otherwise false
.StopableObject.isActive()
public final void shutDown()
StopableObject
shutDown
in interface StopableObject
StopableObject.shutDown()
private java.lang.String getID()
ProjectInfo.REACHABILITY_AGENT_WORKER_NAME
, the
services name and a pseudo random number.private java.lang.String getServiceStateReference()
private java.lang.String getVersion()
ProjectInfo.REACHABILITY_AGENT_VERSION
.