Package helma.framework.core
Class RequestEvaluator
java.lang.Object
helma.framework.core.RequestEvaluator
- All Implemented Interfaces:
Runnable
This class does the work for incoming requests. It holds a transactor thread
and an EcmaScript evaluator to get the work done. Incoming threads are
blocked until the request has been serviced by the evaluator, or the timeout
specified by the application has passed. In the latter case, the evaluator thread
is killed and an error message is returned.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Application
static final Object[]
protected ScriptingEngine
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new RequestEvaluator for this application. -
Method Summary
Modifier and TypeMethodDescriptionThis checks if the Evaluator is already executing an equal request.getAction
(Object obj, String action, RequestTrans req) Check if an action with a given name is defined for a scripted object.Get the request object for the current request.Get the response object for the current request.Returns this evaluator's scripting engineReturn the current sessionGet the current transactor threadprotected void
invokeDirectFunction
(Object obj, Object function, Object[] args) Invoke a function internally and directly, using the thread we're running on.invokeExternal
(String functionName, Object[] args) Invoke a function for an external request.invokeHttp
(RequestTrans req, Session session) Invoke an action function for a HTTP request.invokeInternal
(Object object, Object function, Object[] args) Invoke a function internally.invokeInternal
(Object object, Object function, Object[] args, long timeout) Invoke a function internally.invokeXmlRpc
(String functionName, Object[] args) Invoke a function for an XML-RPC request.void
run()
protected void
shutdown()
-
Field Details
-
EMPTY_ARGS
-
app
-
scriptingEngine
-
skinDepth
protected int skinDepth
-
-
Constructor Details
-
RequestEvaluator
Create a new RequestEvaluator for this application.- Parameters:
app
- the application
-
-
Method Details
-
initScriptingEngine
protected void initScriptingEngine() -
shutdown
protected void shutdown() -
run
public void run() -
invokeHttp
Invoke an action function for a HTTP request. The function is dispatched in a new thread and waits for it to finish.- Parameters:
req
- the incoming HTTP requestsession
- the client's session- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
attachHttpRequest
This checks if the Evaluator is already executing an equal request. If so, attach to it and wait for it to complete. Otherwise return null, so the application knows it has to run the request.- Throws:
Exception
-
invokeXmlRpc
Invoke a function for an XML-RPC request. The function is dispatched in a new thread and waits for it to finish.- Parameters:
functionName
- the name of the function to invokeargs
- the arguments- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
invokeExternal
Invoke a function for an external request. The function is dispatched in a new thread and waits for it to finish.- Parameters:
functionName
- the name of the function to invokeargs
- the arguments- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
invokeDirectFunction
Invoke a function internally and directly, using the thread we're running on.- Parameters:
obj
- the object to invoke the function onfunction
- the function or name of the function to invokeargs
- the arguments- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
invokeInternal
Invoke a function internally. The function is dispatched in a new thread and waits for it to finish.- Parameters:
object
- the object to invoke the function onfunction
- the function or name of the function to invokeargs
- the arguments- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
invokeInternal
public Object invokeInternal(Object object, Object function, Object[] args, long timeout) throws Exception Invoke a function internally. The function is dispatched in a new thread and waits for it to finish.- Parameters:
object
- the object to invoke the function onfunction
- the function or name of the function to invokeargs
- the argumentstimeout
- the time in milliseconds to wait for the function to return, or -1 to wait indefinitely- Returns:
- the result returned by the invocation
- Throws:
Exception
- any exception thrown by the invocation
-
getAction
Check if an action with a given name is defined for a scripted object. If it is, return the action's function name. Otherwise, return null. -
getScriptingEngine
Returns this evaluator's scripting engine -
getRequest
Get the request object for the current request.- Returns:
- the request object
-
getResponse
Get the response object for the current request.- Returns:
- the response object
-
getThread
Get the current transactor thread- Returns:
- the current transactor thread
-
getSession
Return the current session- Returns:
- the session for the current request
-