X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringCommandHandler.java;h=9eb3a0df1e42247dd7ea9cc8c241d0cc13fb7c66;hb=1d5afdce3e91054f07ddd3c98309c363b4cf1d46;hp=0356f57d2e850acd5cbb9930dca51974cd43bd4c;hpb=92daeb190be66653f39544ae9b5a2f2c31a60797;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java index 0356f57d2..9eb3a0df1 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java +++ b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.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,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 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 +45,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 +72,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); }