org.apache.servicemix.scripting
Class ScriptingEndpoint

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ProviderEndpoint
              extended by org.apache.servicemix.scripting.ScriptingEndpoint
All Implemented Interfaces:
Endpoint, ScriptingEndpointType

public class ScriptingEndpoint
extends ProviderEndpoint
implements ScriptingEndpointType

Author:
lhein

Field Summary
static char EXTENSION_SEPARATOR
           
static java.lang.String KEY_CHANNEL
           
static java.lang.String KEY_COMPONENT_NAMESPACE
           
static java.lang.String KEY_CONTEXT
           
static java.lang.String KEY_ENDPOINT
           
static java.lang.String KEY_ENDPOINTNAME
           
static java.lang.String KEY_IN_EXCHANGE
           
static java.lang.String KEY_IN_MSG
           
static java.lang.String KEY_INTERFACENAME
           
static java.lang.String KEY_LOGGER
           
static java.lang.String KEY_OUT_EXCHANGE
           
static java.lang.String KEY_OUT_MSG
           
static java.lang.String KEY_SCRIPT
           
static java.lang.String KEY_SERVICENAME
           
static java.lang.String KEY_USER_BINDINGS
           
static java.lang.String LANGUAGE_AUTODETECT
           
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
ScriptingEndpoint()
           
 
Method Summary
 void configureTarget(javax.jbi.messaging.MessageExchange exchange)
          Configures the target on the newly created exchange
protected  void copyAttachments(javax.jbi.messaging.NormalizedMessage from, javax.jbi.messaging.NormalizedMessage to)
          Copies attachments from one message to another that do not already exist
protected  void copyProperties(javax.jbi.messaging.NormalizedMessage from, javax.jbi.messaging.NormalizedMessage to)
          Copies properties from one message to another that do not already exist
protected  java.util.logging.Logger createScriptLogger()
           
protected  void done(javax.jbi.messaging.MessageExchange messageExchange)
           
protected  void fail(javax.jbi.messaging.MessageExchange messageExchange, java.lang.Exception e)
           
 java.util.Map<java.lang.String,java.lang.Object> getBindings()
           
static java.lang.String getExtension(java.lang.String filename)
           
 java.lang.String getLanguage()
           
 java.lang.String getLogResourceBundle()
           
 ScriptingMarshalerSupport getMarshaler()
           
 org.springframework.core.io.Resource getScript()
           
 java.util.logging.Logger getScriptLogger()
          returns the script logger
 java.lang.String getTargetEndpoint()
           
 javax.xml.namespace.QName getTargetInterface()
           
 javax.xml.namespace.QName getTargetOperation()
           
 javax.xml.namespace.QName getTargetService()
           
 java.lang.String getTargetUri()
           
static int indexOfExtension(java.lang.String filename)
           
static int indexOfLastSeparator(java.lang.String filename)
           
 boolean isCopyAttachments()
           
 boolean isCopyProperties()
           
 boolean isDisableOutput()
           
 void process(javax.jbi.messaging.MessageExchange exchange)
           
protected  void send(javax.jbi.messaging.MessageExchange messageExchange)
           
protected  void sendSync(javax.jbi.messaging.MessageExchange messageExchange)
           
 void setBindings(java.util.Map<java.lang.String,java.lang.Object> bindings)
          A Map with additional variables that are made available during script execution.
 void setCopyAttachments(boolean copyAttachments)
          Copy the attachments into the 'out' message.
 void setCopyProperties(boolean copyProperties)
          Copy the properties into the 'out' message.
 void setDisableOutput(boolean disableOutput)
          Set this flag to true to true to avoid sending back a response message.
 void setLanguage(java.lang.String language)
          The scripting language to be used.
 void setLogResourceBundle(java.lang.String logResourceBundle)
          The resource bundle to use when logging internationalized messages.
 void setMarshaler(ScriptingMarshalerSupport marshaler)
          Custom marshaler implementation to handle startup/shutdown, loading the script code and registering additional user beans.
 void setScript(org.springframework.core.io.Resource script)
          Spring Resource referring to the script location.
 void setScriptLogger(java.util.logging.Logger scriptLogger)
          Sets the logger to use if the script decides to log.
 void setTargetEndpoint(java.lang.String targetEndpoint)
          Target endpoint for the output exchange that is created by the script.
 void setTargetInterface(javax.xml.namespace.QName targetInterface)
          Target interface for the output exchange that is created by the script.
 void setTargetOperation(javax.xml.namespace.QName targetOperation)
          Target operation for the output exchange that is created by the script.
 void setTargetService(javax.xml.namespace.QName targetService)
          Target service for the output exchange that is created by the script.
 void setTargetUri(java.lang.String targetUri)
          URI for configuring target service/endpoint/interface for the exchange that is created by the script.
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.servicemix.common.endpoints.ProviderEndpoint
activate, deactivate, getRole, processInOnly, processInOut
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
getChannel, getContext, getExchangeFactory
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getDefinition, getDescription, getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_CHANNEL

