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 387147 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.core/web/orion/serviceregistry.js (-15 / +31 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * @license
2
 * @license
3
 * Copyright (c) 2011, 2012 IBM Corporation and others.
3
 * Copyright (c) 2011, 2013 IBM Corporation and others.
4
 * All rights reserved. This program and the accompanying materials are made 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 
5
 * available under the terms of the Eclipse Public License v1.0
6
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
6
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
7
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
7
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
10
 *     IBM Corporation - initial API and implementation
Lines 132-138 Link Here
132
			}
132
			}
133
		}
133
		}
134
	}
134
	}
135
	
135
136
	function ServiceEvent(type, serviceReference) {
136
	function ServiceEvent(type, serviceReference) {
137
		this.type = type;
137
		this.type = type;
138
		this.serviceReference = serviceReference;
138
		this.serviceReference = serviceReference;
Lines 140-146 Link Here
140
140
141
	/**
141
	/**
142
	 * Creates a new service registry
142
	 * Creates a new service registry
143
	 * 
143
	 *
144
	 * @name orion.serviceregistry.ServiceRegistry
144
	 * @name orion.serviceregistry.ServiceRegistry
145
	 * @class The Orion service registry
145
	 * @class The Orion service registry
146
	 */
146
	 */
Lines 158-164 Link Here
158
				var entry = _this._entries[serviceId];
158
				var entry = _this._entries[serviceId];
159
				if (!entry) {
159
				if (!entry) {
160
					throw new Error("already unregistered");
160
					throw new Error("already unregistered");
161
				}				
161
				}
162
				var reference = entry.reference;
162
				var reference = entry.reference;
163
				_this._serviceEventTarget.dispatchEvent(new ServiceEvent("unregistering", reference));
163
				_this._serviceEventTarget.dispatchEvent(new ServiceEvent("unregistering", reference));
164
				_this._entries[serviceId] = null;
164
				_this._entries[serviceId] = null;
Lines 181-193 Link Here
181
				var entry = _this._entries[serviceId];
181
				var entry = _this._entries[serviceId];
182
				if (!entry) {
182
				if (!entry) {
183
					throw new Error("already unregistered");
183
					throw new Error("already unregistered");
184
				}				
184
				}
185
				var reference = entry.reference;
185
				var reference = entry.reference;
186
				_this._serviceEventTarget.dispatchEvent(new ServiceEvent("modified", reference));
186
				_this._serviceEventTarget.dispatchEvent(new ServiceEvent("modified", reference));
187
			}
187
			}
188
		};
188
		};
189
	}
189
	}
190
	
190
191
	ServiceRegistry.prototype = /** @lends orion.serviceregistry.ServiceRegistry.prototype */
191
	ServiceRegistry.prototype = /** @lends orion.serviceregistry.ServiceRegistry.prototype */
192
	{
192
	{
193
193
Lines 243-256 Link Here
243
			if (typeof service === "undefined" ||  service === null) {
243
			if (typeof service === "undefined" ||  service === null) {
244
				throw new Error("invalid service");
244
				throw new Error("invalid service");
245
			}
245
			}
246
			
246
247
			if (typeof names === "string") {
247
			if (typeof names === "string") {
248
				names = [names];
248
				names = [names];
249
			} else if (!Array.isArray(names)) {
249
			} else if (!Array.isArray(names)) {
250
				names = [];
250
				names = [];
251
			}
251
			}
252
			
252
253
			var serviceId = this._entries.length;			
253
			var serviceId = this._entries.length;
254
			var reference = new ServiceReference(serviceId, names, properties);
254
			var reference = new ServiceReference(serviceId, names, properties);
255
			var namedReferences = this._namedReferences;
255
			var namedReferences = this._namedReferences;
256
			names.forEach(function(name) {
256
			names.forEach(function(name) {
Lines 268-285 Link Here
268
		},
268
		},
269
269
270
		/**
270
		/**
271
		 * Adds a listener for events on this registry
271
		 * @name addEventListener
272
		 * @description Adds a listener for events on this registry
273
		 * @function
274
		 * @public
275
		 * @memberOf ServiceRegistry
272
		 * @param {String} eventName The name of the event to listen for
276
		 * @param {String} eventName The name of the event to listen for
273
		 * @param {Function} listener The listener to add
277
		 * @param {Function} listener The listener to add
278
		 *
279
		 * @event modified The service has been changed in the registry
280
		 * @event registered The service has been successfully registered with the registry
281
		 * @event unregistering The service is unregistering from the registry
274
		 */
282
		 */
275
		addEventListener: function(eventName, listener) {
283
		addEventListener: function(eventName, listener) {
276
			this._serviceEventTarget.addEventListener(eventName, listener);
284
			this._serviceEventTarget.addEventListener(eventName, listener);
277
		},
285
		},
278
286
279
		/**
287
		/**
280
		 * Removes a listener for events on this registry
288
		 * @name removeEventListener
289
		 * @description Removes a listener for events on this registry
290
		 * @function
291
		 * @public
292
		 * @memberOf ServiceRegistry
281
		 * @param {String} eventName The name of the event to stop listening for
293
		 * @param {String} eventName The name of the event to stop listening for
282
		 * @param {Function} listener The listener to remove
294
		 * @param {Function} listener The listener to remove
295
		 *
296
		 * @event modified The service has been changed in the registry
297
		 * @event registered The service has been successfully registered with the registry
298
		 * @event unregistering The service is unregistering from the registry
283
		 */
299
		 */
284
		removeEventListener: function(eventName, listener) {
300
		removeEventListener: function(eventName, listener) {
285
			this._serviceEventTarget.removeEventListener(eventName, listener);
301
			this._serviceEventTarget.removeEventListener(eventName, listener);

Return to bug 387147