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.HashMap;
    16  import java.util.Map;
    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 Map<String,WsdlTestStepFactory> factoryMap = new HashMap<String,WsdlTestStepFactory>();
    30
    31  	public WsdlTestStepRegistry()
    32  	{
    33  		addFactory( new WsdlTestRequestStepFactory() );
    34  		addFactory( new TransferValuesStepFactory() );
    35  		addFactory( new GotoStepFactory() );
    36  		addFactory( new DelayStepFactory() );
    37  		addFactory( new PropertiesStepFactory() );
    38  		addFactory( new GroovyScriptStepFactory() );
    39  	}
    40
    41  	public WsdlTestStepFactory getFactory( String type )
    42  	{
    43  		return factoryMap.get( type );
    44  	}
    45
    46  	public void addFactory( WsdlTestStepFactory factory )
    47  	{
    48  		factoryMap.put( factory.getType(), factory );
    49  	}
    50
    51  	public static synchronized WsdlTestStepRegistry getInstance()
    52  	{
    53  		if( instance == null )
    54  			instance = new WsdlTestStepRegistry();
    55
    56  		return instance;
    57  	}
    58
    59  	public WsdlTestStepFactory [] getFactories()
    60  	{
    61  		return factoryMap.values().toArray( new WsdlTestStepFactory[factoryMap.size()] );
    62  	}
    63
    64  	public boolean hasFactory( TestStepConfig config )
    65  	{
    66  		return getFactory( config.getType() ) != null;
    67  	}
    68
    69  }