Skip to main content
summaryrefslogtreecommitdiffstats
blob: 04d7c929286607a4db0c453e63aa9f45fb6b2b3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*******************************************************************************
 * Copyright (c) 2002, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jst.ws.internal.consumption.wsfinder;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;

public class WSFinderRegistry
{
  private static WSFinderRegistry instance_;
  private Vector wsfinders_;

  private WSFinderRegistry()
  {
    wsfinders_ = new Vector();
  }
  
  /**
  * Returns a singleton instance of this class.
  * @return A singleton WSFinderRegistry object.
  */
  public static WSFinderRegistry getInstance()
  {
    if (instance_ == null)
    {
      instance_ = new WSFinderRegistry();
      instance_.init();
    }
    return instance_;
  }
  
  private void init()
  {
    IExtensionRegistry pluginReg = Platform.getExtensionRegistry();
    IConfigurationElement[] configElements = pluginReg.getConfigurationElementsFor("org.eclipse.jst.ws.consumption", "wsfinder");
    for (int i = 0; i < configElements.length; i++)
    {
      try
      {
        Object object = configElements[i].createExecutableExtension("class");
        if (object instanceof IWSFinder)
        {
          IWSFinder wsfinder = (IWSFinder)object;
          wsfinder.setID(configElements[i].getAttribute("id"));
          wsfinder.setName(configElements[i].getAttribute("name"));
          wsfinder.setDescription(configElements[i].getAttribute("description"));
          wsfinders_.add(wsfinder);
        }
      }
      catch (CoreException ce)
      {
      }
    }
  }

  public List getWSFinders()
  {
    return wsfinders_;
  }
  
  public List getWebServices()
  {
    List ws = new Vector();
    List wsFinders = getWSFinders();
    for (Iterator it = wsFinders.iterator(); it.hasNext();)
    {
      IWSFinder wsFinder = (IWSFinder)it.next();
      ws.addAll(wsFinder.find());
    }
    return ws;
  }
}

Back to the top