Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-07-07 14:49:18 +0000
committerCamille Letavernier2014-07-07 14:49:18 +0000
commita10838037fe1d1bd44e6f0e135b2b55dcb1c8936 (patch)
tree2c8adee29edf9e9428669520c1c32640b2162a6e
parent4ff77c2977c868122e203aca002c4e0f5e9563fc (diff)
downloadorg.eclipse.papyrus-a10838037fe1d1bd44e6f0e135b2b55dcb1c8936.tar.gz
org.eclipse.papyrus-a10838037fe1d1bd44e6f0e135b2b55dcb1c8936.tar.xz
org.eclipse.papyrus-a10838037fe1d1bd44e6f0e135b2b55dcb1c8936.zip
439031: [Performances] The decoration service parses the decoration
extension point in each call to DecorationSpecificFunctions https://bugs.eclipse.org/bugs/show_bug.cgi?id=439031 - Cache the contributions to the extension point
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java36
1 files changed, 26 insertions, 10 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java
index 4a9d898b16a..33207a6ef2d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.decoration/src/org/eclipse/papyrus/infra/services/decoration/util/DecorationSpecificFunctions.java
@@ -1,18 +1,21 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
- *
+ *
* 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:
- * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ * Ansgar Radermacher (CEA LIST) - ansgar.radermacher@cea.fr
+ * Camille Letavernier (CEA LIST) - camille.letavernier@cea.fr - Bug 439031
*****************************************************************************/
-
package org.eclipse.papyrus.infra.services.decoration.util;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
@@ -24,9 +27,9 @@ import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunction
/**
* Return access to the extensions of interface IDecorationSpecificFunctions
- *
+ *
* @author ansgar
- *
+ *
*/
public class DecorationSpecificFunctions {
@@ -34,23 +37,36 @@ public class DecorationSpecificFunctions {
public static final String DECORATION_TYPE_ID = "decorationType";
+ public static Map<String, IDecorationSpecificFunctions> decorationFunctions;
+
public static IDecorationSpecificFunctions getDecorationInterface(String decorationType) {
+ if(decorationFunctions == null) {
+ parseDecorationFunctions();
+ }
+
+ return decorationFunctions.get(decorationType);
+ }
+
+ private static void parseDecorationFunctions() {
+ decorationFunctions = new HashMap<String, IDecorationSpecificFunctions>();
+
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] configElements = reg.getConfigurationElementsFor(DECORATION_SPECIFIC_FUNCTIONS_ID);
for(IConfigurationElement configElement : configElements) {
try {
final String iConfiguratorIDext = configElement.getAttribute(DECORATION_TYPE_ID);
- if((iConfiguratorIDext != null) && iConfiguratorIDext.equals(decorationType)) {
- // TODO: cache returned instance (avoid creating a new instance each time => more efficient, no need for static attributes)
+ if(iConfiguratorIDext != null) {
final Object obj = configElement.createExecutableExtension("class");
if(obj instanceof IDecorationSpecificFunctions) {
- return (IDecorationSpecificFunctions)obj;
+ decorationFunctions.put(iConfiguratorIDext, (IDecorationSpecificFunctions)obj);
+ } else {
+ Activator.log.warn(String.format("The plug-in %s contributed an invalid class to the %s extension point. Contributions should extend %s", //$NON-NLS-1$
+ configElement.getContributor(), DECORATION_SPECIFIC_FUNCTIONS_ID, IDecorationSpecificFunctions.class.getSimpleName()));
}
}
} catch (CoreException exception) {
- exception.printStackTrace();
+ Activator.log.error(exception);
}
}
- return null;
}
}

Back to the top