X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fplugins%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringExtensionFactory.java;fp=eclipse%2Fplugins%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringExtensionFactory.java;h=49a226d39339bf15d5a7dffb3884f79709896897;hb=6c587214d5c68fba28a3fbc0bf258c5e7c470aa1;hp=92a3fed1375c04901d384514eb1b6df58c209608;hpb=24d5030a47ec501bb77ec601bc1b9bd7f4a3da1d;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java index 92a3fed13..49a226d39 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java +++ b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringExtensionFactory.java @@ -16,6 +16,7 @@ package org.argeo.eclipse.spring; +import org.argeo.ArgeoException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; @@ -41,7 +42,8 @@ import org.springframework.context.ApplicationContext; * spring extension factory uses the id of the extension itself to identify the * bean. * - * original code from: Blog entry * * @author Martin Lippert @@ -53,21 +55,30 @@ public class SpringExtensionFactory implements IExecutableExtensionFactory, private Object bean; public Object create() throws CoreException { + if (bean == null) + throw new ArgeoException("No underlying bean for extension"); return bean; } 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 - .getApplicationContext(config.getContributor().getName()); + .getApplicationContext(bundleSymbolicName); + if (appContext == null) + throw new ArgeoException( + "Cannot find application context for bundle " + + bundleSymbolicName); - if (beanName != null && appContext != null) { - this.bean = appContext.getBean(beanName); - if (this.bean instanceof IExecutableExtension) { - ((IExecutableExtension) this.bean).setInitializationData( - config, propertyName, data); - } + this.bean = appContext.getBean(beanName); + if (this.bean instanceof IExecutableExtension) { + ((IExecutableExtension) this.bean).setInitializationData(config, + propertyName, data); } }