View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.support.scripting;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  import com.eviware.soapui.model.ModelItem;
19  import com.eviware.soapui.support.scripting.groovy.GroovyScriptEngineFactory;
20  
21  /***
22   * Registry of available script engines
23   * 
24   * @author ole.matzura
25   */
26  
27  public class SoapUIScriptEngineRegistry
28  {
29  	public static final String GROOVY_ID = GroovyScriptEngineFactory.ID;
30  	
31  	private static Map<String,SoapUIScriptEngineFactory> factories = new HashMap<String, SoapUIScriptEngineFactory>();
32  	
33  	public static void registerScriptEngine( String id, SoapUIScriptEngineFactory factory )
34  	{
35  		factories.put( id, factory );
36  	}
37  	
38  	public static SoapUIScriptEngineFactory getFactory( String id )
39  	{
40  		return factories.get( id );
41  	}
42  	
43  	public static SoapUIScriptEngine create( String id, ModelItem modelItem )
44  	{
45  		return factories.get( id ).createScriptEngine( modelItem );
46  	}
47  	
48  	static
49  	{
50  		registerScriptEngine( GroovyScriptEngineFactory.ID, new GroovyScriptEngineFactory() );
51  	}
52  }