| java.lang.Object org.xins.common.manageable.Manageable org.xins.server.CallingConvention
All known Subclasses: org.xins.server.XMLRPCCallingConvention, org.xins.server.CustomCallingConvention, org.xins.server.JSONCallingConvention, org.xins.server.JSONRPCCallingConvention, org.xins.server.XMLCallingConvention, org.xins.server.SOAPCallingConvention, org.xins.server.StandardCallingConvention,
CallingConvention | abstract class CallingConvention extends Manageable (Code) | | Abstraction of a calling convention. A calling convention determines how an
HTTP request is converted to a XINS function invocation request and how a
XINS function result is converted back to an HTTP response.
Thread safety
Calling convention implementations must be thread-safe.
version: $Revision: 1.105.2.1 $ $Date: 2007/09/27 14:43:33 $ author: Anthony Goubard author: Ernst de Haan See Also: CallingConventionManager |
Constructor Summary | |
protected | CallingConvention() Constructs a new CallingConvention . |
Method Summary | |
static void | cleanUpParameters(BasicPropertyReader parameters) Changes a parameter set to remove all parameters that should not be
passed to functions. | final FunctionRequest | convertRequest(HttpServletRequest httpRequest) Converts an HTTP request to a XINS request (wrapper method). | abstract protected FunctionRequest | convertRequestImpl(HttpServletRequest httpRequest) Converts an HTTP request to a XINS request (implementation method). | final void | convertResult(FunctionResult xinsResult, HttpServletResponse httpResponse, HttpServletRequest httpRequest) Converts a XINS result to an HTTP response (wrapper method). | abstract protected void | convertResultImpl(FunctionResult xinsResult, HttpServletResponse httpResponse, HttpServletRequest httpRequest) Converts a XINS result to an HTTP response (implementation method). | BasicPropertyReader | gatherParams(HttpServletRequest httpRequest) Gathers all parameters from the specified request. | final protected API | getAPI() Determines the current API. | final String | getConventionName() Gets the name of the convention associated with this CC. | protected String[] | getSupportedMethods() Determines which HTTP methods are supported for function invocations.
Each String in the returned array must be one
supported method.
The returned array must not be null , it must only
contain valid HTTP method names, so they may not contain whitespace, for
example. | protected String[] | getSupportedMethods(HttpServletRequest request) Determines which HTTP methods are supported for function invocations,
for the specified request.
Each String in the returned array must be one
supported method.
The returned array may be null . | abstract protected boolean | matches(HttpServletRequest httpRequest) Checks if the specified request can possibly be handled by this calling
convention as a function invocation.
Implementations of this method should be optimized for performance,
as this method may be called for each incoming request. | final boolean | matchesRequest(HttpServletRequest httpRequest) Checks if the specified request can be handled by this calling
convention. | protected Element | parseXMLRequest(HttpServletRequest httpRequest) Parses XML from the specified HTTP request and checks that the content
type is correct. | protected Element | parseXMLRequest(HttpServletRequest httpRequest, boolean checkType) Parses XML from the specified HTTP request and optionally checks that
the content type is correct. | final void | setAPI(API api) Sets the current API. | final void | setConventionName(String conventionName) Sets the name of the convention associated with this CC. |
CallingConvention | protected CallingConvention()(Code) | | Constructs a new CallingConvention . A
CallingConvention instance can only be generated by the
XINS/Java Server Framework.
|
cleanUpParameters | static void cleanUpParameters(BasicPropertyReader parameters) throws IllegalArgumentException(Code) | | Changes a parameter set to remove all parameters that should not be
passed to functions.
A parameter will be removed if it matches any of the following
conditions:
- parameter name is
null ;
- parameter name is empty;
- parameter value is
null ;
- parameter value is empty;
- parameter name equals
"function" .
Parameters: parameters - the BasicPropertyReader containing the set of parametersto investigate, cannot be null . throws: IllegalArgumentException - if parameters == null . |
convertRequest | final FunctionRequest convertRequest(HttpServletRequest httpRequest) throws IllegalStateException, IllegalArgumentException, InvalidRequestException, FunctionNotSpecifiedException(Code) | | Converts an HTTP request to a XINS request (wrapper method). This method
checks the arguments, checks that the HTTP method is actually supported,
calls the implementation method and then checks the return value from
that method.
Parameters: httpRequest - the HTTP request, cannot be null .the XINS request object, never null . throws: IllegalStateException - if this calling convention is currently not usable, seeManageable.assertUsable. throws: IllegalArgumentException - if httpRequest == null . throws: InvalidRequestException - if the request is considerd to be invalid, at least for this callingconvention; either because the HTTP method is not supported, orbecause CallingConvention.convertRequestImpl(HttpServletRequest) indicates so. throws: FunctionNotSpecifiedException - if the request does not indicate the name of the function to execute. |
convertResult | final void convertResult(FunctionResult xinsResult, HttpServletResponse httpResponse, HttpServletRequest httpRequest) throws IllegalStateException, IllegalArgumentException, IOException(Code) | | Converts a XINS result to an HTTP response (wrapper method). This method
checks the arguments, then calls the implementation method and then
checks the return value from that method.
Note that this method is not called if there is an error while
converting the request.
Parameters: xinsResult - the XINS result object that should be converted to an HTTP response,cannot be null . Parameters: httpResponse - the HTTP response object to configure, cannot be null . Parameters: httpRequest - the HTTP request, cannot be null . throws: IllegalStateException - if this calling convention is currently not usable, seeManageable.assertUsable. throws: IllegalArgumentException - if xinsResult == null|| httpResponse == null|| httpRequest == null . throws: IOException - if the invocation of any of the methods in eitherhttpResponse or httpRequest caused an I/Oerror. |
convertResultImpl | abstract protected void convertResultImpl(FunctionResult xinsResult, HttpServletResponse httpResponse, HttpServletRequest httpRequest) throws IOException(Code) | | Converts a XINS result to an HTTP response (implementation method). This
method should only be called from the XINS/Java Server Framework self.
Then it is guaranteed that none of the arguments is null .
Parameters: xinsResult - the XINS result object that should be converted to an HTTP response,will not be null . Parameters: httpResponse - the HTTP response object to configure. Parameters: httpRequest - the HTTP request. throws: IOException - if the invocation of any of the methods in eitherhttpResponse or httpRequest caused an I/Oerror. |
getAPI | final protected API getAPI()(Code) | | Determines the current API.
the current API, never null . since: XINS 1.5.0 |
getConventionName | final String getConventionName()(Code) | | Gets the name of the convention associated with this CC.
the name of this calling convention, never null . since: XINS 2.1 |
getSupportedMethods | protected String[] getSupportedMethods()(Code) | | Determines which HTTP methods are supported for function invocations.
Each String in the returned array must be one
supported method.
The returned array must not be null , it must only
contain valid HTTP method names, so they may not contain whitespace, for
example. Duplicates will be ignored. HTTP method names must be in uppercase.
There must be at least one HTTP method supported for function
invocations.
Note that OPTIONS must not be returned by this method, as it
is not an HTTP method that can ever be used to invoke a XINS function.
HTTP OPTIONS requests are treated differently. For the path
* the capabilities of the whole server are returned. For other
paths, the appropriate calling convention is determined, after which the
set of supported HTTP methods is returned to the called.
the HTTP methods supported, in a String array, mustnot be null . since: XINS 1.5.0 |
getSupportedMethods | protected String[] getSupportedMethods(HttpServletRequest request)(Code) | | Determines which HTTP methods are supported for function invocations,
for the specified request.
Each String in the returned array must be one
supported method.
The returned array may be null . If it is not, then the
returned array must only contain valid HTTP method names, so they may
not contain whitespace, for example. HTTP method names must be in uppercase.
There must be at least one HTTP method supported for function
invocations.
Note that OPTIONS must not be returned by this method, as it
is not an HTTP method that can ever be used to invoke a XINS function.
The set of supported methods must be a subset of the set returned by
CallingConvention.getSupportedMethods() .
The default implementation of this method returns the set returned by
CallingConvention.getSupportedMethods() .
Parameters: request - the request to determine the supported methods for.the HTTP methods supported for the specified request, in aString array, can be null . since: XINS 1.5.0 |
matches | abstract protected boolean matches(HttpServletRequest httpRequest) throws Exception(Code) | | Checks if the specified request can possibly be handled by this calling
convention as a function invocation.
Implementations of this method should be optimized for performance,
as this method may be called for each incoming request. Also, this
method should not have any side-effects except possibly some caching in
case there is a match.
If this method throws any exception, the exception is logged as an
ignorable exception and false is assumed.
This method should only be called by the XINS/Java Server Framework.
Parameters: httpRequest - the HTTP request to investigate, never null .true if this calling convention is possiblyable to handle this request, or false if it isdefinitely not able to handle this request. throws: Exception - if analysis of the request causes an exception; in this casefalse will be assumed by the framework. since: XINS 1.4.0 |
matchesRequest | final boolean matchesRequest(HttpServletRequest httpRequest)(Code) | | Checks if the specified request can be handled by this calling
convention. Assuming this CallingConvention instance is
usable and the HTTP method is supported, this method delegates to
CallingConvention.matches(HttpServletRequest) .
If this calling convention is not usable (see
CallingConvention.isUsable() ),
then false is returned, even before calling
CallingConvention.matches(HttpServletRequest) .
If this method does not support the HTTP method for function
invocations, then false is returned.
If
CallingConvention.matches(HttpServletRequest) throws an exception, then
this exception is ignored and false is returned.
This method is guaranteed not to throw any exception.
Parameters: httpRequest - the HTTP request to investigate, cannot be null .true if this calling convention is possiblyable to handle this request, or false if it isdefinitely not able to handle this request. |
parseXMLRequest | protected Element parseXMLRequest(HttpServletRequest httpRequest, boolean checkType) throws IllegalArgumentException, InvalidRequestException(Code) | | Parses XML from the specified HTTP request and optionally checks that
the content type is correct.
Since XINS 1.4.0, this method uses a cache to optimize performance if
either of the parseXMLRequest methods is called multiple
times for the same request.
Parameters: httpRequest - the HTTP request, cannot be null . Parameters: checkType - flag indicating whether this method should check that the contenttype of the request is text/xml.the parsed element, never null . throws: IllegalArgumentException - if httpRequest == null . throws: InvalidRequestException - if the HTTP request cannot be read or cannot be parsed correctly. since: XINS 1.3.0 |
setAPI | final void setAPI(API api)(Code) | | Sets the current API.
Parameters: api - the current API, never null . |
setConventionName | final void setConventionName(String conventionName)(Code) | | Sets the name of the convention associated with this CC.
Parameters: conventionName - the calling convention name, never null . since: XINS 2.1 |
Methods inherited from org.xins.common.manageable.Manageable | final protected void assertUsable() throws IllegalStateException(Code)(Java Doc) final public void bootstrap(PropertyReader properties) throws IllegalStateException, MissingRequiredPropertyException, InvalidPropertyValueException, BootstrapException(Code)(Java Doc) protected void bootstrapImpl(PropertyReader properties) throws MissingRequiredPropertyException, InvalidPropertyValueException, BootstrapException(Code)(Java Doc) final public void deinit() throws IllegalStateException, DeinitializationException(Code)(Java Doc) protected void deinitImpl() throws Throwable(Code)(Java Doc) final public State getState()(Code)(Java Doc) final public void init(PropertyReader properties) throws IllegalStateException, MissingRequiredPropertyException, InvalidPropertyValueException, InitializationException(Code)(Java Doc) protected void initImpl(PropertyReader properties) throws MissingRequiredPropertyException, InvalidPropertyValueException, InitializationException(Code)(Java Doc) final public boolean isBootstrapped()(Code)(Java Doc) final public boolean isUsable()(Code)(Java Doc)
|
|
|