-
Notifications
You must be signed in to change notification settings - Fork 393
Description
Current annotation model works like:
@ShellComponentis needed to introduce wrapping class into context asBean.StandardMethodTargetRegistrarin a standard package queries@ShellComponentbeans from a context and scans@ShellMethodmethods and manually createsCommandRegistrationinstances and register those intoCommandCatalog.- As
@ShellComponentis a@Componentthis wrapping class is then available as an object instance to target command invocation via reflection.
Ultimate plan is to deprecate whole spring-shell-standard module and create a full modern annotation system replacement which aligns better with CommandRegistration system and its new features(some only available if registration is created as a bean) which cannot be used with old annotations.
We want to move away from all automatic ways what happens with @ShellComponent and align new annotation system with concepts from a modern boot/framework:
- Be more restrictive what comes for a classpath scanning.
- Allow to define command targets using modern annotation and class structure boot user are familiar with.
In no particular order new annotations could look like(draft of some ideas and more detailed in annotation specific issues):
- Reorganise e2e samples #642
- @CommandAvailability Annotation #663
- @Command Annotation #638
- @Option Annotation #639
- @EnableCommand Annotation #640
- @CommandScan Annotation #641
- Document feature
Command
@Command on a class level would be used to mark it as target for finding commands and on a method level marking it as target for command logic. Annotation on a class level would be used to provide some defaults for methods in that particular class.
Option
@Optionin a method parameter level to add metadata for command options.
EnableCommand
@EnableCommandannotation would be similar to boot's@ConfigurationPropertiesdefining class targets.- For example, use it as @EnableCommand({ MyCommands1.class, MyCommands2.class} )
CommandScan
@CommandScanannotation would be similar to boot's@ConfigurationPropertiesScandefining classpath scanning targets.- For example, use it as @CommandScan(basePackages = "org.example.commands")
ExitCode
@ExitCodein a method level with@ExceptionResolverwould instruct non-interactive command what to return in case of an error.