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.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 TransferValuesStepFactory() );
37  		addFactory( new GotoStepFactory() );
38  		addFactory( new DelayStepFactory() );
39  		addFactory( new RunTestCaseStepFactory() );
40  	}
41  	
42  	public WsdlTestStepFactory getFactory( String type )
43  	{
44  		for( WsdlTestStepFactory factory : factories )
45  			if( factory.getType().equals( type ))
46  				return factory;
47  		
48  		return null;
49  	}
50  
51  	public void addFactory( WsdlTestStepFactory factory )
52  	{
53  		factories.add( factory );
54  	}
55  
56  	public static synchronized WsdlTestStepRegistry getInstance()
57  	{
58  		if( instance == null )
59  			instance = new WsdlTestStepRegistry();
60  		
61  		return instance;
62  	}
63  
64  	public WsdlTestStepFactory [] getFactories()
65  	{
66  		return factories.toArray( new WsdlTestStepFactory[factories.size()] );
67  	}
68  
69  	public boolean hasFactory( TestStepConfig config )
70  	{
71  		return getFactory( config.getType() ) != null;
72  	}
73  }