Coverage Report - org.mule.components.script.jsr223.ScriptComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
ScriptComponent
90%
9/10
50%
1/2
1.5
 
 1  
 /*
 2  
  * $Id: ScriptComponent.java 10430 2008-01-21 16:28:22Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.components.script.jsr223;
 12  
 
 13  
 import org.mule.umo.UMOEventContext;
 14  
 import org.mule.umo.lifecycle.Callable;
 15  
 
 16  
 import javax.script.Bindings;
 17  
 
 18  
 
 19  
 /**
 20  
  * A JSR 223 Script component. Allows any JSR 223 compliant script engines such as
 21  
  * JavaScript, Groovy or Rhino to be embedded as Mule components.
 22  
  */
 23  4
 public class ScriptComponent extends AbstractScriptComponent implements Callable
 24  
 {
 25  
     
 26  
     protected void populateBindings(Bindings namespace, UMOEventContext context)
 27  
     {
 28  4
         super.populateBindings(namespace, context);
 29  4
         namespace.put("result", new Object());
 30  4
     }
 31  
 
 32  
     public Object onCall(UMOEventContext eventContext) throws Exception
 33  
     {
 34  4
         Bindings bindings = this.getBindings();
 35  4
         populateBindings(bindings, eventContext);
 36  4
         Object result = runScript(bindings);
 37  4
         if (result == null)
 38  
         {
 39  0
             result = bindings.get("result");
 40  
         }
 41  4
         return result;
 42  
     }
 43  
 
 44  
 }