Skip to main content
summaryrefslogtreecommitdiffstats
blob: e3f94263e7b76bb96ed781e372b7f3757d28614b (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
88
89
90
91
92
93
94
95
96
/*******************************************************************************
 * Copyright (c) 2002, 2005 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.ui.wizard;

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;
import org.eclipse.jst.ws.internal.consumption.ui.wizard.uddi.PublicUDDIRegistryType;


public class PublicUDDIRegistryTypeRegistry
{

  // Copyright
  public static final String copyright = "(c) Copyright IBM Corporation 2002.";

  private static PublicUDDIRegistryTypeRegistry instance_;
  private Vector types_;
  private Vector configElements_;

  private PublicUDDIRegistryTypeRegistry() {
    types_ = new Vector();
    configElements_ = new Vector();

    init();
  }

  /**
  * Returns a singleton instance of this class.
  * @return A singleton WebServiceClientTypeRegistry object.
  */
  public static PublicUDDIRegistryTypeRegistry getInstance() {
    if (instance_ == null) {
      instance_ = new PublicUDDIRegistryTypeRegistry();
    }
    
    return instance_;
  }

  public void init() {
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] config = reg.getConfigurationElementsFor(
                                     "org.eclipse.jst.ws.consumption.ui",
                                     "publicUDDIRegistryType");

    for (int i = 0; i < config.length; i++) {
      try {
        Object configElement = config[i].createExecutableExtension("class");

        if( configElement instanceof PublicUDDIRegistryType)  {
          types_.add(configElement);
          configElements_.add(config[i]);
        }
      }
      catch (CoreException e) {}
    }
  }

  public PublicUDDIRegistryType[] getAllPublicUDDIRegistryTypes() {
    PublicUDDIRegistryType[] types = new PublicUDDIRegistryType[types_.size()];
    for (int i = 0; i < types_.size(); i++) {
      types[i] = (PublicUDDIRegistryType)types_.elementAt(i);
    }
    return types;
  }

  public PublicUDDIRegistryType getPublicUDDIRegistryTypeByID(String id) {
    for (int i = 0; i < configElements_.size(); i++) {
      IConfigurationElement c = (IConfigurationElement)configElements_.elementAt(i);
      if (c.getAttribute("id").equals(id))
        return (PublicUDDIRegistryType)types_.elementAt(i);
    }
    return null;
  }

  public String getPublicUDDIRegistryTypeIDByName(String name) {
    for (int i = 0; i < types_.size(); i++) {
      PublicUDDIRegistryType type = (PublicUDDIRegistryType)types_.elementAt(i);
      if (type.getName().equals(name))
        return ((IConfigurationElement)configElements_.elementAt(i)).getAttribute("id");
    }
    return null;
  }

}

Back to the top