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     }
44  	
45  	public WsdlTestStepFactory getFactory( String type )
46  	{
47  		for( WsdlTestStepFactory factory : factories )
48  			if( factory.getType().equals( type ))
49  				return factory;
50  		
51  		return null;
52  	}
53  
54  	public void addFactory( WsdlTestStepFactory factory )
55  	{
56  		factories.add( factory );
57  	}
58  
59  	public void removeFactory(String type)
60  	{
61  		for( WsdlTestStepFactory factory : factories )
62  		{
63  			if( factory.getType().equals( type ))
64  			{
65  				factories.remove(factory);
66  				break;
67  			}
68  		}
69  	}
70  
71  	public static synchronized WsdlTestStepRegistry getInstance()
72  	{
73  		if( instance == null )
74  			instance = new WsdlTestStepRegistry();
75  		
76  		return instance;
77  	}
78  
79  	public WsdlTestStepFactory [] getFactories()
80  	{
81  		return factories.toArray( new WsdlTestStepFactory[factories.size()] );
82  	}
83  
84  	public boolean hasFactory( TestStepConfig config )
85  	{
86  		return getFactory( config.getType() ) != null;
87  	}
88  }