Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenn Hussey2012-05-14 00:20:03 +0000
committerKenn Hussey2012-05-14 00:20:03 +0000
commit99f1b3bdc3742b4e708769564eeae89e047d3e52 (patch)
treeb8fcacae8e1bb98c31a50d4fd7a6d055df98818c
parentfac207ea53da3032eaa1d99118f6af923312ba57 (diff)
downloadorg.eclipse.uml2.git.040612-99f1b3bdc3742b4e708769564eeae89e047d3e52.tar.gz
org.eclipse.uml2.git.040612-99f1b3bdc3742b4e708769564eeae89e047d3e52.tar.xz
org.eclipse.uml2.git.040612-99f1b3bdc3742b4e708769564eeae89e047d3e52.zip
[335125] Adding thead local support for cache adapter singleton.
-rw-r--r--plugins/org.eclipse.uml2.common/src/org/eclipse/uml2/common/util/CacheAdapter.java29
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java7
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java4
3 files changed, 32 insertions, 8 deletions
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 8e364b23..311a2a28 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 @@ public class CacheAdapter
}
}
+ /**
+ * @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 51cb95df..e5d8aab1 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 @@ public abstract class ElementImpl
* @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 df22fbcd..e1d36702 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 class UMLUtil
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);

Back to the top