From: Mathieu Baudier Date: Tue, 11 Jan 2011 21:45:04 +0000 (+0000) Subject: Improve error reporting in eclipse ui X-Git-Tag: argeo-commons-2.1.30~1543 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=6c587214d5c68fba28a3fbc0bf258c5e7c470aa1;p=lgpl%2Fargeo-commons.git Improve error reporting in eclipse ui git-svn-id: https://svn.argeo.org/commons/trunk@4006 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/plugins/org.argeo.eclipse.ui/pom.xml b/eclipse/plugins/org.argeo.eclipse.ui/pom.xml index 3b8f94c37..460702ee1 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/pom.xml +++ b/eclipse/plugins/org.argeo.eclipse.ui/pom.xml @@ -47,6 +47,13 @@ + + + org.argeo.commons.basic + org.argeo.basic.nodeps + 0.2.2-SNAPSHOT + + org.eclipse.ui @@ -111,6 +118,7 @@ org.springframework org.springframework.context + org.slf4j diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java index 92a3fed13..49a226d39 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java +++ b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java @@ -16,6 +16,7 @@ package org.argeo.eclipse.spring; +import org.argeo.ArgeoException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; @@ -41,7 +42,8 @@ import org.springframework.context.ApplicationContext; * spring extension factory uses the id of the extension itself to identify the * bean. * - * original code from: Blog entry * * @author Martin Lippert @@ -53,21 +55,30 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory, private Object bean; public Object create() throws CoreException { + if (bean == null) + throw new ArgeoException("No underlying bean for extension"); return bean; } public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { String beanName = getBeanName(data, config); + if (beanName == null) + throw new ArgeoException("Cannot find bean name for extension " + + config); + + String bundleSymbolicName = config.getContributor().getName(); ApplicationContext appContext = ApplicationContextTracker - .getApplicationContext(config.getContributor().getName()); + .getApplicationContext(bundleSymbolicName); + if (appContext == null) + throw new ArgeoException( + "Cannot find application context for bundle " + + bundleSymbolicName); - if (beanName != null && appContext != null) { - this.bean = appContext.getBean(beanName); - if (this.bean instanceof IExecutableExtension) { - ((IExecutableExtension) this.bean).setInitializationData( - config, propertyName, data); - } + this.bean = appContext.getBean(beanName); + if (this.bean instanceof IExecutableExtension) { + ((IExecutableExtension) this.bean).setInitializationData(config, + propertyName, data); } }