View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.impl.wsdl.teststeps.registry;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  import com.eviware.soapui.config.TestStepConfig;
19  
20  /***
21   * Registry of WsdlTestStep factories
22   * 
23   * @author Ole.Matzura
24   */
25  
26  public class WsdlTestStepRegistry
27  {
28  	private static WsdlTestStepRegistry instance;
29  	private List<WsdlTestStepFactory> factories = new ArrayList<WsdlTestStepFactory>();
30  
31  	public WsdlTestStepRegistry()
32  	{
33  		addFactory( new WsdlTestRequestStepFactory() );
34  		addFactory( new GroovyScriptStepFactory() );
35  		addFactory( new PropertiesStepFactory() );
36  		addFactory( new PropertyTransfersStepFactory() );
37  		addFactory( new GotoStepFactory() );
38  		addFactory( new DelayStepFactory() );
39  		addFactory( new RunTestCaseStepFactory() );
40  		addFactory( new RestRequestStepFactory() );
41  		addFactory( new HttpRequestStepFactory() );
42  		addFactory( new WsdlMockResponseStepFactory() );
43  		addFactory( new JdbcRequestTestStepFactory() );
44  		addFactory( new AMFRequestStepFactory() );
45  
46  		// soapUI Pro TestStep placeholders
47  		addFactory( new ProPlaceholderStepFactory( "datasource", "soapUI Pro DataSource", "/datasource.gif" ) );
48  		addFactory( new ProPlaceholderStepFactory( "datasourceloop", "soapUI Pro DataSourceLoop", "/datasource_loop.gif" ) );
49  		addFactory( new ProPlaceholderStepFactory( "datasink", "soapUI Pro DataSink", "/datasink.gif" ) );
50  		addFactory( new ProPlaceholderStepFactory( "datagen", "soapUI Pro DataGen", "/datagen.gif" ) );
51  	}
52  
53  	public WsdlTestStepFactory getFactory( String type )
54  	{
55  		for( WsdlTestStepFactory factory : factories )
56  			if( factory.getType().equals( type ) )
57  				return factory;
58  
59  		return null;
60  	}
61  
62  	public void addFactory( WsdlTestStepFactory factory )
63  	{
64  		removeFactory( factory.getType() );
65  		factories.add( factory );
66  	}
67  
68  	public void removeFactory( String type )
69  	{
70  		for( WsdlTestStepFactory factory : factories )
71  		{
72  			if( factory.getType().equals( type ) )
73  			{
74  				factories.remove( factory );
75  				break;
76  			}
77  		}
78  	}
79  
80  	public static synchronized WsdlTestStepRegistry getInstance()
81  	{
82  		if( instance == null )
83  			instance = new WsdlTestStepRegistry();
84  
85  		return instance;
86  	}
87  
88  	public WsdlTestStepFactory[] getFactories()
89  	{
90  		return factories.toArray( new WsdlTestStepFactory[factories.size()] );
91  	}
92  
93  	public boolean hasFactory( TestStepConfig config )
94  	{
95  		return getFactory( config.getType() ) != null;
96  	}
97  }