Package org.onosproject.ui
Class RequestHandler
- java.lang.Object
-
- org.onosproject.ui.RequestHandler
-
- Direct Known Subclasses:
ChartRequestHandler
,TableRequestHandler
public abstract class RequestHandler extends java.lang.Object
Abstraction of an entity that handles a specific request from the user interface client.- See Also:
UiMessageHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected static com.fasterxml.jackson.databind.ObjectMapper
MAPPER
-
Constructor Summary
Constructors Constructor Description RequestHandler(java.lang.String eventType)
Constructs a request handler instance that will handle events of the specified type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
bool(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a boolean.protected void
chain(java.lang.String eventType, com.fasterxml.jackson.databind.node.ObjectNode payload)
Allows one request handler to pass the event on to another for further processing.java.lang.String
eventType()
Returns the event type that this handler handles.protected <T> T
get(java.lang.Class<T> serviceClass)
Returns an implementation of the specified service class.protected long
number(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a number.abstract void
process(com.fasterxml.jackson.databind.node.ObjectNode payload)
Processes the incoming message payload from the client.protected void
sendMessage(com.fasterxml.jackson.databind.node.ObjectNode message)
Sends a message back to the client.protected void
sendMessage(java.lang.String eventType, com.fasterxml.jackson.databind.node.ObjectNode payload)
Sends a message back to the client with the given event type and payload.protected java.lang.String
string(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a string.protected java.lang.String
string(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key, java.lang.String defValue)
Returns the specified node property as a string, with a default fallback.
-
-
-
Method Detail
-
eventType
public java.lang.String eventType()
Returns the event type that this handler handles.- Returns:
- event type
-
process
public abstract void process(com.fasterxml.jackson.databind.node.ObjectNode payload)
Processes the incoming message payload from the client.- Parameters:
payload
- request message payload
-
get
protected <T> T get(java.lang.Class<T> serviceClass)
Returns an implementation of the specified service class.- Type Parameters:
T
- type of service- Parameters:
serviceClass
- service class- Returns:
- implementation class
- Throws:
ServiceNotFoundException
- if no implementation found
-
sendMessage
protected void sendMessage(java.lang.String eventType, com.fasterxml.jackson.databind.node.ObjectNode payload)
Sends a message back to the client with the given event type and payload.- Parameters:
eventType
- message event typepayload
- message payload
-
sendMessage
protected void sendMessage(com.fasterxml.jackson.databind.node.ObjectNode message)
Sends a message back to the client. Here, the message is preformatted; the assumption is that it has its "event" (event type) and "payload" attributes already filled in.- Parameters:
message
- the message to send
-
chain
protected void chain(java.lang.String eventType, com.fasterxml.jackson.databind.node.ObjectNode payload)
Allows one request handler to pass the event on to another for further processing. Note that the message handlers must be defined in the same parent.- Parameters:
eventType
- event typepayload
- message payload
-
string
protected java.lang.String string(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a string.- Parameters:
node
- message eventkey
- property name- Returns:
- property as a string
-
string
protected java.lang.String string(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key, java.lang.String defValue)
Returns the specified node property as a string, with a default fallback.- Parameters:
node
- object nodekey
- property namedefValue
- fallback value if property is absent- Returns:
- property as a string
-
bool
protected boolean bool(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a boolean. More precisely, if the value for the given key is the string "true" then this returns true, false otherwise.- Parameters:
node
- object nodekey
- property name- Returns:
- property as a boolean
-
number
protected long number(com.fasterxml.jackson.databind.node.ObjectNode node, java.lang.String key)
Returns the specified node property as a number.- Parameters:
node
- object nodekey
- property name- Returns:
- property as a number
-
-