Skip to main content
summaryrefslogtreecommitdiffstats
blob: 427957df7f4ed1b45ee1ef659effb209362ed457 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*******************************************************************************
 * Copyright (c) 2005, 2010 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
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20060427   126780 rsinha@ca.ibm.com - Rupam Kuehner
 * 20100811   322429 mahutch@ca.ibm.com - Mark Hutchinson, Improve performance of launching the Web Services Wizard
 *******************************************************************************/

package org.eclipse.jst.ws.internal.consumption.ui.wsrt;

import java.util.ArrayList;
import java.util.Hashtable;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;

public class WebServiceRuntimeExtensionRegistry2
{

  private static WebServiceRuntimeExtensionRegistry2 instance_;

  //webServiceImpls_: 
  //key: id attribute of extension to org.eclipse.jst.ws.consumption.ui.wsImpl
  //value: org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceImpl 
  Hashtable webServiceImpls_;

  //webServiceClientImpls_: 
  //key: id attribute of extension to org.eclipse.jst.ws.consumption.ui.wsClientImpl
  //value: org.eclipse.jst.ws.internal.consumption.ui.wsrt.WebServiceClientImpl  
  Hashtable webServiceClientImpls_;

  //runtimes_: 
  //key: id attribute of extension to org.eclipse.jst.ws.consumption.ui.runtimes
  //value: org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor
  Hashtable runtimes_;
  
  //serviceRuntimes_: 
  //key: id attribute of extension to org.eclipse.jst.ws.consumption.ui.serviceRuntimes
  //value: org.eclipse.jst.ws.internal.consumption.ui.wsrt.ServiceRuntimeDescriptor
  Hashtable serviceRuntimes_;
  
  //clientRuntimes_: 
  //key: id attribute of extension to org.eclipse.jst.ws.consumption.ui.clientRuntimes
  //value: org.eclipse.jst.ws.internal.consumption.ui.wsrt.ClientRuntimeDescriptor  
  Hashtable clientRuntimes_;
  
  //webServiceTypesList_ contains a list of String values in this form: "scenario/webServiceImplId",
  //where sceanrio the String representation of one of 
  //org.eclipse.wst.ws.internal.wsrt.WebServiceScenario.BOTTOM_UP or 
  //org.eclipse.wst.ws.internal.wsrt.WebServiceScenario.TOP_DOWN
  //and webServiceImplId is the id attribute of an extension to org.eclipse.jst.ws.consumption.ui.wsImpl
  //This list is used to determine the items displayed in the WebServiceType combo-box of page 1 of the 
  //Web serivce wizard.
  ArrayList webServiceTypesList_;
  
  //TODO: Not used. Remove this and all references to it in this class.
  ArrayList webServiceClientTypesList_;  
  
  
  /**
   * Returns a singleton instance of this class.
   * 
   * @return A singleton WebServiceRuntimeExtensionRegistry2 object.
   */
  public static WebServiceRuntimeExtensionRegistry2 getInstance()
  {
    if (instance_ == null)
    {
      instance_ = new WebServiceRuntimeExtensionRegistry2();
      instance_.load();
    }
    return instance_;
  }

