01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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: private static XmlInspectorRegistry instance;
27: private List<XmlInspectorFactory> factories = new ArrayList<XmlInspectorFactory>();
28:
29: public XmlInspectorRegistry() {
30: }
31:
32: public void addFactory(XmlInspectorFactory factory) {
33: factories.add(factory);
34: }
35:
36: public static final XmlInspectorRegistry getInstance() {
37: if (instance == null)
38: instance = new XmlInspectorRegistry();
39:
40: return instance;
41: }
42:
43: public XmlInspectorFactory[] getFactories() {
44: return factories.toArray(new XmlInspectorFactory[factories
45: .size()]);
46: }
47:
48: public XmlInspectorFactory[] getFactoriesOfType(Class type) {
49: List<XmlInspectorFactory> result = new ArrayList<XmlInspectorFactory>();
50: for (XmlInspectorFactory factory : factories) {
51: if (Arrays.asList(factory.getClass().getInterfaces())
52: .contains(type))
53: result.add(factory);
54: }
55:
56: return result.toArray(new XmlInspectorFactory[result.size()]);
57: }
58: }
|