blob: 46bea11f762c1e5a49b82c136354e60a73405e01 (
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
118
|
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* yyyymmdd bug Email and other contact information
* -------- -------- -----------------------------------------------------------
* 20060821 153833 makandre@ca.ibm.com - Andrew Mak, Allow the Web Service Test extension point to specify the supported client runtime
*******************************************************************************/
package org.eclipse.jst.ws.internal.ext;
import java.util.Hashtable;
import java.util.Vector;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jst.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.";
protected Hashtable nameExtensionTable_;
protected Vector id_;
protected 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
*/
protected 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] );
}
}
|