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
public class ScriptReceiver
- extends AbstractInOutSyncMessageReceiver
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:
...
scripts/myScript.js
This example shows a JavaScript function embedded within a services.xml file:
...
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.
Method Summary |
protected org.apache.bsf.BSFEngine |
getBSFEngine(MessageContext mc)
Gets the BSFEngine for the script service. |
protected org.apache.bsf.BSFEngine |
initScript(MessageContext mc)
Initializes the script service by finding the script source code,
compiling it in a BSFEngine, and creating an OMElementConvertor
for the script. |
void |
invokeBusinessLogic(MessageContext inMC,
MessageContext outMC)
Invokes the service by calling the script function |
protected java.lang.String |
readScript(java.lang.ClassLoader cl,
java.lang.String scriptName)
Reads the complete script source code into a String |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SCRIPT_ATTR
public static final java.lang.String SCRIPT_ATTR
- See Also:
- Constant Field Values
FUNCTION_ATTR
public static final java.lang.String FUNCTION_ATTR
- See Also:
- Constant Field Values
DEFAULT_FUNCTION
public static final java.lang.String DEFAULT_FUNCTION
- See Also:
- Constant Field Values
CONVERTOR_ATTR
public static final java.lang.String CONVERTOR_ATTR
- See Also:
- Constant Field Values
BSFENGINE_PROP
protected static final java.lang.String BSFENGINE_PROP
CONVERTOR_PROP
protected static final java.lang.String CONVERTOR_PROP
SCRIPT_SRC_PROP
public static final java.lang.String SCRIPT_SRC_PROP
ScriptReceiver
public ScriptReceiver()
invokeBusinessLogic
public void invokeBusinessLogic(MessageContext inMC,
MessageContext outMC)
throws AxisFault
- Invokes the service by calling the script function
- Specified by:
invokeBusinessLogic
in class AbstractInOutSyncMessageReceiver
- Throws:
AxisFault
getBSFEngine
protected org.apache.bsf.BSFEngine getBSFEngine(MessageContext mc)
throws AxisFault
- 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
protected org.apache.bsf.BSFEngine initScript(MessageContext mc)
throws AxisFault
- 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
protected java.lang.String readScript(java.lang.ClassLoader cl,
java.lang.String scriptName)
throws AxisFault
- Reads the complete script source code into a String
- Throws:
AxisFault
Copyright © 2007 Apache Web Services Project. All Rights Reserved.