Skip to main content
summaryrefslogtreecommitdiffstats
blob: 07f66dd146cbcf4fc67a5edbb64c746bd1bf197b (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*******************************************************************************
 * Copyright (c) 2000, 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 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.ws.internal.ext;

import java.util.Hashtable;
import java.util.Vector;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.wst.ws.internal.data.LabelsAndIds;


/**
* This is a generic registry which sets up general code in handling   
* IConfigElements for an extension
*/
public abstract class WebServiceExtensionRegistryImpl implements WebServiceExtensionRegistry
{
  // Copyright
  public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";
  
  private Hashtable nameExtensionTable_;
  private Vector id_;
  private Vector label_;
  private LabelsAndIds labelsandids_;
    
  public WebServiceExtensionRegistryImpl()
  {
    nameExtensionTable_ = new Hashtable();
    label_ = new Vector();
    id_ = new Vector();
    loadExtensions();
  }
  
  /**
  * Children registries will have different extension types 
  * @return WebserviceExtension holds a config elem
  * for that extension capable of creating an executable file
  */
  public abstract WebServiceExtension createWebServiceExtension(IConfigurationElement configElement);

  /**
  * Children must implement how they get the IConfigurationElement[] 
  * @return IConfigurationElement[] an array of elements particular to that
  * extension
  */
  public abstract IConfigurationElement[] getConfigElements();

  /*
  * Loads WebServiceExtensions for WebServiceClientTest into this registry.
  * This is done by querying the plugin registry for all extensions
  * that extend webServiceClientTest  
  */
  private void loadExtensions ()
  {    
    IConfigurationElement[] config = getConfigElements();

    for(int idx=0; idx<config.length; idx++) 
    {
      IConfigurationElement elem = config[idx];
      String label = elem.getAttribute( "label" );
      String id =   elem.getAttribute( "id" );      
      WebServiceExtension webServiceExtension = createWebServiceExtension(elem);	
      nameExtensionTable_.put(label,webServiceExtension);
      label_.add(label);
      id_.add(id);
    }
  }

  /**
  * Returns the names of all registered extensions
  * @return The names of all registered extensions.
  */
  public String[] getWebServiceExtensionNames ()
  {
    return (String[])nameExtensionTable_.keySet().toArray( new String[0] );
  }

  /**
   * Return the names and Ids 
   */
  public LabelsAndIds getLabelsAndIDs()
  {
  	labelsandids_ = new LabelsAndIds();
  	labelsandids_.setLabels_((String[])label_.toArray( new String[0] ));
  	labelsandids_.setIds_((String[])id_.toArray( new String[0] ));
  	return labelsandids_;
  }
  
  /**
  * Returns the extension object of the given name
  * @return WebServiceExtension object
  */
  public WebServiceExtension getWebServiceExtensionsByName( String name)
  {
    return (WebServiceExtension)nameExtensionTable_.get(name);
  }

  /**
  * Returns All extention objects in this registry
  *@return WebServiceExtension objects
  */
  public WebServiceExtension[] getWebServiceExtensions()
  {
    return (WebServiceExtension[])nameExtensionTable_.values().toArray( new WebServiceExtension[0] );
  }
  
}

Back to the top