public static final java.lang.String KEY_CHANNEL
See Also:
Constant Field Values

KEY_COMPONENT_NAMESPACE

public static final java.lang.String KEY_COMPONENT_NAMESPACE
See Also:
Constant Field Values

KEY_CONTEXT

public static final java.lang.String KEY_CONTEXT
See Also:
Constant Field Values

KEY_ENDPOINT

public static final java.lang.String KEY_ENDPOINT
See Also:
Constant Field Values

KEY_ENDPOINTNAME

public static final java.lang.String KEY_ENDPOINTNAME
See Also:
Constant Field Values

KEY_IN_EXCHANGE

public static final java.lang.String KEY_IN_EXCHANGE
See Also:
Constant Field Values

KEY_IN_MSG

public static final java.lang.String KEY_IN_MSG
See Also:
Constant Field Values

KEY_OUT_EXCHANGE

public static final java.lang.String KEY_OUT_EXCHANGE
See Also:
Constant Field Values

KEY_OUT_MSG

public static final java.lang.String KEY_OUT_MSG
See Also:
Constant Field Values

KEY_INTERFACENAME

public static final java.lang.String KEY_INTERFACENAME
See Also:
Constant Field Values

KEY_LOGGER

public static final java.lang.String KEY_LOGGER
See Also:
Constant Field Values

KEY_SCRIPT

public static final java.lang.String KEY_SCRIPT
See Also:
Constant Field Values

KEY_SERVICENAME

public static final java.lang.String KEY_SERVICENAME
See Also:
Constant Field Values

KEY_USER_BINDINGS

public static final java.lang.String KEY_USER_BINDINGS
See Also:
Constant Field Values

LANGUAGE_AUTODETECT

public static final java.lang.String LANGUAGE_AUTODETECT
See Also:
Constant Field Values

EXTENSION_SEPARATOR

public static final char EXTENSION_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

ScriptingEndpoint

public ScriptingEndpoint()
Method Detail

createScriptLogger

protected java.util.logging.Logger createScriptLogger()
                                               throws javax.jbi.messaging.MessagingException
Returns:
Throws:
javax.jbi.messaging.MessagingException

done

protected void done(javax.jbi.messaging.MessageExchange messageExchange)
             throws javax.jbi.messaging.MessagingException
Overrides:
done in class SimpleEndpoint
Throws:
javax.jbi.messaging.MessagingException

fail

protected void fail(javax.jbi.messaging.MessageExchange messageExchange,
                    java.lang.Exception e)
             throws javax.jbi.messaging.MessagingException
Overrides:
fail in class SimpleEndpoint
Throws:
javax.jbi.messaging.MessagingException

getBindings

public java.util.Map<java.lang.String,java.lang.Object> getBindings()
Returns:
the bindings

getLanguage

public java.lang.String getLanguage()
Returns:
Returns the language.

getLogResourceBundle

public java.lang.String getLogResourceBundle()
Returns:
Returns the logResourceBundle.

getMarshaler

public ScriptingMarshalerSupport getMarshaler()
Returns:
the marshaler

getScript

public org.springframework.core.io.Resource getScript()
Returns:
the script

getScriptLogger

public java.util.logging.Logger getScriptLogger()
                                         throws javax.jbi.messaging.MessagingException
returns the script logger

Returns:
the script logger
Throws:
javax.jbi.messaging.MessagingException

isDisableOutput

public boolean isDisableOutput()
Returns:
the disableOutput

process

public void process(javax.jbi.messaging.MessageExchange exchange)
             throws java.lang.Exception
Specified by:
process in interface Endpoint
Overrides:
process in class ProviderEndpoint
Throws:
java.lang.Exception

send

protected void send(javax.jbi.messaging.MessageExchange messageExchange)
             throws javax.jbi.messaging.MessagingException
Overrides:
send in class SimpleEndpoint
Throws:
javax.jbi.messaging.MessagingException

sendSync

protected void sendSync(javax.jbi.messaging.MessageExchange messageExchange)
                 throws javax.jbi.messaging.MessagingException
Overrides:
sendSync in class SimpleEndpoint
Throws:
javax.jbi.messaging.MessagingException

setBindings

public void setBindings(java.util.Map<java.lang.String,java.lang.Object> bindings)
A Map with additional variables that are made available during script execution.

