Package org.apache.axis2.scripting
Class ScriptReceiver
java.lang.Object
org.apache.axis2.receivers.AbstractMessageReceiver
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
org.apache.axis2.scripting.ScriptReceiver
- All Implemented Interfaces:
MessageReceiver
An Axis2 MessageReceiver for invoking script language functions.
The scripting support uses the Apache Bean Scripting Framework (BSF)
so the script may be written in any language supported by BSF.
There are two ways of defining the script, either in a seperate file
or embedded in-line within the services.xml file.
This example shows a services.xml using a seperate script file:
invalid input: '<'service ...>
...
scripts/myScript.js
This example shows a JavaScript function embedded within a services.xml file:
invalid input: '<'service ...>
...
The script language is determined by the file name suffix when using scripts
in seperate files or the script parameter name suffix when using inline scripts.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
AbstractMessageReceiver.AsyncMessageReceiverWorker, AbstractMessageReceiver.ThreadContextDescriptor -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
DO_ASYNC, SAVED_MC, SAVED_TCCL, SCOPE, serviceTCCL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.bsf.BSFEngineGets the BSFEngine for the script service.protected org.apache.bsf.BSFEngineInitializes the script service by finding the script source code, compiling it in a BSFEngine, and creating an OMElementConvertor for the script.voidinvokeBusinessLogic(MessageContext inMC, MessageContext outMC) Invokes the service by calling the script functionprotected StringreadScript(ClassLoader cl, String scriptName) Reads the complete script source code into a StringMethods inherited from class org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
invokeBusinessLogicMethods inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
getSOAPFactory, getTheImplementationObject, makeNewServiceObject, receive, replicateState, restoreThreadContext, setThreadContext
-
Field Details
-
SCRIPT_ATTR
- See Also:
-
FUNCTION_ATTR
- See Also:
-
DEFAULT_FUNCTION
- See Also:
-
CONVERTOR_ATTR
- See Also:
-
BSFENGINE_PROP
-
CONVERTOR_PROP
-
SCRIPT_SRC_PROP
-
-
Constructor Details
-
ScriptReceiver
public ScriptReceiver()
-
-
Method Details
-
invokeBusinessLogic
Invokes the service by calling the script function- Specified by:
invokeBusinessLogicin classAbstractInOutSyncMessageReceiver- Throws:
AxisFault
-
getBSFEngine
Gets the BSFEngine for the script service. The first service invocation creates the BSFEngine and caches it in the Axis2 ServiceContext for reuse by subsequent requests.- Throws:
AxisFault
-
initScript
Initializes the script service by finding the script source code, compiling it in a BSFEngine, and creating an OMElementConvertor for the script.- Throws:
AxisFault
-
readScript
Reads the complete script source code into a String- Throws:
AxisFault
-