public abstract class Request<T extends Response> extends Object
The Request can be fired directly to return the expected Response. Alternatively it can be added to a RequestBundle to be included in a single group XML document.
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(Consumer<T> consumer)
Fire this Request asynchronously with the provided Response consumer.
|
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 using the
RequestBundler . |
void |
fire(Consumer<T> consumer)
Fire this Request with the provided Response consumer.
|
protected void |
formRequest()
This method is used to append elements to a request before it is sent
|
BroadWorksServer |
getBroadWorksServer() |
String |
getCacheString()
Returns the Request's command element -- removing the xsi namespace to make it XML valid
|
Element |
getCommandElement() |
String |
getCommandType()
Returns the base XML command type.
|
Document |
getDomDocument() |
String |
getId()
Retrieves the ID of the Request
|
Request.Protocol |
getOCSProtocol()
Get the OCS protocol
|
long |
getRequestTimeoutMillis()
Gets the socket request timeout for this request.
|
Class<T> |
getResponseClass()
Returns the Class object of the Response.
|
protected Element |
getRootElement() |
String |
getValidationErrorsAsString()
Returns the request validation errors as a human readable string.
|
boolean |
isMemberOfBundle() |
boolean |
isValid()
Returns True iff the Request has no constraint violations
|
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 |
setRequestTimeoutMillis(long requestTimeoutMillis)
Sets the socket request timeout for this request.
|
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 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()
RequestBundler
.public void fire(Consumer<T> consumer)
consumer
- The consumer for the Response.public void asyncFire(Consumer<T> consumer)
consumer
- The consumer for the Response.protected void formRequest() throws RequestException
RequestException
public BroadWorksServer getBroadWorksServer()
public void setBroadWorksServer(BroadWorksServer broadWorksServer)
public 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 setRequestId(String id)
id
- The request IDpublic long getRequestTimeoutMillis()
public void setRequestTimeoutMillis(long requestTimeoutMillis)
requestTimeoutMillis
- The timeout in milliseconds.public Request.Protocol getOCSProtocol()
public String toString()
public String getCacheString()
public Set<javax.validation.ConstraintViolation<Request<T>>> validate()
public String getValidationErrorsAsString()
Copyright © 2017 ECG. All rights reserved.