|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.oakgrovesystems.reactor.requests.ReactorRequest
The superclass of the helper objects used to facilitate creation and fulfillment of requests to the Reactor system.
Requests to the Reactor system are composed of a request type, an authentication token, and a set of request-specific named parameters.
The request type indicates what kind of request is to be fulfilled. For example, the request type 'authentication_login' indicates that the request is a login request. The request type 'process_command_start' indicates that a Reactor Process is to be started.
The authentication token is a String that identifies the requester as an authenticated Reactor user. Authentication tokens are generated by the Reactor system in response to successful authentication requests. An authentication token is required for most types of requests to the Reactor system; the obvious exception being a login request. Authentication tokens may expire after a reasonable period of time.
The request parameters store details necessary for the fulfillment of the request. For example, a login request requires a username and password; a start request requires the identifier of the Process to start.
Subclasses of ReactorRequest make configuring requests easy by automatically setting the request type to the appropriate value and providing type-safe helper methods to use to set request-specific parameters.
So to make a request of the Reactor system, follow the steps below:
Field Summary | |
protected com.oakgrovesystems.reactor.processMediation.xml.OperandOutputter |
operandOutputter
|
protected com.oakgrovesystems.reactor.processMediation.xml.PolicyOutputter |
policyOutputter
|
protected com.oakgrovesystems.reactor.processMediation.xml.ProcessOutputter |
processOutputter
|
protected com.oakgrovesystems.reactor.processMediation.xml.StatusOutputter |
statusOutputter
|
Constructor Summary | |
ReactorRequest()
|
Method Summary | |
void |
configureFromXML(com.oakgrovesystems.xml.XMLObject request)
configures this ReactorRequest from its XML representation |
void |
configureFromXML(com.oakgrovesystems.xml.XMLObject request,
com.oakgrovesystems.reactor.LabelPathToIdMapper mapper)
configures this ReactorRequest from its XML representation |
com.oakgrovesystems.xml.XMLObject |
createResponseXML(com.oakgrovesystems.reactor.ReactorResponse response)
Creates the XML representation of a response from its ReactorResponse Java representation. |
com.oakgrovesystems.xml.XMLObject |
createResponseXML(com.oakgrovesystems.reactor.ReactorResponse response,
com.oakgrovesystems.reactor.IdToLabelPathMapper mapper)
Creates the XML representation of a response from its ReactorResponse Java representation. |
protected static org.jdom.Element |
createReturnValuesElem(java.lang.String[][] returns)
Creates a 'return_values' JDOM Element from the given array of key-value pairs. |
protected org.jdom.Element |
createRtnValXML(com.oakgrovesystems.reactor.ReactorResponse response,
com.oakgrovesystems.reactor.IdToLabelPathMapper mapper)
This (superclass) implementation simply returns null, which is perfect for requests that don't have return values. |
java.lang.String |
getAuthToken()
Gets the authentication token for this request. |
protected static com.oakgrovesystems.reactor.LabelPath |
getLabelPath(org.jdom.Element parent)
If the Element specified has an 'object_reference' child and that child has a 'label_path' child, then the method returns a ReactorObjectId instantiated from the 'label_path' Element. |
protected static com.oakgrovesystems.reactor.ReactorObjectId |
getObjectId(org.jdom.Element parent)
If the Element specified has an 'object_reference' child and that child has an 'id' child, then the method returns a ReactorObjectId instantiated from the text content of the 'id' Element. |
java.lang.Object |
getParameter(java.lang.String name)
Returns the value of the named request parameter. |
java.lang.Object |
getParameter(java.lang.String name,
java.lang.Class type)
Returns the value of the named request parameter if the value is assignment compatible with the given class. |
java.util.Set |
getParameterNames()
returns a set containing the names of the request parameters that have been set. |
java.lang.String |
getRequestType()
Gets the request type for this request. |
protected java.lang.String |
makeAuthTokenXML(java.lang.String token)
|
protected org.jdom.Element |
makeObjectElement(java.lang.Object obj)
|
protected org.jdom.Element |
makeOperandElement(com.oakgrovesystems.reactor.processMediation.Operand obj)
|
protected org.jdom.Element |
makePolicyElement(com.oakgrovesystems.reactor.processMediation.Policy obj)
|
protected org.jdom.Element |
makeProcessElement(com.oakgrovesystems.reactor.processMediation.Process obj)
|
protected org.jdom.Element |
makeReferenceElement(com.oakgrovesystems.reactor.ReactorObjectId id,
com.oakgrovesystems.reactor.LabelPath labelPath)
|
protected org.jdom.Element |
makeStatusElement(com.oakgrovesystems.reactor.processMediation.Status obj)
|
protected abstract java.util.List |
paramsToXML()
Returns a List of Elements representing the parameters of the request |
protected abstract void |
parseParameters(org.jdom.Element params,
com.oakgrovesystems.reactor.LabelPathToIdMapper mapper)
Configures the parameters from the XML representation |
com.oakgrovesystems.reactor.ReactorResponse |
parseResponse(com.oakgrovesystems.xml.XMLObject xml)
Parses an XML response to this ReactorRequest. |
protected abstract com.oakgrovesystems.reactor.ReactorResponse |
parseReturnValues(org.jdom.Element returnValues)
|
com.oakgrovesystems.reactor.ReactorResponse |
send()
Sends the request to Reactor to be fulfilled. |
com.oakgrovesystems.xml.XMLObject |
sendAsXML(java.net.URL xmlServerURL)
Sends the request to Reactor's XML Front Desk servlet for fulfillment. |
com.oakgrovesystems.reactor.ReactorResponse |
sendViaHttp(java.net.URL xmlServerURL)
Sends the request to Reactor's XML Front Desk servlet for fulfillment, and then parses the XML response into a ReactorResponse. |
void |
setAuthToken(java.lang.String authToken)
Sets the authentication token for this request. |
protected void |
setParameter(java.lang.String name,
java.lang.Object value)
sets a request parameter for this request |
protected void |
setRequestType(java.lang.String requestType)
Sets the type of request. |
java.lang.String |
toString()
Returns a String representation of this ReactorRequest |
com.oakgrovesystems.xml.XMLObject |
toXML()
Creates an XML representation of this request suitable for sending to Reactor's XML Front Desk servlet. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected com.oakgrovesystems.reactor.processMediation.xml.ProcessOutputter processOutputter
protected com.oakgrovesystems.reactor.processMediation.xml.OperandOutputter operandOutputter
protected com.oakgrovesystems.reactor.processMediation.xml.StatusOutputter statusOutputter
protected com.oakgrovesystems.reactor.processMediation.xml.PolicyOutputter policyOutputter
Constructor Detail |
public ReactorRequest()
Method Detail |
public java.lang.String getRequestType()
protected void setRequestType(java.lang.String requestType)
requestType
- the type of this requestpublic java.lang.String getAuthToken()
public void setAuthToken(java.lang.String authToken)
public java.lang.Object getParameter(java.lang.String name, java.lang.Class type)
name
- the name of the parameter to gettype
- the Class of the value of the named parameter
public java.lang.Object getParameter(java.lang.String name)
name
- the name of the parameter to get
public java.util.Set getParameterNames()
protected void setParameter(java.lang.String name, java.lang.Object value)
name
- the name of the parameter to setvalue
- the value to which the named parameter should be setpublic java.lang.String toString()
toString
in class java.lang.Object
public com.oakgrovesystems.reactor.ReactorResponse send()
public com.oakgrovesystems.reactor.ReactorResponse sendViaHttp(java.net.URL xmlServerURL) throws java.io.IOException
xmlServerURL
- The URL of the Reactor XML Front Desk servlet.
java.io.IOException
- if an IO error occurspublic com.oakgrovesystems.xml.XMLObject sendAsXML(java.net.URL xmlServerURL) throws java.io.IOException, FailedRequestException
xmlServerURL
- The URL of the Reactor XML Front Desk servlet.
java.io.IOException
- if an IO error occurs
FailedRequestException
public com.oakgrovesystems.xml.XMLObject createResponseXML(com.oakgrovesystems.reactor.ReactorResponse response)
response
- the ReactorResponse to translate to XML
public com.oakgrovesystems.xml.XMLObject createResponseXML(com.oakgrovesystems.reactor.ReactorResponse response, com.oakgrovesystems.reactor.IdToLabelPathMapper mapper)
response
- the ReactorResponse to translate to XMLmapper
- object to convert IDs to label paths in return values
protected org.jdom.Element createRtnValXML(com.oakgrovesystems.reactor.ReactorResponse response, com.oakgrovesystems.reactor.IdToLabelPathMapper mapper) throws FailedRequestException
response
- the ReactorResponse to translate to XML.mapper
- object to convert IDs to label paths in return values
FailedRequestException
- if the return values Element can't be createdpublic com.oakgrovesystems.reactor.ReactorResponse parseResponse(com.oakgrovesystems.xml.XMLObject xml) throws FailedRequestException
FailedRequestException
- if there is an error parsing the XMLprotected abstract com.oakgrovesystems.reactor.ReactorResponse parseReturnValues(org.jdom.Element returnValues) throws FailedRequestException
FailedRequestException
public com.oakgrovesystems.xml.XMLObject toXML() throws FailedRequestException
FailedRequestException
protected abstract java.util.List paramsToXML() throws FailedRequestException
FailedRequestException
public void configureFromXML(com.oakgrovesystems.xml.XMLObject request) throws FailedRequestException
request
- the XML request to parse and use to configure this request
FailedRequestException
- if the request type is not appropriate for this subclass of
ReactorRequest or if there is an error parsing the XML.public void configureFromXML(com.oakgrovesystems.xml.XMLObject request, com.oakgrovesystems.reactor.LabelPathToIdMapper mapper) throws FailedRequestException
request
- the XML request to parse and use to configure this requestmapper
- object to convert label paths to IDs in response XML
FailedRequestException
- if the request type is not appropriate for this subclass of
ReactorRequest or if there is an error parsing the XML.protected abstract void parseParameters(org.jdom.Element params, com.oakgrovesystems.reactor.LabelPathToIdMapper mapper) throws FailedRequestException
params
- the 'parameters' Element of the request
FailedRequestException
- if the parameters can't be configured from the XML.protected static com.oakgrovesystems.reactor.ReactorObjectId getObjectId(org.jdom.Element parent)
protected static com.oakgrovesystems.reactor.LabelPath getLabelPath(org.jdom.Element parent)
protected static org.jdom.Element createReturnValuesElem(java.lang.String[][] returns)
returns
- an array of key-value pairs.
protected java.lang.String makeAuthTokenXML(java.lang.String token)
protected org.jdom.Element makeReferenceElement(com.oakgrovesystems.reactor.ReactorObjectId id, com.oakgrovesystems.reactor.LabelPath labelPath) throws FailedRequestException
FailedRequestException
protected org.jdom.Element makeObjectElement(java.lang.Object obj) throws FailedRequestException
FailedRequestException
protected org.jdom.Element makeProcessElement(com.oakgrovesystems.reactor.processMediation.Process obj)
protected org.jdom.Element makeOperandElement(com.oakgrovesystems.reactor.processMediation.Operand obj)
protected org.jdom.Element makeStatusElement(com.oakgrovesystems.reactor.processMediation.Status obj)
protected org.jdom.Element makePolicyElement(com.oakgrovesystems.reactor.processMediation.Policy obj)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |