Class AbstractRuntime
java.lang.Object
org.springframework.extensions.webscripts.AbstractRuntime
- All Implemented Interfaces:
Runtime
- Direct Known Subclasses:
WebScriptServletRuntime
Encapsulates the execution of a single Web Script.
Sub-classes of WebScriptRuntime maintain the execution environment e.g. servlet
request & response.
A new instance of WebScriptRuntime is required for each invocation.
- Author:
- davidc
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RuntimeContainerComponent Dependenciesprotected static final org.apache.commons.logging.Logprotected static final org.apache.commons.logging.Logprotected WebScriptSession -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbeforeProcessError(Match match, Throwable e) Before processing an error exception - hook point to allow additional processing of the exception based on the runtime.protected abstract AuthenticatorCreate a Web Script Authenticatorprotected abstract WebScriptRequestcreateRequest(Match match) Create a Web Script Requestprotected abstract WebScriptResponseCreate a Web Script Responseprotected abstract WebScriptSessionFactoryCreate a Web Script Sessionfinal voidExecute the Web Script encapsulated by this Web Script Runtimeprotected voidexecuteScript(WebScriptRequest scriptReq, WebScriptResponse scriptRes, Authenticator auth) Execute script given the specified contextGets the Web Script Container within which this Runtime is hostedprotected StatusTemplategetFormatStatusTemplate(String format) Get format Status Template pathprotected static WebScriptRequestgetRealWebScriptRequest(WebScriptRequest request) Helper to retrieve real (last) Web Script Request in a stack of wrapped Web Script requestsprotected static WebScriptResponsegetRealWebScriptResponse(WebScriptResponse response) Helper to retrieve real (last) Web Script Response in a stack of wrapped Web Script responsesprotected abstract StringGet the Web Script Method e.g.Gets script parametersprotected abstract StringGet the Web Script UrlGet the Web Script Sessionprotected StatusTemplategetStatusCodeTemplate(int statusCode) Get code specific Status Template pathprotected StatusTemplateGet Status Template pathGets template parametersprotected voidrenderErrorResponse(Match match, Throwable exception, WebScriptRequest request, WebScriptResponse response) Renders an error message to the response based on the Throwable exception passed in.voidsetURLModelFactory(URLModelFactory urlModelFactory)
-
Field Details
-
logger
protected static final org.apache.commons.logging.Log logger -
exceptionLogger
protected static final org.apache.commons.logging.Log exceptionLogger -
container
Component Dependencies -
session
-
-
Constructor Details
-
AbstractRuntime
Construct- Parameters:
container- web script context
-
-
Method Details
-
getContainer
Description copied from interface:RuntimeGets the Web Script Container within which this Runtime is hosted- Specified by:
getContainerin interfaceRuntime- Returns:
- web script container
-
getSession
Description copied from interface:RuntimeGet the Web Script Session- Specified by:
getSessionin interfaceRuntime- Returns:
- web script session
-
setURLModelFactory
-
executeScript
public final void executeScript()Execute the Web Script encapsulated by this Web Script Runtime -
renderErrorResponse
protected void renderErrorResponse(Match match, Throwable exception, WebScriptRequest request, WebScriptResponse response) Renders an error message to the response based on the Throwable exception passed in.- Parameters:
match-exception-request-response-
-
beforeProcessError
Before processing an error exception - hook point to allow additional processing of the exception based on the runtime. This allows runtime to handle errors themselves if required - for example silently ignoring missing webscripts.- Parameters:
match- WebScript that was processed and caused the errore- Exception that occured during webscript processing- Returns:
- true to continue default error processing, false to assume handling is complete
-
executeScript
protected void executeScript(WebScriptRequest scriptReq, WebScriptResponse scriptRes, Authenticator auth) throws IOException Execute script given the specified context- Parameters:
scriptReq- WebScriptRequestscriptRes- WebScriptResponseauth- Authenticator- Throws:
IOException
-
getStatusCodeTemplate
Get code specific Status Template path- Parameters:
statusCode- int- Returns:
- path
-
getFormatStatusTemplate
Get format Status Template path- Parameters:
format- String- Returns:
- path
-
getStatusTemplate
Get Status Template path- Returns:
- path
-
getScriptParameters
Description copied from interface:RuntimeGets script parameters- Specified by:
getScriptParametersin interfaceRuntime- Returns:
- script parameters provided by the runtime
-
getTemplateParameters
Description copied from interface:RuntimeGets template parameters- Specified by:
getTemplateParametersin interfaceRuntime- Returns:
- template parameters provided by the runtime
-
getScriptMethod
Get the Web Script Method e.g. get, post- Returns:
- web script method
-
getScriptUrl
Get the Web Script Url- Returns:
- web script url
-
createRequest
Create a Web Script Request- Parameters:
match- web script matching the script method and url- Returns:
- web script request
-
createResponse
Create a Web Script Response- Returns:
- web script response
-
createAuthenticator
Create a Web Script Authenticator- Returns:
- web script authenticator
-
createSessionFactory
Create a Web Script Session -
getRealWebScriptRequest
Helper to retrieve real (last) Web Script Request in a stack of wrapped Web Script requests- Parameters:
request- WebScriptRequest- Returns:
- WebScriptRequest
-
getRealWebScriptResponse
Helper to retrieve real (last) Web Script Response in a stack of wrapped Web Script responses- Parameters:
response- WebScriptResponse- Returns:
- WebScriptResponse
-