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.panels.request.components.editor.inspectors.registry;
    14
    15  import java.util.ArrayList;
    16  import java.util.Arrays;
    17  import java.util.List;
    18
    19  /***
    20   * Registry of registered XmlInspectorFactories
    21   *
    22   * @author ole.matzura
    23   */
    24
    25  public class XmlInspectorRegistry
    26  {
    27  	private static XmlInspectorRegistry instance;
    28  	private List<XmlInspectorFactory> factories = new ArrayList<XmlInspectorFactory>();
    29
    30  	public XmlInspectorRegistry()
    31  	{
    32  	}
    33
    34  	public void addFactory( XmlInspectorFactory factory )
    35  	{
    36  		factories.add( factory );
    37  	}
    38
    39  	public static final XmlInspectorRegistry getInstance()
    40  	{
    41  		if( instance == null )
    42  			instance = new XmlInspectorRegistry();
    43
    44  		return instance;
    45  	}
    46
    47  	public XmlInspectorFactory [] getFactories()
    48  	{
    49  		return factories.toArray( new XmlInspectorFactory[factories.size()] );
    50  	}
    51
    52  	public XmlInspectorFactory [] getFactoriesOfType( Class type )
    53  	{
    54  		List<XmlInspectorFactory> result = new ArrayList<XmlInspectorFactory>();
    55  		for( XmlInspectorFactory factory : factories )
    56  		{
    57  			if( Arrays.asList( factory.getClass().getInterfaces() ).contains( type ))
    58  				result.add( factory );
    59  		}
    60
    61  		return result.toArray( new XmlInspectorFactory[result.size()] );
    62  	}
    63  }