org.apache.axis2.scripting
Class ScriptReceiver

java.lang.Object
  extended by org.apache.axis2.receivers.AbstractMessageReceiver
      extended by org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
          extended by 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
AbstractMessageReceiver.AsyncMessageReceiverWorker, AbstractMessageReceiver.ThreadContextDescriptor
 
Field Summary
protected static java.lang.String BSFENGINE_PROP
           
static java.lang.String CONVERTOR_ATTR
           
protected static java.lang.String CONVERTOR_PROP
           
static java.lang.String DEFAULT_FUNCTION
           
static java.lang.String FUNCTION_ATTR
           
static java.lang.String SCRIPT_ATTR
           
static java.lang.String SCRIPT_SRC_PROP
           
 
Fields inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
DO_ASYNC, SAVED_MC, SAVED_TCCL, SCOPE, serviceTCCL
 
Constructor Summary
ScriptReceiver()
           
 
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 org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
invokeBusinessLogic
 
Methods inherited from class org.apache.axis2.receivers.AbstractMessageReceiver
getSOAPFactory, getTheImplementationObject, makeNewServiceObject, receive, replicateState, restoreThreadContext, setThreadContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

ScriptReceiver

public ScriptReceiver()
Method Detail

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.