Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2019-03-14 06:31:13 -0400
committerPatrick Tessier2019-05-06 07:58:35 -0400
commitf13d47654fd242d83b6e7db2d2aac29fc478bbdf (patch)
treed215d8578015a2d6dd601f3e436d92ff974f3a61 /plugins
parent89bc31de7736a1bfe9add4fdb050a98fa22ef697 (diff)
downloadorg.eclipse.papyrus-f13d47654fd242d83b6e7db2d2aac29fc478bbdf.tar.gz
org.eclipse.papyrus-f13d47654fd242d83b6e7db2d2aac29fc478bbdf.tar.xz
org.eclipse.papyrus-f13d47654fd242d83b6e7db2d2aac29fc478bbdf.zip
Bug 543723: [Performances] Improve the ClassLoaderHelper
https://bugs.eclipse.org/bugs/show_bug.cgi?id=543723 - Add a context URI or Bundle to all methods in ClassLoaderHelper - The context is used to find the most appropriate bundle to load the given class, to avoid relying on a very expensive Eclipse Buddy Policy Change-Id: Ia3c7cc86397643ff3fad634391dce68e5d509d4c Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDescriptionUtils.java89
-rw-r--r--plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/core/architecture/merged/MergedArchitectureContext.java11
-rw-r--r--plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaInstanceOf.java3
-rw-r--r--plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaQueryConstraint.java3
-rw-r--r--plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintFactory.java5
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ClassLoaderHelper.java366
-rwxr-xr-xplugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/GMFDiagramViewTypeHelper.java5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteViewer.java3
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSourceFactory.java4
-rw-r--r--plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultAdviceBindingFactory.java6
-rw-r--r--plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultEditHelperAdviceFactory.java5
-rw-r--r--plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultMatcherFactory.java5
-rw-r--r--plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/MetamodelTypeFactory.java4
13 files changed, 431 insertions, 78 deletions
diff --git a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDescriptionUtils.java b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDescriptionUtils.java
index 31f6e751410..122227344a6 100644
--- a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDescriptionUtils.java
+++ b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/architecture/ArchitectureDescriptionUtils.java
@@ -1,17 +1,17 @@
/**
* Copyright (c) 2017,2018 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Maged Elaasar - Initial API and implementation
* Benoit Maggi - Bug 535393
- *
+ *
*/
package org.eclipse.papyrus.infra.architecture;
@@ -48,33 +48,34 @@ public class ArchitectureDescriptionUtils {
* The model set in context
*/
private ModelSet modelSet;
-
+
/**
* The architecture domain manager
*/
private ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance();
-
+
/**
* Constructs an instance of this class given a model set
*
- * @param modelSet The given model set
+ * @param modelSet
+ * The given model set
*/
public ArchitectureDescriptionUtils(ModelSet modelSet) {
this.modelSet = modelSet;
}
-
+
/**
* Gets the model set in context
- *
+ *
* @return a model set
*/
public ModelSet getModelSet() {
return modelSet;
}
-
+
/**
* Gets the architecture context set in the model set
- *
+ *
* @return architecture context
*/
public MergedArchitectureContext getArchitectureContext() {
@@ -84,34 +85,36 @@ public class ArchitectureDescriptionUtils {
/**
* Gets the architecture context id set in the model set
- *
+ *
* @return architecture context id
*/
public String getArchitectureContextId() {
ArchitectureDescription description = DiModelUtils.getArchitectureDescription(modelSet);
- if (description != null)
+ if (description != null) {
return description.getContextId();
+ }
return ArchitectureDomainManager.getInstance().getDefaultArchitectureContextId();
}
/**
* Gets the architecture viewpoints set in the model set
- *
+ *
* @return a collection of architecture viewpoints
*/
public Collection<MergedArchitectureViewpoint> getArchitectureViewpoints() {
List<MergedArchitectureViewpoint> viewpoints = new ArrayList<>();
for (String viewpointId : getArchitectureViewpointIds()) {
MergedArchitectureViewpoint viewpoint = manager.getArchitectureViewpointById(viewpointId);
- if (viewpoint != null)
+ if (viewpoint != null) {
viewpoints.add(viewpoint);
+ }
}
return viewpoints;
}
/**
* Gets the architecture viewpoint ids set in the model set
- *
+ *
* @return a collection of architecture viewpoint ids
*/
public Collection<String> getArchitectureViewpointIds() {
@@ -137,12 +140,14 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command that applies the given contextId and viewpoint ids to the model set
* and creates a new model in the set based on them
- *
+ *
* Model creation is based on the creation command configured with the architecture context
* and contribution commands registered in extensions
- *
- * @param contextId the context id to apply to the model set
- * @param viewpointIds the viewpoint ids to apply to the model set
+ *
+ * @param contextId
+ * the context id to apply to the model set
+ * @param viewpointIds
+ * the viewpoint ids to apply to the model set
* @return a command to create a new model
*/
public Command createNewModel(final String contextId, final String[] viewpointIds) {
@@ -161,11 +166,12 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command that switches the contextId of the model set to the given id and
* converts the semantic model as a result
- *
+ *
* Model conversion is based on the conversion command configured with the architecture context
* and contribution commands registered in extensions
- *
- * @param contextId the context id to apply to the model set
+ *
+ * @param contextId
+ * the context id to apply to the model set
* @return a command that switches the model set to the given context id
*/
public Command switchArchitectureContextId(final String contextId) {
@@ -181,8 +187,9 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command that switches the viewpoints of the model set to the given id
- *
- * @param viewpointIds the new viewpoint ids to apply to the model set
+ *
+ * @param viewpointIds
+ * the new viewpoint ids to apply to the model set
* @return a command that switches the model set to the given viewpoint ids
*/
public Command switchArchitectureViewpointIds(final String[] viewpointIds) {
@@ -194,8 +201,9 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command to set the context id in the model set
- *
- * @param contextId the new context id
+ *
+ * @param contextId
+ * the new context id
* @return a command that sets the context id in the model set
*/
protected Command getSetContextCommand(String contextId) {
@@ -210,19 +218,21 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command to create a new model in the model set based on the given context id
- *
- * @param contextId the context id
+ *
+ * @param contextId
+ * the context id
* @return a command that creates a new model
*/
protected Command getModelCreationCommand(String contextId) {
final MergedArchitectureContext context = manager.getArchitectureContextById(contextId);
- if (context.getCreationCommandClassName() == null)
+ if (context.getCreationCommandClassName() == null) {
return UnexecutableCommand.INSTANCE;
+ }
return new RecordingCommand(modelSet.getTransactionalEditingDomain()) {
@Override
protected void doExecute() {
try {
- IModelCreationCommand creationCommand = (IModelCreationCommand) context.getCreationCommandClass().newInstance();
+ IModelCreationCommand creationCommand = context.getCreationCommandClass().newInstance();
creationCommand.createModel(modelSet);
} catch (Exception e) {
Activator.log.error(e);
@@ -230,22 +240,24 @@ public class ArchitectureDescriptionUtils {
}
};
}
-
+
/**
* Returns a command to converts a new model in the model set based on the given new context id
- *
- * @param contextId the new context id
+ *
+ * @param contextId
+ * the new context id
* @return a command that converts a model
*/
protected Command getModelConversionCommand(String contextId) {
MergedArchitectureContext context = manager.getArchitectureContextById(contextId);
- if (context.getConversionCommandClassName() == null)
+ if (context.getConversionCommandClassName() == null) {
return null;
+ }
return new RecordingCommand(modelSet.getTransactionalEditingDomain()) {
@Override
protected void doExecute() {
try {
- IModelConversionCommand conversionCommand = (IModelConversionCommand) context.getConversionCommandClass().newInstance();
+ IModelConversionCommand conversionCommand = context.getConversionCommandClass().newInstance();
conversionCommand.convertModel(modelSet);
} catch (Exception e) {
Activator.log.error(e);
@@ -256,8 +268,9 @@ public class ArchitectureDescriptionUtils {
/**
* Returns a command that sets the given viewpoint ids to the model set
- *
- * @param viewpointIds The new viewpoint ids
+ *
+ * @param viewpointIds
+ * The new viewpoint ids
* @return a command to set the viewpoint ids
*/
protected Command getSetViewpointCommand(String[] viewpointIds) {
@@ -270,5 +283,5 @@ public class ArchitectureDescriptionUtils {
}
};
}
-
+
}
diff --git a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/core/architecture/merged/MergedArchitectureContext.java b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/core/architecture/merged/MergedArchitectureContext.java
index 23e9b5cfa88..f7c0799ea4a 100644
--- a/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/core/architecture/merged/MergedArchitectureContext.java
+++ b/plugins/infra/architecture/org.eclipse.papyrus.infra.architecture/src/org/eclipse/papyrus/infra/core/architecture/merged/MergedArchitectureContext.java
@@ -22,6 +22,9 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.architecture.commands.IModelConversionCommand;
+import org.eclipse.papyrus.infra.architecture.commands.IModelCreationCommand;
import org.eclipse.papyrus.infra.core.architecture.ADElement;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureContext;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureViewpoint;
@@ -71,11 +74,11 @@ public abstract class MergedArchitectureContext extends MergedADElement {
*
* @return a creation command class
*/
- public Class<?> getCreationCommandClass() throws ClassNotFoundException {
+ public Class<? extends IModelCreationCommand> getCreationCommandClass() throws ClassNotFoundException {
for (ADElement element : elements) {
ArchitectureContext context = (ArchitectureContext) element;
if (context.getCreationCommandClass() != null) {
- return ClassLoaderHelper.loadClass(context.getCreationCommandClass());
+ return ClassLoaderHelper.loadClass(context.getCreationCommandClass(), IModelCreationCommand.class, EcoreUtil.getURI(context));
}
}
return null;
@@ -86,11 +89,11 @@ public abstract class MergedArchitectureContext extends MergedADElement {
*
* @return a conversion command class
*/
- public Class<?> getConversionCommandClass() throws ClassNotFoundException {
+ public Class<? extends IModelConversionCommand> getConversionCommandClass() throws ClassNotFoundException {
for (ADElement element : elements) {
ArchitectureContext context = (ArchitectureContext) element;
if (context.getConversionCommandClass() != null) {
- return ClassLoaderHelper.loadClass(context.getConversionCommandClass());
+ return ClassLoaderHelper.loadClass(context.getConversionCommandClass(), IModelConversionCommand.class, EcoreUtil.getURI(context));
}
}
return null;
diff --git a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaInstanceOf.java b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaInstanceOf.java
index b136b5766cd..503ceb2ed29 100644
--- a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaInstanceOf.java
+++ b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaInstanceOf.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.constraints.constraints;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
@@ -28,7 +29,7 @@ public class JavaInstanceOf extends AbstractConstraint {
@Override
public void setDescriptor(SimpleConstraint descriptor) {
- clazz = ClassLoaderHelper.loadClass(getValue("class")); //$NON-NLS-1$
+ clazz = ClassLoaderHelper.loadClass(getValue("class"), EcoreUtil.getURI(descriptor)); //$NON-NLS-1$
}
@Override
diff --git a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaQueryConstraint.java b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaQueryConstraint.java
index 12017fada3a..dcfe2892396 100644
--- a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaQueryConstraint.java
+++ b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/JavaQueryConstraint.java
@@ -14,6 +14,7 @@
/*****************************************************************************/
package org.eclipse.papyrus.infra.constraints.constraints;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.constraints.Activator;
import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.JavaQuery.FalseQuery;
@@ -42,7 +43,7 @@ public class JavaQueryConstraint extends AbstractConstraint {
@Override
protected void setDescriptor(SimpleConstraint descriptor) {
String queryClassName = getValue(QUERY_CLASS_NAME_PROPERTY);
- query = ClassLoaderHelper.newInstance(queryClassName, JavaQuery.class);
+ query = ClassLoaderHelper.newInstance(queryClassName, JavaQuery.class, EcoreUtil.getURI(descriptor));
if (query == null) {
Activator.log.warn("Cannot load the JavaQuery for this constraint : " + descriptor.getName());
}
diff --git a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintFactory.java b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintFactory.java
index a13baf96e1e..d250682f28a 100644
--- a/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintFactory.java
+++ b/plugins/infra/constraints/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/runtime/ConstraintFactory.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.constraints.runtime;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.constraints.Activator;
import org.eclipse.papyrus.infra.constraints.CompositeConstraint;
import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
@@ -46,7 +47,7 @@ public class ConstraintFactory {
* @param model
* The ConstraintDescriptor describing the Constraint
* @return
- * The new constraint instance
+ * The new constraint instance
*/
public Constraint createFromModel(ConstraintDescriptor model) {
Constraint constraint = null;
@@ -77,7 +78,7 @@ public class ConstraintFactory {
if (model.getConstraintType() != null) {
String className = model.getConstraintType().getConstraintClass();
- constraint = ClassLoaderHelper.newInstance(className, Constraint.class);
+ constraint = ClassLoaderHelper.newInstance(className, Constraint.class, EcoreUtil.getURI(model));
}
if (constraint == null) {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ClassLoaderHelper.java b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ClassLoaderHelper.java
index 2b763eb9c47..88f9cd00def 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ClassLoaderHelper.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ClassLoaderHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2019 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,34 +10,83 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 543723
*****************************************************************************/
package org.eclipse.papyrus.infra.tools.util;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.infra.tools.Activator;
+import org.osgi.framework.Bundle;
/**
- * A Helper class for Class Loading.
+ * <p>
+ * A Helper class for Class Loading. It keeps a cache of classes once they've been loaded,
+ * to speed up future lookups.
+ * </p>
+ * <p>
+ * When loading a class, it is recommended to pass a Bundle ID (Or URI), to narrow down the
+ * list of bundles to explore for that class. This helper can also take a simple qualified name,
+ * but in that case it will explore all bundles that depend on this bundle; which may have
+ * severe impact on performances (at least for initial load; after that, the cache will speed
+ * everything up).
+ * </p>
*
* @author Camille Letavernier
*/
-// This class needs the "BuddyPolicy" set to "dependent" in the Manifest.MF,
-// in order to be able to retrieve the classes it loads
-//
-// This is the org.eclipse.papyrus.infra.tools class loader which is used for loading
-// a class, instead of each caller's ClassLoader
-//
-// Plug-ins using this class should also either set their Buddy-policy to dependent or
-// reexport the dependency to oep.infra.tools
public class ClassLoaderHelper {
/**
* Usually, there are few classes with many different accesses. Using a cache, we can improve
- * the performances between 10 and 20 times, with really few memory consumption
+ * the performances between 10 and 20 times, with really little memory consumption
*/
- private static final Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
+ private static final Map<String, Class<?>> classes = new HashMap<>();
+
+ /**
+ * <p>
+ * Loads the class matching the given className. The context {@link URI} is
+ * used as a hint to find the most appropriate class loader: if this URI is
+ * a platform-plugin URI, the represented plug-in's class loader will be used.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the Class to load.
+ * @param context
+ * The context URI
+ * @return
+ * The loaded Class, or null if an error occurred
+ * @since 3.1
+ */
+ public static Class<?> loadClass(String className, URI context) {
+ if (classes.containsKey(className)) {
+ return classes.get(className);
+ }
+ return loadClass(className, getPluginId(context));
+ }
+
+ /**
+ * <p>
+ * Loads the class matching the given className from the specified bundle.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the Class to load.
+ * @param bundleId
+ * The bundle in which the class is located
+ * @return
+ * The loaded Class, or null if an error occurred
+ * @since 3.1
+ */
+ public static Class<?> loadClass(String className, String bundleId) {
+ if (classes.containsKey(className)) {
+ return classes.get(className);
+ }
+ Bundle bundle = Platform.getBundle(bundleId);
+ return bundle == null ? loadClass(className) : loadClass(className, bundle);
+ }
/**
* Loads the class matching the given className. Exceptions are caught and sent
@@ -46,18 +95,44 @@ public class ClassLoaderHelper {
* @param className
* The qualified name of the Class to load.
* @return
- * The loaded Class, or null if an error occured
+ * The loaded Class, or null if an error occurred
+ * @deprecated Since 3.1 This method is very slow (See Bug 543723).
+ * Use {@link #loadClass(String, Bundle)} instead
*/
+ @Deprecated
public static Class<?> loadClass(String className) {
+ Class<?> result = classes.get(className);
+ if (result == null) {
+ Activator.log.warn("Using ClassLoaderHelper#loadClass without an appropriate context. This may degrade performances (Class: " + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ return loadClass(className, Activator.getDefault().getBundle());
+ }
+ return result;
+ }
+
+ /**
+ * <p>
+ * Loads the class matching the given className from the specified bundle.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the Class to load.
+ * @param bundle
+ * The bundle in which the class is located
+ * @return
+ * The loaded Class, or null if an error occurred
+ * @since 3.1
+ */
+ public static Class<?> loadClass(String className, Bundle bundle) {
try {
Class<?> result = classes.get(className);
if (result == null) {
- result = Activator.getDefault().getBundle().loadClass(className);
+ result = bundle.loadClass(className);
classes.put(className, result);
}
return result;
} catch (ClassNotFoundException ex) {
Activator.log.error(String.format("The class %s doesn't exist", className), ex); //$NON-NLS-1$
+ return loadClass(className); // We received the wrong bundle-context, Fallback to the buddy-policy and try again
} catch (NullPointerException ex) {
Activator.log.error("Cannot load class " + className, ex); //$NON-NLS-1$
}
@@ -66,19 +141,77 @@ public class ClassLoaderHelper {
}
/**
- * Loads and returns the class denoted by the given className.
+ * <p>
+ * Loads and returns the class represented by the given className.
* Checks that the loaded class is a subtype of the given Class.
+ * </p>
+ * <p>
+ * The context {@link URI} is used as a hint to find the most appropriate
+ * class loader: if this URI is a platform-plugin URI, the represented
+ * plug-in's class loader will be used.
+ * </p>
*
* @param className
* The qualified name of the class to be loaded
* @param asSubClass
* The interface or class that the loaded class must implement or extend
+ * @param context
+ * The context URI
* @return
- * The loaded class, or null if the class doesn't exist or is invalid.
+ * The loaded class, or null if the class doesn't exist or is invalid.
* In such a case, the exception is logged.
+ * @since 3.1
*/
- public static <T> Class<? extends T> loadClass(String className, Class<T> asSubClass) {
- Class<?> theClass = loadClass(className);
+ public static <T> Class<? extends T> loadClass(String className, Class<T> asSubClass, URI context) {
+ return loadClass(className, asSubClass, getPluginId(context));
+ }
+
+ /**
+ * <p>
+ * Loads and returns the class represented by the given className
+ * from the specified bundle. Checks that the loaded class is a subtype
+ * of the given Class.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the class to be loaded
+ * @param asSubClass
+ * The interface or class that the loaded class must implement or extend
+ * @param bundleId
+ * The bundle in which the class is located
+ * @return
+ * The loaded class, or null if the class doesn't exist or is invalid.
+ * In such a case, the exception is logged.
+ * @since 3.1
+ */
+ public static <T> Class<? extends T> loadClass(String className, Class<T> asSubClass, String bundleId) {
+ return loadClass(className, asSubClass, bundleId == null ? null : Platform.getBundle(bundleId));
+ }
+
+ /**
+ * <p>
+ * Loads and returns the class represented by the given className
+ * from the specified bundle. Checks that the loaded class is a subtype
+ * of the given Class.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the class to be loaded
+ * @param asSubClass
+ * The interface or class that the loaded class must implement or extend
+ * @param bundle
+ * The bundle in which the class is located
+ * @return
+ * The loaded class, or null if the class doesn't exist or is invalid.
+ * In such a case, the exception is logged.
+ * @since 3.1
+ */
+ public static <T> Class<? extends T> loadClass(String className, Class<T> asSubClass, Bundle bundle) {
+ if (bundle == null) {
+ Activator.log.warn("Using ClassLoaderHelper#loadClass without an appropriate context. This may degrade performances (Class: " + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ bundle = Activator.getDefault().getBundle();
+ }
+ Class<?> theClass = loadClass(className, bundle);
if (theClass == null) {
return null;
}
@@ -94,6 +227,111 @@ public class ClassLoaderHelper {
}
/**
+ * Loads and returns the class denoted by the given className.
+ * Checks that the loaded class is a subtype of the given Class.
+ *
+ * @param className
+ * The qualified name of the class to be loaded
+ * @param asSubClass
+ * The interface or class that the loaded class must implement or extend
+ * @return
+ * The loaded class, or null if the class doesn't exist or is invalid.
+ * In such a case, the exception is logged.
+ * @deprecated Since 3.1 This method is very slow (See Bug 543723).
+ * Use {@link #loadClass(String, Class, Bundle)} instead
+ */
+ @Deprecated
+ public static <T> Class<? extends T> loadClass(String className, Class<T> asSubClass) {
+ if (!classes.containsKey(className)) {
+ Activator.log.warn("Using ClassLoaderHelper#loadClass without an appropriate context. This may degrade performances (Class: " + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return loadClass(className, asSubClass, Activator.getDefault().getBundle());
+ }
+
+ /**
+ * <p>
+ * Creates a new instance of class denoted by the given className.
+ * Checks that the instantiated class is a subtype of the given class.
+ * </p>
+ * <p>
+ * The context {@link URI} is used as a hint to find the most appropriate
+ * class loader: if this URI is a platform-plugin URI, the represented
+ * plug-in's class loader will be used.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the class to be instantiated
+ * @param asSubclass
+ * The interface or class that the loaded class must implement or extend
+ * @param context
+ * The context URI
+ * @return
+ * An instance of the loaded class, or null if a valid instance
+ * cannot be created. In such a case, the exception is logged.
+ * @since 3.1
+ */
+ public static <T> T newInstance(String className, Class<T> asSubclass, URI context) {
+ Class<? extends T> typedClass = loadClass(className, asSubclass, context);
+ if (typedClass == null) {
+ return null;
+ }
+
+ return newInstance(typedClass);
+ }
+
+ /**
+ * <p>
+ * Creates a new instance of class denoted by the given className from the specified bundle.
+ * Checks that the instantiated class is a subtype of the given class.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the class to be instantiated
+ * @param asSubclass
+ * The interface or class that the loaded class must implement or extend
+ * @param bundleId
+ * The bundle in which the class is located
+ * @return
+ * An instance of the loaded class, or null if a valid instance
+ * cannot be created. In such a case, the exception is logged.
+ * @since 3.1
+ */
+ public static <T> T newInstance(String className, Class<T> asSubclass, String bundleId) {
+ Class<? extends T> typedClass = loadClass(className, asSubclass, bundleId);
+ if (typedClass == null) {
+ return null;
+ }
+
+ return newInstance(typedClass);
+ }
+
+ /**
+ * <p>
+ * Creates a new instance of class denoted by the given className from the specified bundle.
+ * Checks that the instantiated class is a subtype of the given class.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the class to be instantiated
+ * @param asSubclass
+ * The interface or class that the loaded class must implement or extend
+ * @param bundle
+ * The bundle in which the class is located
+ * @return
+ * An instance of the loaded class, or null if a valid instance
+ * cannot be created. In such a case, the exception is logged.
+ * @since 3.1
+ */
+ public static <T> T newInstance(String className, Class<T> asSubclass, Bundle bundle) {
+ Class<? extends T> typedClass = loadClass(className, asSubclass, bundle);
+ if (typedClass == null) {
+ return null;
+ }
+
+ return newInstance(typedClass);
+ }
+
+ /**
* Creates a new instance of class denoted by the given className.
* Checks that the instantiated class is a subtype of the given class
*
@@ -102,9 +340,12 @@ public class ClassLoaderHelper {
* @param asSubclass
* The interface or class that the loaded class must implement or extend
* @return
- * An instance of the loaded class, or null if a valid instance
+ * An instance of the loaded class, or null if a valid instance
* cannot be created. In such a case, the exception is logged.
+ * @deprecated Since 3.1 This method is very slow (See Bug 543723).
+ * Use {@link #newInstance(String, Class, Bundle)} instead
*/
+ @Deprecated
public static <T> T newInstance(String className, Class<T> asSubclass) {
Class<? extends T> typedClass = loadClass(className, asSubclass);
if (typedClass == null) {
@@ -115,14 +356,76 @@ public class ClassLoaderHelper {
}
/**
+ * <p>
+ * Returns a new Instance of the given class.
+ * </p>
+ * <p>
+ * The context {@link URI} is used as a hint to find the most appropriate
+ * class loader: if this URI is a platform-plugin URI, the represented
+ * plug-in's class loader will be used.
+ * </p>
+ *
+ * @param className
+ * The qualified name of the Class to instantiate
+ * @param context
+ * the context URI
+ * @return
+ * A new instance of the given class, or null if the class couldn't be
+ * instantiated
+ * @since 3.1
+ */
+ public static Object newInstance(String className, URI context) {
+ return newInstance(loadClass(className, context));
+ }
+
+ /**
+ * </p>
+ * Returns a new Instance of the given class from the specified bundle
+ * </p>
+ *
+ * @param className
+ * The qualified name of the Class to instantiate
+ * @param bundleId
+ * The bundle in which the class is located
+ * @return
+ * A new instance of the given class, or null if the class couldn't be
+ * instantiated
+ * @since 3.1
+ */
+ public static Object newInstance(String className, String bundleId) {
+ return newInstance(loadClass(className, bundleId));
+ }
+
+ /**
+ * <p>
* Returns a new Instance of the given class
+ * </p>
*
* @param className
* The qualified name of the Class to instantiate
+ * @param bundle
+ * The bundle in which the class is located
* @return
- * A new instance of the given class, or null if the class couldn't be
+ * A new instance of the given class, or null if the class couldn't be
* instantiated
+ * @since 3.1
*/
+ public static Object newInstance(String className, Bundle bundle) {
+ return newInstance(loadClass(className, bundle));
+ }
+
+ /**
+ * Returns a new Instance of the given class
+ *
+ * @param className
+ * The qualified name of the Class to instantiate
+ * @return
+ * A new instance of the given class, or null if the class couldn't be
+ * instantiated
+ * @deprecated Since 3.1 This method is very slow (See Bug 543723).
+ * Use {@link #newInstance(String, Bundle)} instead
+ */
+ @Deprecated
public static Object newInstance(String className) {
return newInstance(loadClass(className));
}
@@ -133,7 +436,7 @@ public class ClassLoaderHelper {
* @param theClass
* The Class to instantiate
* @return
- * A new instance of the given class, or null if the class couldn't be
+ * A new instance of the given class, or null if the class couldn't be
* instantiated
*/
public static <T extends Object> T newInstance(Class<T> theClass) {
@@ -151,4 +454,25 @@ public class ClassLoaderHelper {
return null;
}
+
+ /**
+ * <p>
+ * Retrieve the bundle ID from a URI. The URI should be either a {@link URI#isPlatformPlugin() PlatformPlugin URI}
+ * or use the custom properties "ppe:/" protocol
+ * </p>
+ *
+ * @param uri
+ * @return
+ * The ID of the Bundle containing the model represented by this URI,
+ * or <code>null</code> if the URI doesn't reference a bundle
+ */
+ private static final String getPluginId(URI uri) {
+ if (uri != null && (uri.isPlatformPlugin() || "ppe".equals(uri.scheme()))) { // ppe is a custom URI scheme used for properties view //$NON-NLS-1$
+ String[] segments = uri.segments();
+ if (segments.length > 2) {
+ return segments[1];
+ }
+ }
+ return null;
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/GMFDiagramViewTypeHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/GMFDiagramViewTypeHelper.java
index a5e7cb15026..b93b36dc903 100755
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/GMFDiagramViewTypeHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/GMFDiagramViewTypeHelper.java
@@ -17,6 +17,7 @@
package org.eclipse.papyrus.infra.gmfdiag.common.helper;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
@@ -55,12 +56,12 @@ public class GMFDiagramViewTypeHelper extends AbstractViewTypeHelper<PapyrusDiag
protected ViewPrototype doGetPrototypeFor(PapyrusDiagram diagramKind) {
String commandClassName = diagramKind.getCreationCommandClass();
if (commandClassName != null) {
- Class<?> creationCommandClass = ClassLoaderHelper.loadClass(commandClassName);
+ Class<? extends AbstractPapyrusGmfCreateDiagramCommandHandler> creationCommandClass = ClassLoaderHelper.loadClass(commandClassName, AbstractPapyrusGmfCreateDiagramCommandHandler.class, EcoreUtil.getURI(diagramKind));
if (creationCommandClass != null) {
AbstractPapyrusGmfCreateDiagramCommandHandler command;
try {
- command = (AbstractPapyrusGmfCreateDiagramCommandHandler) creationCommandClass.newInstance();
+ command = creationCommandClass.newInstance();
} catch (Exception e) {
Activator.log.error(e);
return null;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteViewer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteViewer.java
index acaf88c6089..0b21791948c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteViewer.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/palette/PapyrusPaletteViewer.java
@@ -30,6 +30,7 @@ import org.eclipse.swt.widgets.Shell;
/**
* Extended Palette Viewer, to have a new customize dialog
+ *
* @since 3.0
*/
public class PapyrusPaletteViewer extends PaletteViewerEx {
@@ -53,7 +54,7 @@ public class PapyrusPaletteViewer extends PaletteViewerEx {
for (IConfigurationElement e : config) {
String customizerClassName = e.getAttribute(CUSTOMIZER_ATTRIBUTE);
try {
- Class<? extends PaletteCustomizerDialog> advancedCustomizerDialogClass = ClassLoaderHelper.loadClass(customizerClassName).asSubclass(PaletteCustomizerDialog.class);
+ Class<? extends PaletteCustomizerDialog> advancedCustomizerDialogClass = ClassLoaderHelper.loadClass(customizerClassName, PaletteCustomizerDialog.class, e.getContributor().getName());
if (advancedCustomizerDialogClass != null) {
Constructor<? extends PaletteCustomizerDialog> constructor = advancedCustomizerDialogClass.getConstructor(Shell.class, PaletteCustomizer.class, PaletteRoot.class);
if (constructor != null) {
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSourceFactory.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSourceFactory.java
index ecf3be98604..bf2223f7126 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSourceFactory.java
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSourceFactory.java
@@ -163,7 +163,7 @@ public class DataSourceFactory {
}
String factoryName = factoryDescriptor.getFactoryClass();
- ModelElementFactory factory = ClassLoaderHelper.newInstance(factoryName, ModelElementFactory.class);
+ ModelElementFactory factory = ClassLoaderHelper.newInstance(factoryName, ModelElementFactory.class, EcoreUtil.getURI(context));
return factory;
}
@@ -242,5 +242,5 @@ public class DataSourceFactory {
// TODO : More than one view can be displayed at the same time. The cache should only
// rely on a selection ; not on a selection-view pair.
// We may use a (ISelection, Context) key : the DataSource must be associated to a single context
- private Map<SelectionEntry, DataSource> sources = new HashMap<SelectionEntry, DataSource>();
+ private Map<SelectionEntry, DataSource> sources = new HashMap<>();
}
diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultAdviceBindingFactory.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultAdviceBindingFactory.java
index a933282ca9c..14465bd0522 100644
--- a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultAdviceBindingFactory.java
+++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultAdviceBindingFactory.java
@@ -15,6 +15,8 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.types.core.factories.impl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
import org.eclipse.papyrus.infra.types.AbstractAdviceBindingConfiguration;
@@ -28,7 +30,9 @@ public class DefaultAdviceBindingFactory extends AbstractAdviceBindingFactory<Ad
*/
@Override
protected IEditHelperAdvice getEditHelperAdvice(final AdviceBindingConfiguration adviceConfiguration) {
- IEditHelperAdvice editHelperAdvice = ClassLoaderHelper.newInstance(adviceConfiguration.getEditHelperAdviceClassName(), IEditHelperAdvice.class);
+ String className = adviceConfiguration.getEditHelperAdviceClassName();
+ URI uri = EcoreUtil.getURI(adviceConfiguration);
+ IEditHelperAdvice editHelperAdvice = ClassLoaderHelper.newInstance(className, IEditHelperAdvice.class, uri);
return editHelperAdvice;
}
diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultEditHelperAdviceFactory.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultEditHelperAdviceFactory.java
index c30fad2b0e2..1c61c78a131 100644
--- a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultEditHelperAdviceFactory.java
+++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultEditHelperAdviceFactory.java
@@ -14,6 +14,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.types.core.factories.impl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
import org.eclipse.papyrus.infra.types.EditHelperAdviceConfiguration;
@@ -21,7 +22,7 @@ import org.eclipse.papyrus.infra.types.EditHelperAdviceConfiguration;
public class DefaultEditHelperAdviceFactory extends AbstractEditHelperAdviceFactory<EditHelperAdviceConfiguration> {
/**
- *
+ *
* @see org.eclipse.papyrus.infra.types.core.factories.impl.AbstractAdviceFactory#getEditHelperAdvice(org.eclipse.papyrus.infra.types.AdviceConfiguration)
*
* @param adviceConfiguration
@@ -29,7 +30,7 @@ public class DefaultEditHelperAdviceFactory extends AbstractEditHelperAdviceFact
*/
@Override
protected IEditHelperAdvice getEditHelperAdvice(EditHelperAdviceConfiguration adviceConfiguration) {
- IEditHelperAdvice editHelperAdvice = ClassLoaderHelper.newInstance(adviceConfiguration.getEditHelperAdviceClassName(), IEditHelperAdvice.class);
+ IEditHelperAdvice editHelperAdvice = ClassLoaderHelper.newInstance(adviceConfiguration.getEditHelperAdviceClassName(), IEditHelperAdvice.class, EcoreUtil.getURI(adviceConfiguration));
return editHelperAdvice;
}
diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultMatcherFactory.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultMatcherFactory.java
index b865decb5e1..1844827be7a 100644
--- a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultMatcherFactory.java
+++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/DefaultMatcherFactory.java
@@ -14,6 +14,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.types.core.factories.impl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
import org.eclipse.papyrus.infra.types.MatcherConfiguration;
@@ -22,7 +23,7 @@ import org.eclipse.papyrus.infra.types.core.factories.IMatcherFactory;
public class DefaultMatcherFactory implements IMatcherFactory<MatcherConfiguration> {
/**
- *
+ *
* @see org.eclipse.papyrus.infra.types.core.factories.IMatcherFactory#createElementMatcher(org.eclipse.papyrus.infra.types.AbstractMatcherConfiguration)
*
* @param matcherConfiguration
@@ -31,7 +32,7 @@ public class DefaultMatcherFactory implements IMatcherFactory<MatcherConfigurati
@Override
public IElementMatcher createElementMatcher(MatcherConfiguration matcherConfiguration) {
String matcherClassName = matcherConfiguration.getMatcherClassName();
- IElementMatcher matcher = ClassLoaderHelper.newInstance(matcherClassName, IElementMatcher.class);
+ IElementMatcher matcher = ClassLoaderHelper.newInstance(matcherClassName, IElementMatcher.class, EcoreUtil.getURI(matcherConfiguration));
return matcher;
}
}
diff --git a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/MetamodelTypeFactory.java b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/MetamodelTypeFactory.java
index d56a43a48b3..e03ee3ce75e 100644
--- a/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/MetamodelTypeFactory.java
+++ b/plugins/infra/types/org.eclipse.papyrus.infra.types.core/src/org/eclipse/papyrus/infra/types/core/factories/impl/MetamodelTypeFactory.java
@@ -15,6 +15,7 @@
package org.eclipse.papyrus.infra.types.core.factories.impl;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelper;
import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
@@ -26,6 +27,7 @@ public class MetamodelTypeFactory extends AbstractElementTypeConfigurationFactor
/**
* {@inheritDoc}
*/
+ @Override
public IHintedType createElementType(MetamodelTypeConfiguration configuration) {
return new ConfiguredHintedMetamodelElementType(getID(configuration), getIconURL(configuration), getDisplayName(configuration), getEClass(configuration), createEditHelper(configuration), getSemanticHint(configuration), configuration);
}
@@ -39,7 +41,7 @@ public class MetamodelTypeFactory extends AbstractElementTypeConfigurationFactor
if (editHelperClassName == null) {
return null;
}
- IEditHelper editHelper = ClassLoaderHelper.newInstance(editHelperClassName, IEditHelper.class);
+ IEditHelper editHelper = ClassLoaderHelper.newInstance(editHelperClassName, IEditHelper.class, EcoreUtil.getURI(configuration));
return editHelper;
}
}

Back to the top