public abstract class Request<T extends Response> extends Object implements Runnable
Constructor and Description |
---|
Request(BroadWorksServer broadWorksServer,
String commandType,
Class<T> clazz)
The Default Request Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendChild(Element e)
Add an XML element child to this command.
|
protected void |
appendChild(String tagName)
Append an empty tag to a command; this creates an element with no
content.
|
protected void |
appendChild(String tagName,
String value)
Creates and appends a text element with the given name and value to the
command element.
|
void |
asyncFire(ResponseHandler<T> handler)
Fires the request on it's own thread and returns the response to the
provided handler.
|
protected Element |
createElement(String tagName)
Get a new, empty element having the name specified.
|
protected Element |
createNilElement(String tagName)
Get a new element specified as "xsi:nil"
|
protected Element |
createTextElement(String tagName,
String value)
Get a new text element with given name and value
|
T |
fire()
This generates a Response object from a Request.
|
T |
fire(boolean readFromCache)
This generates a Response object from a Request.
|
protected abstract void |
formRequest()
This method is used to append elements to a request before it is sent
|
BroadWorksServer |
getBroadWorksServer() |
protected String |
getCommandType()
Returns the base XML command type.
|
Document |
getDomDocument() |
protected Class<T> |
getResponseClass()
Returns the Class object of the Response.
|
boolean |
isMemberOfBundle() |
boolean |
isValid()
Returns True iff the Request has no constraint violations
|
void |
run()
Method to handle the request when firing on a distinct thread.
|
void |
setBroadWorksServer(BroadWorksServer broadWorksServer) |
protected void |
setCommandElement(Element commandElement)
Overrides the set Command element for the Request.
|
void |
setCommandType(String commandType) |
protected void |
setDomDocument(Document domDocument)
Overrides the default DOM document for the Request.
|
protected void |
setMemberOfBundle(boolean isMemberOfBundle)
Sets the Request as member of Bundle.
|
void |
setRequestId(String id)
Sets the RequestID to the given value.
|
void |
setResponseClass(Class<T> responseClass) |
protected void |
setRootElement(Element rootElement)
Overrides the default Root element for the Request.
|
String |
toString()
The RequestBundle as transformed into the expected XML message
|
Set<javax.validation.ConstraintViolation<Request<T>>> |
validate()
Returns the list of Constraint Violations for the Request
|
public Request(BroadWorksServer broadWorksServer, String commandType, Class<T> clazz)
broadWorksServer
- commandType
- clazz
- protected void appendChild(Element e) throws RequestException
e
- The Element to append to the command element.RequestException
- Exception is thrown if the underlying DOM Document has not
been initialized.protected void appendChild(String tagName) throws RequestException
tagName
- The name of the empty element to append to the command
element.RequestException
- Exception is thrown if the underlying DOM Document has not
been initialized.protected void appendChild(String tagName, String value) throws RequestException
tagName
- The name of the element to append.value
- The value of the element to append.RequestException
- Exception is thrown if the underlying DOM Document has not
been initialized.public void asyncFire(ResponseHandler<T> handler) throws RequestException
handler
- The handler to return the Response toward following execution
completion.RequestException
protected Element createElement(String tagName)
tagName
- protected Element createNilElement(String tagName)
tagName
- protected Element createTextElement(String tagName, String value)
tagName
- value
- public T fire() throws RequestException
RequestException
public T fire(boolean readFromCache) throws RequestException
readFromCache
- RequestException
protected abstract void formRequest() throws RequestException
RequestException
public BroadWorksServer getBroadWorksServer()
protected String getCommandType()
public Document getDomDocument()
protected Class<T> getResponseClass()
public boolean isMemberOfBundle()
public boolean isValid()
public void run()
public void setBroadWorksServer(BroadWorksServer broadWorksServer)
protected void setCommandElement(Element commandElement)
commandElement
- public void setCommandType(String commandType)
protected void setDomDocument(Document domDocument)
domDocument
- protected void setMemberOfBundle(boolean isMemberOfBundle)
isMemberOfBundle
- public void setRequestId(String id)
id
- The request IDprotected void setRootElement(Element rootElement)
rootElement
- public String toString()
Copyright © 2016 ECG, Inc. All rights reserved.