  private void load()
  {
    webServiceImpls_ = new Hashtable();
    webServiceClientImpls_ = new Hashtable();
    runtimes_ = new Hashtable();
    serviceRuntimes_ = new Hashtable();
    clientRuntimes_ = new Hashtable();
    webServiceTypesList_ = new ArrayList();
    webServiceClientTypesList_ = new ArrayList();
    
    
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    
//  Load WebServiceImpls by reading all extensions to org.eclipse.jst.ws.consumption.ui.wsImpl
    IConfigurationElement[] wsImplExts = reg.getConfigurationElementsFor(
        "org.eclipse.jst.ws.consumption.ui", "wsImpl");
    
    for(int idx=0; idx<wsImplExts.length; idx++) 
    {
      IConfigurationElement elem = wsImplExts[idx];        
        if (elem.getName().equals("webServiceImpl"))
        {
          WebServiceImpl wsimpl = new WebServiceImpl(elem);          
          webServiceImpls_.put(elem.getAttribute("id"), wsimpl);
        }        
    }
    
    //Load WebServiceClientImpls by reading all extensions to org.eclipse.jst.ws.consumption.ui.wsClientImpl
    IConfigurationElement[] wsClientImplExts = reg.getConfigurationElementsFor(
        "org.eclipse.jst.ws.consumption.ui", "wsClientImpl");
    
    for(int idx=0; idx<wsClientImplExts.length; idx++) 
    {
      IConfigurationElement elem = wsClientImplExts[idx];

        if (elem.getName().equals("webServiceClientImpl"))
        {
          WebServiceClientImpl wsClientImpl = new WebServiceClientImpl(elem);
          webServiceClientImpls_.put(elem.getAttribute("id"), wsClientImpl);
        }        
    }
    
    //Load runtimes by reading all extensions to org.eclipse.jst.ws.consumption.ui.runtimes
    IConfigurationElement[] runtimeExts = reg.getConfigurationElementsFor(
        "org.eclipse.jst.ws.consumption.ui", "runtimes");
    
    for(int idx=0; idx<runtimeExts.length; idx++) 
    {
      IConfigurationElement elem = runtimeExts[idx];

        if (elem.getName().equals("runtime"))
        {
          RuntimeDescriptor rd = new RuntimeDescriptor(elem);
          runtimes_.put(elem.getAttribute("id"), rd);
        }        
    }
    
    //Load serviceRuntimes by reading all extensions to org.eclipse.jst.ws.consumption.ui.serviceRuntimes
    IConfigurationElement[] serviceRuntimeExts = reg.getConfigurationElementsFor(
        "org.eclipse.jst.ws.consumption.ui", "serviceRuntimes");
    
    for(int idx=0; idx<serviceRuntimeExts.length; idx++) 
    {
      IConfigurationElement elem = serviceRuntimeExts[idx];

        if (elem.getName().equals("serviceRuntime"))
        {
          ServiceRuntimeDescriptor rd = new ServiceRuntimeDescriptor(elem, webServiceImpls_, runtimes_);
          serviceRuntimes_.put(elem.getAttribute("id"), rd);          
          updateWebServiceTypeList(rd);
        }        
    }
    
    //Load clientRuntimes by reading all extensions to org.eclipse.jst.ws.consumption.ui.clientRuntimes
    IConfigurationElement[] clientRuntimeExts = reg.getConfigurationElementsFor(
        "org.eclipse.jst.ws.consumption.ui", "clientRuntimes");
    
    for(int idx=0; idx<clientRuntimeExts.length; idx++) 
    {
      IConfigurationElement elem = clientRuntimeExts[idx];

      if (elem.getName().equals("clientRuntime"))
      {
        ClientRuntimeDescriptor rd = new ClientRuntimeDescriptor(elem, webServiceClientImpls_, runtimes_);
        clientRuntimes_.put(elem.getAttribute("id"), rd);
        updateWebServiceClientTypeList(rd);
          
      }        
    }
    
    //Load clientRuntimeProperties and update client Runtimes
    IConfigurationElement[] clientRuntimeProperties = reg.getConfigurationElementsFor(
            "org.eclipse.jst.ws.consumption.ui", "clientRuntimeProperties");
    for (IConfigurationElement elem : clientRuntimeProperties) {
    	String clientRuntimeId = elem.getAttribute("clientRuntimeId");
    	if (clientRuntimeId != null) {
	    	ClientRuntimeDescriptor rd = (ClientRuntimeDescriptor)clientRuntimes_.get(clientRuntimeId);
	    	if (rd!=null) {
	    		rd.processClientRuntimeProperties(elem);
	    	}
    	}
    }
    
  //Load serviceRuntimeProperties and update service Runtimes
    IConfigurationElement[] serviceRuntimeProperties = reg.getConfigurationElementsFor(
            "org.eclipse.jst.ws.consumption.ui", "serviceRuntimeProperties");
    for (IConfigurationElement elem : serviceRuntimeProperties) {
    	String serviceRuntimeId = elem.getAttribute("serviceRuntimeId");
    	if (serviceRuntimeId != null) {
	    	ServiceRuntimeDescriptor rd = (ServiceRuntimeDescriptor)serviceRuntimes_.get(serviceRuntimeId);
	    	if (rd!=null) {
	    		rd.processServiceRuntimeProperties(elem);
	    	}
    	}
    }
  }  
    
  /**
   * Updates the list of Web service types with the provided service runtime's contribution of
   * scenario/webServiceImpl combination.
   * @param descriptor
   */
  private void updateWebServiceTypeList(ServiceRuntimeDescriptor descriptor)
  {
    String serviceImplId = descriptor.getServiceImplementationType().getId();
    boolean bottomUp = descriptor.getBottomUp();
    boolean topDown = descriptor.getTopDown();
    if (bottomUp)
    {
      StringBuffer entrybuff = new StringBuffer();
      entrybuff.append(String.valueOf(WebServiceScenario.BOTTOMUP));
      entrybuff.append("/");
      entrybuff.append(serviceImplId);
      String entry = entrybuff.toString();
      if (!webServiceTypesList_.contains(entry))
      {
        webServiceTypesList_.add(entry);
      }      
    }
    
    if (topDown)
    {
      StringBuffer entrybuff = new StringBuffer();
      entrybuff.append(String.valueOf(WebServiceScenario.TOPDOWN));
      entrybuff.append("/");
      entrybuff.append(serviceImplId);
      String entry = entrybuff.toString();
      if (!webServiceTypesList_.contains(entry))
      {
        webServiceTypesList_.add(entry);
      }      
    }
  }
  
  private void updateWebServiceClientTypeList(ClientRuntimeDescriptor descriptor)
  {
    String clientImplId = descriptor.getClientImplementationType().getId();
    StringBuffer entrybuff = new StringBuffer();
    entrybuff.append(String.valueOf(WebServiceScenario.CLIENT));
    entrybuff.append("/");
    entrybuff.append(clientImplId);
    String entry = entrybuff.toString();
    if (!webServiceClientTypesList_.contains(entry))
    {
      webServiceClientTypesList_.add(entry);
    }    
  }
  
}

Back to the top