X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringExtensionFactory.java;h=d8ec9d77a0f317c05ed3fa0d8466c1ddc05ff83b;hb=1d5afdce3e91054f07ddd3c98309c363b4cf1d46;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..d8ec9d77a 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Mathieu Baudier + * Copyright (C) 2007-2012 Mathieu Baudier * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.argeo.eclipse.spring; import org.argeo.ArgeoException; @@ -62,20 +61,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);