public class XSLTCallingConvention extends StandardCallingConvention
Manageable.State
Modifier and Type | Field and Description |
---|---|
protected static String |
CLEAR_TEMPLATE_CACHE_PARAMETER
The name of the input parameter used to clear the template cache.
|
protected static String |
TEMPLATE_PARAMETER
The name of the input parameter that specifies the location of the XSLT
template to use.
|
protected static String |
TEMPLATES_CACHE_PROPERTY
The name of the runtime property that defines if the templates should be
cached.
|
RESPONSE_CONTENT_TYPE, RESPONSE_ENCODING
BOOTSTRAPPED, BOOTSTRAPPING, DEINITIALIZING, INITIALIZING, UNUSABLE, USABLE
Constructor and Description |
---|
XSLTCallingConvention()
Constructs a new
XSLTCallingConvention object. |
Modifier and Type | Method and Description |
---|---|
protected FunctionRequest |
convertRequestImpl(HttpServletRequest httpRequest)
Converts an HTTP request to a XINS request (implementation method).
|
protected void |
convertResultImpl(FunctionResult xinsResult,
HttpServletResponse httpResponse,
Map<String,Object> backpack)
Converts a XINS result to an HTTP response (implementation method).
|
protected API |
getAPI()
Determines the current API.
|
protected String[] |
getSupportedMethods()
Determines which HTTP methods are supported for function invocations.
|
protected String[] |
getSupportedMethods(HttpServletRequest request)
Determines which HTTP methods are supported for function invocations,
for the specified request.
|
protected void |
initImpl(Map<String,String> runtimeProperties)
Performs the initialization procedure (actual implementation).
|
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.
|
matches
assertUsable, bootstrap, bootstrapImpl, deinit, deinitImpl, getState, init, isBootstrapped, isUsable
protected static final String TEMPLATES_CACHE_PROPERTY
"true"
or "false"
.
By default the cache is enabled.protected static final String TEMPLATE_PARAMETER
protected static final String CLEAR_TEMPLATE_CACHE_PARAMETER
public XSLTCallingConvention()
XSLTCallingConvention
object.protected void initImpl(Map<String,String> runtimeProperties) throws MissingRequiredPropertyException, InvalidPropertyValueException, InitializationException
Manageable
Manageable.init(Map)
, the state and the
argument will have been checked and the state will have been set to
Manageable.INITIALIZING
.
The implementation of this method in class Manageable
is
empty.
initImpl
in class Manageable
runtimeProperties
- the initialization properties, not null
.MissingRequiredPropertyException
- if a required property is not given.InvalidPropertyValueException
- if the value of a certain property is invalid.InitializationException
- if the initialization failed, for any other reason.protected FunctionRequest convertRequestImpl(HttpServletRequest httpRequest) throws InvalidRequestException, FunctionNotSpecifiedException
StandardCallingConvention
httpRequest
argument is not
null
.convertRequestImpl
in class StandardCallingConvention
httpRequest
- the HTTP request, will not be null
.null
.InvalidRequestException
- if the request is considerd to be invalid.FunctionNotSpecifiedException
- if the request does not indicate the name of the function to execute.protected void convertResultImpl(FunctionResult xinsResult, HttpServletResponse httpResponse, Map<String,Object> backpack) throws IOException
StandardCallingConvention
convertResultImpl
in class StandardCallingConvention
xinsResult
- the XINS result object that should be converted to an HTTP response,
will not be null
.httpResponse
- the HTTP response object to configure, will not be null
.backpack
- the request backpack, will not be null
.IOException
- if calling any of the methods in httpResponse
causes an
I/O error.protected final API getAPI()
API
, never null
.protected String[] getSupportedMethods()
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.
String
array, must
not be null
.protected String[] getSupportedMethods(HttpServletRequest 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
getSupportedMethods()
.
The default implementation of this method returns the set returned by
getSupportedMethods()
.
request
- the request to determine the supported methods for.String
array, can be null
.protected Element parseXMLRequest(HttpServletRequest httpRequest) throws IllegalArgumentException, InvalidRequestException
This method uses a cache to optimize performance if either of the
parseXMLRequest
methods is called multiple times for the
same request.
Calling this method is equivalent with calling
parseXMLRequest(HttpServletRequest,boolean)
with the
checkType
argument set to true
.
httpRequest
- the HTTP request, cannot be null
.null
.IllegalArgumentException
- if httpRequest == null
.InvalidRequestException
- if the HTTP request cannot be read or cannot be parsed correctly.protected Element parseXMLRequest(HttpServletRequest httpRequest, boolean checkType) throws IllegalArgumentException, InvalidRequestException
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.
httpRequest
- the HTTP request, cannot be null
.checkType
- flag indicating whether this method should check that the content
type of the request is text/xml.null
.IllegalArgumentException
- if httpRequest == null
.InvalidRequestException
- if the HTTP request cannot be read or cannot be parsed correctly.See http://www.xins.org/.