View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 com.eviware.soapui.config.TestStepConfig;
16  
17  import java.util.ArrayList;
18  import java.util.List;
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 AsyncResponseStepFactory() );
41  		addFactory( new RestRequestStepFactory() );
42        addFactory( new HttpRequestStepFactory() );
43        addFactory( new WsdlMockResponseStepFactory() );
44     }
45  	
46  	public WsdlTestStepFactory getFactory( String type )
47  	{
48  		for( WsdlTestStepFactory factory : factories )
49  			if( factory.getType().equals( type ))
50  				return factory;
51  		
52  		return null;
53  	}
54  
55  	public void addFactory( WsdlTestStepFactory factory )
56  	{
57  		factories.add( factory );
58  	}
59  
60  	public void removeFactory(String type)
61  	{
62  		for( WsdlTestStepFactory factory : factories )
63  		{
64  			if( factory.getType().equals( type ))
65  			{
66  				factories.remove(factory);
67  				break;
68  			}
69  		}
70  	}
71  
72  	public static synchronized WsdlTestStepRegistry getInstance()
73  	{
74  		if( instance == null )
75  			instance = new WsdlTestStepRegistry();
76  		
77  		return instance;
78  	}
79  
80  	public WsdlTestStepFactory [] getFactories()
81  	{
82  		return factories.toArray( new WsdlTestStepFactory[factories.size()] );
83  	}
84  
85  	public boolean hasFactory( TestStepConfig config )
86  	{
87  		return getFactory( config.getType() ) != null;
88  	}
89  }