public abstract class Request<T extends Response> extends Object implements Runnable
Modifier and Type | Class and Description |
---|---|
static class |
Request.Protocol |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.logging.log4j.Logger |
log |
Constructor and Description |
---|
Request(BroadWorksServer broadWorksServer,
String commandType,
Class<T> clazz)
The Default Request Constructor.
|
Request(BroadWorksServer broadWorksServer,
String commandType,
Class<T> clazz,
Request.Protocol protocol)
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 void |
createDocument()
Creates the XML Dom Document for this request.
|
Element |
createElement(String tagName)
Get a new, empty element having the name specified.
|
Element |
createNilElement(String tagName)
Get a new element specified as "xsi:nil"
|
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 void |
formRequest()
This method is used to append elements to a request before it is sent
|
BroadWorksServer |
getBroadWorksServer() |
protected Element |
getCommandElement() |
String |
getCommandType()
Returns the base XML command type.
|
Document |
getDomDocument() |
String |
getId()
Retrieves the ID of the Request
|
Class<T> |
getResponseClass()
Returns the Class object of the Response.
|
protected Element |
getRootElement() |
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
- The BroadWorks server for the request.commandType
- The OCI command type for the request.clazz
- The class of the Response
.public Request(BroadWorksServer broadWorksServer, String commandType, Class<T> clazz, Request.Protocol protocol)
broadWorksServer
- The BroadWorks server for the request.commandType
- The OCI command type for the request.clazz
- The class of the Response
.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 void createDocument()
public Element createElement(String tagName)
tagName
- The tag name of the element.public Element createNilElement(String tagName)
tagName
- The tag name of the nil element.public Element createTextElement(String tagName, String value)
tagName
- The tag name of the text element.value
- The value of the text element.public T fire() throws RequestException
RequestException
public T fire(boolean readFromCache) throws RequestException
readFromCache
- Enables reading from the JCS cache for retrieving the response. Defaults to 'true'.RequestException
protected void formRequest() throws RequestException
RequestException
public BroadWorksServer getBroadWorksServer()
public void setBroadWorksServer(BroadWorksServer broadWorksServer)
protected Element getCommandElement()
protected void setCommandElement(Element commandElement)
commandElement
- The command element for the request.public String getCommandType()
public void setCommandType(String commandType)
public Document getDomDocument()
protected void setDomDocument(Document domDocument)
domDocument
- The DOM document for the request.public Class<T> getResponseClass()
protected Element getRootElement()
protected void setRootElement(Element rootElement)
rootElement
- The root element for the request.public boolean isMemberOfBundle()
protected void setMemberOfBundle(boolean isMemberOfBundle)
isMemberOfBundle
- The boolean value designating if the Request is a member of a bundle.public boolean isValid()
public String getId()
public void run()
public void setRequestId(String id)
id
- The request IDpublic String toString()
Copyright © 2016 ECG. All rights reserved.