Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.room')
-rw-r--r--plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java19
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java24
3 files changed, 19 insertions, 25 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
index d3b25bc6f..7c73ad2d9 100644
--- a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
@@ -39,4 +39,3 @@ Export-Package: org.eclipse.etrice.core,
org.eclipse.etrice.core.serializer,
org.eclipse.etrice.core.services,
org.eclipse.etrice.core.validation
-Bundle-Activator: org.eclipse.etrice.core.RoomActivator
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java
deleted file mode 100644
index 6144705cf..000000000
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.eclipse.etrice.core;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.etrice.core.validation.ValidatorExtensionManager;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class RoomActivator extends Plugin implements BundleActivator {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- ValidatorExtensionManager.Registry.getInstance().loadValidatorExtensions();
- }
-}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
index aa2d33069..074ad5034 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
@@ -21,7 +21,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.EMFPlugin;
@@ -37,6 +36,10 @@ import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.CheckType;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+import org.osgi.framework.Bundle;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
/**
* Custom validator manager for room language, that provides registration via an
@@ -97,7 +100,7 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
&& Platform.getExtensionRegistry().getExtensionPoint(IVALIDATOR_ID) != null;
}
- public void loadValidatorExtensions() {
+ public void loadValidatorExtensions(Injector injector) {
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(IVALIDATOR_ID);
// we use parent-package.class-name as key in our tables
@@ -120,7 +123,11 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
// now we add each extension to our maps
for (IConfigurationElement e : config) {
try {
- final Object ext = e.createExecutableExtension("class");
+ final String extContributor = e.getContributor().getName();
+ final Bundle extBundle = Platform.getBundle(extContributor);
+ final String extClassName = e.getAttribute("class");
+ final Class<?> extClass = extBundle.loadClass(extClassName);
+ final Object ext = injector.getInstance(extClass);
if (ext instanceof ICustomValidator) {
ICustomValidator validator = (ICustomValidator) ext;
infos.add(new ValidatorInfo(validator, e.getName() + ValidatorInfo.SEP
@@ -148,8 +155,8 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
System.out.println("ValidatorExtensionManager: unexpected extension");
}
}
- catch (CoreException ex) {
- System.out.println(ex.getMessage());
+ catch (ClassNotFoundException ex) {
+ System.out.println(ex.toString());
}
}
}
@@ -255,6 +262,13 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
isRegistryAvailable = Registry.isAvailable();
}
+ @Inject
+ public void registerExtensionValidators(Injector injector) {
+ if(isRegistryAvailable) {
+ Registry.getInstance().loadValidatorExtensions(injector);
+ }
+ }
+
@Check
public void checkObject(EObject object) {
if (isRegistryAvailable) {

Back to the top