i really like this addition ;
i defined a control bus along with a gateway to link it with the command :
Code:<context:annotation-config/> <int:channel id="request-command"/> <int:channel id="respons-command"/> <int:gateway default-request-channel="request-command" default-reply-channel="respons-command" service-interface="wims.tijd.shell.ControlBusGateway" /> <int:control-bus input-channel="request-command" output-channel="respons-command"/> <bean class="wims.tijd.shell.ControlBusCommand"/>Code:public interface ControlBusGateway { @Gateway Object send(String command); }Code:@Component public class ControlBusCommand implements CommandMarker, ApplicationContextAware { @Inject ControlBusGateway cbg; ApplicationContext applicationContext; @CliCommand(value = "controlbus", help = "Print a simple hello world message") public String send( @CliOption(key = { "identifier" }, mandatory = true, help = "Beanname") final String identifier, @CliOption(key = { "operation" }, mandatory = true, help = "Method") final String operation){ Object returned = cbg.send("@'"+identifier+"'."+operation); if(returned == null){ return "command exucted."; }else{ return returned.toString(); } } @CliCommand(value = "listBeans", help = "Print a simple hello world message") public String listBeans(){ StringBuilder sb = new StringBuilder(this.applicationContext.getDisplayName()).append("\n"); for(String name : this.applicationContext.getBeanDefinitionNames()){ sb.append(name).append("=").append(this.applicationContext.getBean(name).getClass()).append("\n"); } return sb.toString(); } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }Code:spring-shell>controlbus --identifier errorChannel --operation componentType publish-subscribe-channel spring-shell>


Reply With Quote