X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringExtensionFactory.java;h=aa0295d56a80fd3e18a8fb1ea0d9af8f244c4f27;hb=6dafb9a0b459e1a7f6418fd01123a8e08a04b617;hp=49a226d39339bf15d5a7dffb3884f79709896897;hpb=92daeb190be66653f39544ae9b5a2f2c31a60797;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java index 49a226d39..aa0295d56 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java +++ b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java @@ -62,20 +62,28 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory, 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 + ApplicationContext applicationContext = ApplicationContextTracker .getApplicationContext(bundleSymbolicName); - if (appContext == null) + if (applicationContext == null) throw new ArgeoException( "Cannot find application context for bundle " + bundleSymbolicName); - this.bean = appContext.getBean(beanName); + String beanName = getBeanName(data, config); + if (beanName == null) + throw new ArgeoException("Cannot find bean name for extension " + + config); + + if (!applicationContext.containsBean(beanName)) { + if (beanName.startsWith(bundleSymbolicName)) + beanName = beanName.substring(bundleSymbolicName.length() + 1); + } + + if (!applicationContext.containsBean(beanName)) + throw new ArgeoException("No bean with name '" + beanName + "'"); + + this.bean = applicationContext.getBean(beanName); if (this.bean instanceof IExecutableExtension) { ((IExecutableExtension) this.bean).setInitializationData(config, propertyName, data);