Parameters:
bindings - the bindings to set

setDisableOutput

public void setDisableOutput(boolean disableOutput)
Set this flag to true to true to avoid sending back a response message. Defaults to false

Parameters:
disableOutput - the disableOutput to set

setLanguage

public void setLanguage(java.lang.String language)
The scripting language to be used. Defaults to autodetect to determine the language by the script file extension.

Parameters:
language - The language to set.

setLogResourceBundle

public void setLogResourceBundle(java.lang.String logResourceBundle)
The resource bundle to use when logging internationalized messages.

Parameters:
logResourceBundle - The logResourceBundle to set.

setMarshaler

public void setMarshaler(ScriptingMarshalerSupport marshaler)
Custom marshaler implementation to handle startup/shutdown, loading the script code and registering additional user beans.

Parameters:
marshaler - the marshaler to set

setScript

public void setScript(org.springframework.core.io.Resource script)
Spring Resource referring to the script location.

Parameters:
script - the script to set

setScriptLogger

public void setScriptLogger(java.util.logging.Logger scriptLogger)
Sets the logger to use if the script decides to log.

Parameters:
scriptLogger -

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Endpoint
Overrides:
start in class SimpleEndpoint
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Endpoint
Overrides:
stop in class SimpleEndpoint
Throws:
java.lang.Exception

copyProperties

protected void copyProperties(javax.jbi.messaging.NormalizedMessage from,
                              javax.jbi.messaging.NormalizedMessage to)
Copies properties from one message to another that do not already exist

Parameters:
from - the message containing the properties
to - the destination message where the properties are set

copyAttachments

protected void copyAttachments(javax.jbi.messaging.NormalizedMessage from,
                               javax.jbi.messaging.NormalizedMessage to)
                        throws javax.jbi.messaging.MessagingException
Copies attachments from one message to another that do not already exist

Parameters:
from - the message with the attachments
to - the destination message where the attachments are to be added
Throws:
javax.jbi.messaging.MessagingException - if an attachment could not be added

getExtension

public static java.lang.String getExtension(java.lang.String filename)

indexOfExtension

public static int indexOfExtension(java.lang.String filename)

indexOfLastSeparator

public static int indexOfLastSeparator(java.lang.String filename)

configureTarget

public void configureTarget(javax.jbi.messaging.MessageExchange exchange)
                     throws javax.jbi.messaging.MessagingException
Configures the target on the newly created exchange

Parameters:
exchange - the exchange to configure
Throws:
javax.jbi.messaging.MessagingException - if the target could not be configured

isCopyProperties

public boolean isCopyProperties()
Returns:
Returns the copyProperties.

setCopyProperties

public void setCopyProperties(boolean copyProperties)
Copy the properties into the 'out' message. Defaults to true.

Parameters:
copyProperties - The copyProperties to set.

isCopyAttachments

public boolean isCopyAttachments()
Returns:
Returns the copyAttachments.

setCopyAttachments

public void setCopyAttachments(boolean copyAttachments)
Copy the attachments into the 'out' message. Defaults to true.

Parameters:
copyAttachments - The copyAttachments to set.

getTargetInterface

public javax.xml.namespace.QName getTargetInterface()
Returns:
Returns the targetInterface.

setTargetInterface

public void setTargetInterface(javax.xml.namespace.QName targetInterface)
Target interface for the output exchange that is created by the script.

Parameters:
targetInterface - The targetInterface to set.

getTargetOperation

public javax.xml.namespace.QName getTargetOperation()
Returns:
Returns the targetOperation.

setTargetOperation

public void setTargetOperation(javax.xml.namespace.QName targetOperation)
Target operation for the output exchange that is created by the script.

Parameters:
targetOperation - The targetOperation to set.

getTargetService

public javax.xml.namespace.QName getTargetService()
Returns:
Returns the targetService.

setTargetService

public void setTargetService(javax.xml.namespace.QName targetService)
Target service for the output exchange that is created by the script.

Parameters:
targetService - The targetService to set.

getTargetEndpoint

public java.lang.String getTargetEndpoint()
Returns:
Returns the targetEndpoint.

setTargetEndpoint

public void setTargetEndpoint(java.lang.String targetEndpoint)
Target endpoint for the output exchange that is created by the script.

Parameters:
targetEndpoint - The targetEndpoint to set.

getTargetUri

public java.lang.String getTargetUri()
Returns:
Returns the targetUri.

setTargetUri

public void setTargetUri(java.lang.String targetUri)
URI for configuring target service/endpoint/interface for the exchange that is created by the script.

Parameters:
targetUri - The targetUri to set.


Copyright © 2005-2013 FuseSource. All Rights Reserved.