]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java
Introduce OSGi Explorer
[lgpl/argeo-commons.git] / eclipse / runtime / org.argeo.eclipse.ui / src / main / java / org / argeo / eclipse / spring / SpringCommandHandler.java
index 0356f57d2e850acd5cbb9930dca51974cd43bd4c..ebabae1308e0b44de059adc31f482c6fe7bde516 100644 (file)
@@ -18,6 +18,7 @@ package org.argeo.eclipse.spring;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.IHandler;
@@ -45,9 +46,19 @@ public class SpringCommandHandler implements IHandler {
                        // TODO: make it more flexible and robust
                        ApplicationContext applicationContext = ApplicationContextTracker
                                        .getApplicationContext(bundleSymbolicName);
+                       if (applicationContext == null)
+                               throw new ArgeoException("No application context found for "
+                                               + bundleSymbolicName);
 
                        // retrieve the command via its id
                        String beanName = event.getCommand().getId();
+
+                       if (!applicationContext.containsBean(beanName)) {
+                               if (beanName.startsWith(bundleSymbolicName))
+                                       beanName = beanName
+                                                       .substring(bundleSymbolicName.length() + 1);
+                       }
+
                        if (!applicationContext.containsBean(beanName))
                                throw new ExecutionException("No bean found with name "
                                                + beanName + " in bundle " + bundleSymbolicName);
@@ -62,7 +73,7 @@ public class SpringCommandHandler implements IHandler {
                        return handler.execute(event);
                } catch (Exception e) {
                        // TODO: use eclipse error management
-//                     log.error(e);
+                       // log.error(e);
                        throw new ExecutionException("Cannot execute Spring command "
                                        + commandId + " in bundle " + bundleSymbolicName, e);
                }