]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java
Update license headers
[lgpl/argeo-commons.git] / eclipse / runtime / org.argeo.eclipse.ui / src / main / java / org / argeo / eclipse / spring / SpringExtensionFactory.java
index f20e1d1249f70c8e3a73fddaee6226ac9ee0e95d..d8ec9d77a0f317c05ed3fa0d8466c1ddc05ff83b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ * Copyright (C) 2007-2012 Mathieu Baudier\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
  */\r
-\r
 package org.argeo.eclipse.spring;\r
 \r
 import org.argeo.ArgeoException;\r
@@ -63,9 +62,9 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory,
        public void setInitializationData(IConfigurationElement config,\r
                        String propertyName, Object data) throws CoreException {\r
                String bundleSymbolicName = config.getContributor().getName();\r
-               ApplicationContext appContext = ApplicationContextTracker\r
+               ApplicationContext applicationContext = ApplicationContextTracker\r
                                .getApplicationContext(bundleSymbolicName);\r
-               if (appContext == null)\r
+               if (applicationContext == null)\r
                        throw new ArgeoException(\r
                                        "Cannot find application context for bundle "\r
                                                        + bundleSymbolicName);\r
@@ -75,7 +74,15 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory,
                        throw new ArgeoException("Cannot find bean name for extension "\r
                                        + config);\r
 \r
-               this.bean = appContext.getBean(beanName);\r
+               if (!applicationContext.containsBean(beanName)) {\r
+                       if (beanName.startsWith(bundleSymbolicName))\r
+                               beanName = beanName.substring(bundleSymbolicName.length() + 1);\r
+               }\r
+\r
+               if (!applicationContext.containsBean(beanName))\r
+                       throw new ArgeoException("No bean with name '" + beanName + "'");\r
+\r
+               this.bean = applicationContext.getBean(beanName);\r
                if (this.bean instanceof IExecutableExtension) {\r
                        ((IExecutableExtension) this.bean).setInitializationData(config,\r
                                        propertyName, data);\r