/*\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
* 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
\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
+ 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
\r
- this.bean = appContext.getBean(beanName);\r
+ String beanName = getBeanName(data, config);\r
+ if (beanName == null)\r
+ throw new ArgeoException("Cannot find bean name for extension "\r
+ + config);\r
+\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