[335125] Adding thead local support for cache adapter singleton.
diff --git a/plugins/org.eclipse.uml2.common/src/org/eclipse/uml2/common/util/CacheAdapter.java b/plugins/org.eclipse.uml2.common/src/org/eclipse/uml2/common/util/CacheAdapter.java
index 8e364b2..311a2a2 100644
--- a/plugins/org.eclipse.uml2.common/src/org/eclipse/uml2/common/util/CacheAdapter.java
+++ b/plugins/org.eclipse.uml2.common/src/org/eclipse/uml2/common/util/CacheAdapter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2009 IBM Corporation, Embarcadero Technologies, and others.
+ * Copyright (c) 2004, 2012 IBM Corporation, Embarcadero Technologies, 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
@@ -8,8 +8,8 @@
  * Contributors:
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 204200, 220065
+ *   Kenn Hussey - 335125
  *
- * $Id: CacheAdapter.java,v 1.26 2009/03/13 20:41:16 jbruck Exp $
  */
 package org.eclipse.uml2.common.util;
 
@@ -116,8 +116,33 @@
 		}
 	}
 
+	/**
+	 * @deprecated
+	 * @see CacheAdapter#getInstance()
+	 */
 	public static final CacheAdapter INSTANCE = createCacheAdapter();
 
+	protected static final ThreadLocal<CacheAdapter> THREAD_LOCAL = System
+		.getProperty("org.eclipse.uml2.common.util.CacheAdapter.ThreadLocal") != null //$NON-NLS-1$
+		? new ThreadLocal<CacheAdapter>() {
+
+			@Override
+			protected CacheAdapter initialValue() {
+				return createCacheAdapter();
+			}
+
+		}
+		: null;
+
+	/**
+	 * @since 1.7
+	 */
+	public static CacheAdapter getInstance() {
+		return THREAD_LOCAL == null
+			? INSTANCE
+			: THREAD_LOCAL.get();
+	}
+
 	private static CacheAdapter createCacheAdapter() {
 		CacheAdapter cacheAdapter = UML2Util
 			.loadClassFromSystemProperty("org.eclipse.uml2.common.util.CacheAdapter.INSTANCE"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
index 51cb95d..e5d8aab 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011 IBM Corporation, CEA, and others.
+ * Copyright (c) 2005, 2012 IBM Corporation, CEA, 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
@@ -7,10 +7,9 @@
  *
  * Contributors:
  *   IBM - initial API and implementation
- *   Kenn Hussey - 286329, 323181
+ *   Kenn Hussey - 286329, 323181, 335125
  *   Kenn Hussey (CEA) - 327039
  *
- * $Id: ElementImpl.java,v 1.44 2010/09/28 21:02:13 khussey Exp $
  */
 package org.eclipse.uml2.uml.internal.impl;
 
@@ -816,7 +815,7 @@
 	 * @generated NOT
 	 */
 	protected CacheAdapter getCacheAdapter() {
-		return CacheAdapter.INSTANCE;
+		return CacheAdapter.getInstance();
 	}
 
 	/**
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index df22fbc..e1d3670 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -9,7 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 199624, 184249, 204406, 208125, 204200, 213218, 213903, 220669, 208016, 226396, 271470
  *   Nicolas Rouquette (JPL) - 260120, 313837
- *   Kenn Hussey - 286329, 313601, 314971, 344907, 236184
+ *   Kenn Hussey - 286329, 313601, 314971, 344907, 236184, 335125
  *   Kenn Hussey (CEA) - 327039, 358792, 364419, 366350
  *   Yann Tanguy (CEA) - 350402
  *
@@ -212,7 +212,7 @@
 		public EObject applyStereotype(Element element, EClass definition) {
 			EObject stereotypeApplication = EcoreUtil.create(definition);
 
-			CacheAdapter.INSTANCE.adapt(stereotypeApplication);
+			CacheAdapter.getInstance().adapt(stereotypeApplication);
 
 			EList<EObject> containmentList = getContainmentList(element,
 				definition);