Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: dc8f9c8240c47d0f62db37faa72b623ee9a789d1 (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
/*******************************************************************************
 * Copyright (c) 2005 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.wst.common.internal.emfworkbench.edit;

import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchEditResourceHandler;

/**
 * This is a readonly version of the editmodel access registry, only uses a weak hash dictionary,
 * and because the access is read only, is less concerned with timing of access/release, and will be
 * cleaned up on garbage collection if needed.
 * 
 */
public class ReadOnlyClientAccessRegistry extends ClientAccessRegistry {

	public ReadOnlyClientAccessRegistry() {
		super();
	}

	public synchronized void access(Object accessorKey) {
		if (!registry.containsKey(accessorKey)) {
			this.registry.put(accessorKey, null);
		} else
			throw new ClientAccessRegistryException(EMFWorkbenchEditResourceHandler.ClientAccessRegistry_ERROR_0, accessorKey);
	}

	public synchronized void release(Object accessorKey) {

		/*
		 * Error condition: Some one has been naughty and not released the resource
		 */
		if (this.registry.containsKey(accessorKey)) {
			this.registry.remove(accessorKey);
		} else
			complain(accessorKey);
	}

	public void complain(Object accessorKey) {

		throw new ClientAccessRegistryException(EMFWorkbenchResourceHandler.getString("ClientAccessRegistry_ERROR_1"), accessorKey); //$NON-NLS-1$
	}

}

Back to the top