dimanche 20 janvier 2019

Parameter resolving /converter for dynamically registered commands

I am working on a Spring Shell 2 CLI and i am trying to generate commands at runtime from a defined interface through reflection.
I am using the ConfigurableCommandRegistry and MethodTarget to register my command.
Is there a way to setup/register converters at runtime for the parameters of the method that is passed to MethodTarget?
What would be the best approach to do this?

I am pretty new to java and spring and i am not sure if this is possible at all. Keep that in mind and pls dont kill me :)
The Extending Spring Shell of the docs is missing (incomplete?)
I already checked the Spring shell project but could not find something to work with.
Maybe this is possible with Parameter Resolving? or generating Converters at runtime with FormatterRegistrar?

Registering commands as followed

MethodTarget command = new MethodTarget(method, client, new Command.Help(description, group), availabilityIndicator);
registry.register(commandName, command);

method and method paramters, client, description, group is retrieved via reflection from the interface.

I would like to generate a command at runtime from an interface


public interface MessagingManagement {
  @ShellMethod(...)
  public void createPerson(@ShellOption(...)Person person);
}

which is callable with following parameters create-person --person name age (or more paramters)

In short i would like to generate converters for paramaters that are complex objects and flatten them.
Nested objects are ignored





Aucun commentaire:

Enregistrer un commentaire