Improve error reporting in eclipse ui
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 11 Jan 2011 21:45:04 +0000 (21:45 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 11 Jan 2011 21:45:04 +0000 (21:45 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4006 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

eclipse/plugins/org.argeo.eclipse.ui/pom.xml
eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java

index 3b8f94c3701d9a95fc02823d2c5cd5dc53959484..460702ee10a404dcb1a28497448a755595a76649 100644 (file)
                </plugins>
        </build>
        <dependencies>
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons.basic</groupId>
+                       <artifactId>org.argeo.basic.nodeps</artifactId>
+                       <version>0.2.2-SNAPSHOT</version>
+               </dependency>
+
                <!-- Eclipse -->
                <dependency>
                        <groupId>org.eclipse.ui</groupId>
                        <groupId>org.springframework</groupId>
                        <artifactId>org.springframework.context</artifactId>
                </dependency>
+               
                <!-- Others -->
                <dependency>
                        <groupId>org.slf4j</groupId>
index 92a3fed1375c04901d384514eb1b6df58c209608..49a226d39339bf15d5a7dffb3884f79709896897 100644 (file)
@@ -16,6 +16,7 @@
 \r
 package org.argeo.eclipse.spring;\r
 \r
+import org.argeo.ArgeoException;\r
 import org.eclipse.core.runtime.CoreException;\r
 import org.eclipse.core.runtime.IConfigurationElement;\r
 import org.eclipse.core.runtime.IExecutableExtension;\r
@@ -41,7 +42,8 @@ import org.springframework.context.ApplicationContext;
  * spring extension factory uses the id of the extension itself to identify the\r
  * bean.\r
  * \r
- * original code from: <a href="http://martinlippert.blogspot.com/2008/10/new-version-of-spring-extension-factory.html"\r
+ * original code from: <a href=\r
+ * "http://martinlippert.blogspot.com/2008/10/new-version-of-spring-extension-factory.html"\r
  * >Blog entry</a>\r
  * \r
  * @author Martin Lippert\r
@@ -53,21 +55,30 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory,
        private Object bean;\r
 \r
        public Object create() throws CoreException {\r
+               if (bean == null)\r
+                       throw new ArgeoException("No underlying bean for extension");\r
                return bean;\r
        }\r
 \r
        public void setInitializationData(IConfigurationElement config,\r
                        String propertyName, Object data) throws CoreException {\r
                String beanName = getBeanName(data, config);\r
+               if (beanName == null)\r
+                       throw new ArgeoException("Cannot find bean name for extension "\r
+                                       + config);\r
+\r
+               String bundleSymbolicName = config.getContributor().getName();\r
                ApplicationContext appContext = ApplicationContextTracker\r
-                               .getApplicationContext(config.getContributor().getName());\r
+                               .getApplicationContext(bundleSymbolicName);\r
+               if (appContext == null)\r
+                       throw new ArgeoException(\r
+                                       "Cannot find application context for bundle "\r
+                                                       + bundleSymbolicName);\r
 \r
-               if (beanName != null && appContext != null) {\r
-                       this.bean = appContext.getBean(beanName);\r
-                       if (this.bean instanceof IExecutableExtension) {\r
-                               ((IExecutableExtension) this.bean).setInitializationData(\r
-                                               config, propertyName, data);\r
-                       }\r
+               this.bean = appContext.getBean(beanName);\r
+               if (this.bean instanceof IExecutableExtension) {\r
+                       ((IExecutableExtension) this.bean).setInitializationData(config,\r
+                                       propertyName, data);\r
                }\r
        }\r
 \r