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.loadtest.strategy;
    14
    15  import java.util.HashMap;
    16  import java.util.Map;
    17
    18  /***
    19   * Registry of LoadFactorys
    20   *
    21   * @author Ole.Matzura
    22   */
    23
    24  public class LoadStrategyRegistry
    25  {
    26  	private static LoadStrategyRegistry instance;
    27  	private Map<String,LoadStrategyFactory> factories = new HashMap<String,LoadStrategyFactory>();
    28
    29  	public LoadStrategyRegistry()
    30  	{
    31  		addFactory( new SimpleLoadStrategy.Factory() );
    32  		addFactory( new BurstLoadStrategy.Factory() );
    33  		addFactory( new VarianceLoadStrategy.Factory() );
    34  		addFactory( new ThreadCountChangeLoadStrategy.Factory() );
    35  	}
    36
    37  	private void addFactory(LoadStrategyFactory factory)
    38  	{
    39  		factories.put( factory.getType(), factory );
    40  	}
    41
    42  	public Object [] getStrategies()
    43  	{
    44  		return factories.keySet().toArray();
    45  	}
    46
    47  	public static LoadStrategyRegistry getInstance()
    48  	{
    49  		if( instance == null )
    50  			instance = new LoadStrategyRegistry();
    51
    52  		return instance;
    53  	}
    54
    55  	public LoadStrategyFactory getFactory(String type )
    56  	{
    57  		return factories.get( type );
    58  	}
    59  }