Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Faltermeier2014-10-15 06:55:24 -0400
committerJohannes Faltermeier2014-10-24 04:20:13 -0400
commit29768ed3e07c40aa6fef02dd0ef08f3a96f9db5e (patch)
tree31c5f4310d606b1488dac5d70ea625a656b1c376
parent757843680706845535ba7c6e3f32b0673c8db0e5 (diff)
downloadorg.eclipse.emf.edapt-29768ed3e07c40aa6fef02dd0ef08f3a96f9db5e.tar.gz
org.eclipse.emf.edapt-29768ed3e07c40aa6fef02dd0ef08f3a96f9db5e.tar.xz
org.eclipse.emf.edapt-29768ed3e07c40aa6fef02dd0ef08f3a96f9db5e.zip
[436252] Edapt cannot resolve package Factories generated by EMF
* JavaDocs, logging
-rw-r--r--plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/FactoryHelper.java57
1 files changed, 37 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/FactoryHelper.java b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/FactoryHelper.java
index 0f83958..16a884a 100644
--- a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/FactoryHelper.java
+++ b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/FactoryHelper.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 BMW Car IT, Technische Universitaet Muenchen, 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:
+ * Johannes Faltermeier - Initial API and implementation
+ *******************************************************************************/
package org.eclipse.emf.edapt.internal.migration;
import java.lang.reflect.InvocationTargetException;
@@ -9,16 +19,26 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.edapt.spi.migration.MigrationPlugin;
import org.osgi.framework.Bundle;
+/**
+ * Helper class for reading custom {@link EFactory EFactories} from the extension point.
+ *
+ * @author jfaltermeier
+ *
+ */
public final class FactoryHelper {
+
+ /**
+ * The instance.
+ */
+ public static final FactoryHelper INSTANCE = new FactoryHelper();
private static final String CLASS = "class";
private static final String NS_URI = "nsURI";
private static final String POINT_ID = "org.eclipse.emf.edapt.factories";
- public static final FactoryHelper INSTANCE = new FactoryHelper();
-
private Map<String, Class<? extends EFactory>> nsURIToFactoryMap;
private FactoryHelper() {
@@ -31,7 +51,6 @@ public final class FactoryHelper {
.getExtensionRegistry();
final IConfigurationElement[] configurationElements = extensionRegistry
.getConfigurationElementsFor(POINT_ID);
-
for (final IConfigurationElement configurationElement : configurationElements) {
registerFactory(configurationElement);
}
@@ -44,12 +63,11 @@ public final class FactoryHelper {
String className = configurationElement.getAttribute(CLASS);
Class<? extends EFactory> clazz = loadClass(bundle, className);
if (nsURI == null || clazz == null) {
- // TODO log?
+ return;
}
nsURIToFactoryMap.put(nsURI, clazz);
} catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
}
}
@@ -59,12 +77,17 @@ public final class FactoryHelper {
String clazz) throws ClassNotFoundException {
final Bundle bundle = Platform.getBundle(bundleName);
if (bundle == null) {
- // TODO log
+ MigrationPlugin.INSTANCE.log("Could not get bundle " + bundleName + " from platform.");
}
return (Class<? extends EFactory>) bundle.loadClass(clazz);
-
}
+ /**
+ * Overrides the {@link EFactory} for the given {@link EPackage} if a custom EFactory
+ * was registered for the factory's nsURI.
+ *
+ * @param ePackage the package
+ */
public void overrideFactory(EPackage ePackage) {
try {
if (!nsURIToFactoryMap.containsKey(ePackage.getNsURI())) {
@@ -75,23 +98,17 @@ public final class FactoryHelper {
EFactory eFactory = clazz.getConstructor().newInstance();
ePackage.setEFactoryInstance(eFactory);
} catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
} catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
} catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
} catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
} catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
} catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ MigrationPlugin.INSTANCE.log(e);
}
}
}

Back to the top