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  		addFactory( new ManualTestStepFactory() );
46  
47  		// soapUI Pro TestStep placeholders
48  		addFactory( new ProPlaceholderStepFactory( "datasource", "soapUI Pro DataSource", "/datasource.gif" ) );
49  		addFactory( new ProPlaceholderStepFactory( "datasourceloop", "soapUI Pro DataSourceLoop", "/datasource_loop.gif" ) );
50  		addFactory( new ProPlaceholderStepFactory( "datasink", "soapUI Pro DataSink", "/datasink.gif" ) );
51  		addFactory( new ProPlaceholderStepFactory( "datagen", "soapUI Pro DataGen", "/datagen.gif" ) );
52  	}
53  
54  	public WsdlTestStepFactory getFactory( String type )
55  	{
56  		for( WsdlTestStepFactory factory : factories )
57  			if( factory.getType().equals( type ) )
58  				return factory;
59  
60  		return null;
61  	}
62  
63  	public void addFactory( WsdlTestStepFactory factory )
64  	{
65  		removeFactory( factory.getType() );
66  		factories.add( factory );
67  	}
68  
69  	public void removeFactory( String type )
70  	{
71  		for( WsdlTestStepFactory factory : factories )
72  		{
73  			if( factory.getType().equals( type ) )
74  			{
75  				factories.remove( factory );
76  				break;
77  			}
78  		}
79  	}
80  
81  	public static synchronized WsdlTestStepRegistry getInstance()
82  	{
83  		if( instance == null )
84  			instance = new WsdlTestStepRegistry();
85  
86  		return instance;
87  	}
88  
89  	public WsdlTestStepFactory[] getFactories()
90  	{
91  		return factories.toArray( new WsdlTestStepFactory[factories.size()] );
92  	}
93  
94  	public boolean hasFactory( TestStepConfig config )
95  	{
96  		return getFactory( config.getType() ) != null;
97  	}
98  }