Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 316332 | Differences between
and this patch

Collapse All | Expand All

(-)servercore/org/eclipse/wst/server/core/internal/facets/RuntimeBridge.java (-29 / +33 lines)
Lines 11-30 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.server.core.internal.facets;
12
package org.eclipse.wst.server.core.internal.facets;
13
13
14
import java.util.ArrayList;
14
import java.util.*;
15
import java.util.HashMap;
15
16
import java.util.HashSet;
16
import org.eclipse.core.runtime.*;
17
import java.util.List;
17
import org.eclipse.wst.common.project.facet.core.runtime.*;
18
import java.util.Map;
19
import java.util.Set;
20
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeBridge;
25
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
26
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion;
27
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
28
import org.eclipse.wst.server.core.IRuntime;
18
import org.eclipse.wst.server.core.IRuntime;
29
import org.eclipse.wst.server.core.IRuntimeType;
19
import org.eclipse.wst.server.core.IRuntimeType;
30
import org.eclipse.wst.server.core.ServerCore;
20
import org.eclipse.wst.server.core.ServerCore;
Lines 105-131 Link Here
105
	public IStub bridge(String name) throws CoreException {
95
	public IStub bridge(String name) throws CoreException {
106
		if (name == null)
96
		if (name == null)
107
			throw new IllegalArgumentException();
97
			throw new IllegalArgumentException();
108
		
98
		return new Stub(name);
109
		IRuntime[] runtimes = ServerCore.getRuntimes();
110
		int size = runtimes.length;
111
		for (int i = 0; i < size; i++) {
112
			if (runtimes[i].getId().equals(name))
113
				return new Stub(runtimes[i]);
114
			if (runtimes[i].getName().equals(name))
115
				return new Stub(runtimes[i]);
116
		}
117
		return null;
118
	}
99
	}
119
100
120
	private static class Stub extends IRuntimeBridge.Stub {
101
	private static class Stub extends IRuntimeBridge.Stub {
121
		private IRuntime runtime;
102
		private String id;
122
103
123
		public Stub(IRuntime runtime) {
104
		public Stub(String id) {
124
			this.runtime = runtime;
105
			this.id = id;
125
		}
106
		}
126
107
127
		public List<IRuntimeComponent> getRuntimeComponents() {
108
		public List<IRuntimeComponent> getRuntimeComponents() {
128
			List<IRuntimeComponent> components = new ArrayList<IRuntimeComponent>(2);
109
			List<IRuntimeComponent> components = new ArrayList<IRuntimeComponent>(2);
110
			final IRuntime runtime = findRuntime( this.id );
111
			
129
			if (runtime == null)
112
			if (runtime == null)
130
				return components;
113
				return components;
131
			
114
			
Lines 159-164 Link Here
159
142
160
		public Map<String, String> getProperties() {
143
		public Map<String, String> getProperties() {
161
			final Map<String, String> props = new HashMap<String, String>();
144
			final Map<String, String> props = new HashMap<String, String>();
145
            final IRuntime runtime = findRuntime( this.id );
162
			if (runtime != null) {
146
			if (runtime != null) {
163
				props.put("id", runtime.getId());
147
				props.put("id", runtime.getId());
164
				props.put("localized-name", runtime.getName());
148
				props.put("localized-name", runtime.getName());
Lines 170-176 Link Here
170
		}
154
		}
171
		
155
		
172
		public IStatus validate(final IProgressMonitor monitor) {
156
		public IStatus validate(final IProgressMonitor monitor) {
173
		    return runtime.validate( monitor );
157
            final IRuntime runtime = findRuntime( this.id );
174
		}
158
            if( runtime != null ) {
159
                return runtime.validate( monitor );
160
            }
161
            return Status.OK_STATUS; 
162
		}
163
		
164
		private static final IRuntime findRuntime( final String id )
165
		{
166
	        IRuntime[] runtimes = ServerCore.getRuntimes();
167
	        int size = runtimes.length;
168
169
	        for (int i = 0; i < size; i++) {
170
	            if (runtimes[i].getId().equals(id))
171
	                return runtimes[i];
172
	            if (runtimes[i].getName().equals(id))
173
	                return runtimes[i];
174
175
	        }
176
177
	        return null;
178
	    }
175
	}
179
	}
176
}
180
}

Return to bug 316332