Package org.mule.module.scripting.component

Examples of org.mule.module.scripting.component.Scriptable


            Object registeredScript = message.getMuleContext().getRegistry().lookupObject(flowName);

            Preconditions.checkNotNull(registeredScript, "The script called " + flowName + " could not be found");
            if (registeredScript instanceof Scriptable)
            {
                Scriptable script = (Scriptable) registeredScript;
                Bindings bindings = script.getScriptEngine().createBindings();
                script.populateDefaultBindings(bindings);
                try
                {
                    return script.runScript(bindings);
                }
                catch (ScriptException e)
                {
                    throw new RuntimeException("Your script has an execution error ", e);
                }
View Full Code Here


     * @param message    the message to extract from
     * @return the result of the extraction or null if the property was not found
     */
    public Object evaluate(String expression, MuleMessage message)
    {
        Scriptable script = getScript(expression);
        script.setMuleContext(muleContext);
        Bindings bindings = script.getScriptEngine().createBindings();
        script.populateBindings(bindings, message);

        try
        {
            return script.runScript(bindings);
        }
        catch (ScriptException e)
        {
            return null;
        }
View Full Code Here

        throw new UnsupportedOperationException("setName");
    }

    protected Scriptable getScript(String expression)
    {
        Scriptable script = (Scriptable)cache.get(expression);
        if (script==null)
        {
            script = new Scriptable(muleContext);
            script.setScriptEngineName(getName());
            script.setScriptText(expression);
            try
            {
                script.initialise();
            }
            catch (InitialisationException e)
            {
                throw new MuleRuntimeException(
                    CoreMessages.initialisationFailure("An error occurred initialising script."), e);
View Full Code Here

public class GroovyScriptTransformerTestCase extends AbstractTransformerTestCase
{
    public Transformer getTransformer() throws Exception
    {
        Scriptable script = new Scriptable(muleContext);
        script.setScriptEngineName("groovy");
        script.setScriptFile("StringToList.groovy");
        script.initialise();
       
        ScriptTransformer transformer = new ScriptTransformer();
        transformer.setName("StringToList");
        transformer.setMuleContext(muleContext);
        transformer.setScript(script);
View Full Code Here

        return transformer;
    }

    public Transformer getRoundTripTransformer() throws Exception
    {
        Scriptable script = new Scriptable(muleContext);
        script.setScriptFile("ListToString.groovy");
        script.initialise();
       
        ScriptTransformer transformer = new ScriptTransformer();
        transformer.setName("ListToString");
        transformer.setMuleContext(muleContext);
        transformer.setScript(script);
View Full Code Here

    protected void doConfigure(MuleContext muleContext) throws Exception
    {
        this.muleContext = muleContext;

        scriptComponent = new Scriptable(muleContext);
        scriptComponent.setScriptEngineName(scriptEngineName);
           
        for (int i = 0; i < configResources.length; i++)
        {
            ConfigResource configResource = configResources[i];
View Full Code Here

    protected void doConfigure(MuleContext muleContext) throws Exception
    {
        this.muleContext = muleContext;

        scriptComponent = new Scriptable(muleContext);
        scriptComponent.setScriptEngineName(scriptEngineName);
           
        for (int i = 0; i < configResources.length; i++)
        {
            ConfigResource configResource = configResources[i];
View Full Code Here

public class GroovyScriptTransformerTestCase extends AbstractTransformerTestCase
{
    public Transformer getTransformer() throws Exception
    {
        Scriptable script = new Scriptable(muleContext);
        script.setScriptEngineName("groovy");
        script.setScriptFile("StringToList.groovy");
        script.initialise();
       
        ScriptTransformer transformer = new ScriptTransformer();
        transformer.setName("StringToList");
        transformer.setMuleContext(muleContext);
        transformer.setScript(script);
View Full Code Here

        return transformer;
    }

    public Transformer getRoundTripTransformer() throws Exception
    {
        Scriptable script = new Scriptable(muleContext);
        script.setScriptFile("ListToString.groovy");
        script.initialise();
       
        ScriptTransformer transformer = new ScriptTransformer();
        transformer.setName("ListToString");
        transformer.setMuleContext(muleContext);
        transformer.setScript(script);
View Full Code Here

     * @return the result of the extraction or null if the property was not found
     */
    @Override
    public Object evaluate(String expression, MuleMessage message)
    {
        Scriptable script = getScript(expression);
        script.setMuleContext(muleContext);
        Bindings bindings = script.getScriptEngine().createBindings();
        script.populateBindings(bindings, message);

        try
        {
            return script.runScript(bindings);
        }
        catch (ScriptException e)
        {
            throw new MuleRuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of org.mule.module.scripting.component.Scriptable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.