Skip to main content
summaryrefslogtreecommitdiffstats
blob: 59b3831ce21e232758ec69f1a364013a83e511fa (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
/*******************************************************************************
 * Copyright (c) 2000, 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.common;

import java.util.Hashtable;
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.wst.common.environment.EnvironmentService;
import org.eclipse.wst.common.environment.ILog;



/**
* This is the registry of WebServiceStartServerType objects.
*/
public class WebServiceStartServerRegistry
{

  private static WebServiceStartServerRegistry instance_;
  private Hashtable StartServerTypes;

  //
  // Loads WebServiceStartServerType objects into this registry.
  // See method getInstance().
  //
  private void load ()
  {
    StartServerTypes = new Hashtable();
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] config = reg.getConfigurationElementsFor(
                                     "org.eclipse.jst.ws.consumption",
                                     "webServiceStartServerType");

    for(int idx=0; idx<config.length; idx++) 
    {
      IConfigurationElement elem = config[idx];
      try 
      {
          String factoryId_ = elem.getAttribute("factoryId");
		  StartServerTypes.put(factoryId_, elem);
	  
      } 
      catch (Exception e)
      {
        ILog log = EnvironmentService.getEclipseLog();
        log.log(ILog.ERROR, 5047, this, "load", e);
      }
      
    }
  }

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

   public Object getServerStartByTypeId (String typeID) throws CoreException
   {
    if (typeID==null)
      return null;
    return ((IConfigurationElement)StartServerTypes.get(typeID)).createExecutableExtension("class");
  }
  
   public boolean isRemoveEARRequired(String typeId) throws CoreException {
   	if (typeId!=null) {
   		IConfigurationElement elem = (IConfigurationElement)StartServerTypes.get(typeId);
   		if (elem!=null){
   			String value = elem.getAttribute("removeEAR");
   			if (value!=null){
   				return Boolean.valueOf(value).booleanValue();
   			}
   		}
   	}
	return true;   		 
   }   
}




Back to the top