Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Annotation Model #637

Closed
7 tasks done
jvalkeal opened this issue Jan 25, 2023 · 1 comment
Closed
7 tasks done

New Annotation Model #637

jvalkeal opened this issue Jan 25, 2023 · 1 comment
Assignees
Milestone

Comments

@jvalkeal
Copy link
Contributor

jvalkeal commented Jan 25, 2023

Current annotation model works like:

  • @ShellComponent is needed to introduce wrapping class into context as Bean.
  • StandardMethodTargetRegistrar in a standard package queries @ShellComponent beans from a context and scans @ShellMethod methods and manually creates CommandRegistration instances and register those into CommandCatalog.
  • As @ShellComponent is a @Component this 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):

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

  • @Option in a method parameter level to add metadata for command options.

EnableCommand

  • @EnableCommand annotation would be similar to boot's @ConfigurationProperties defining class targets.
  • For example, use it as @EnableCommand({ MyCommands1.class, MyCommands2.class} )

CommandScan

  • @CommandScan annotation would be similar to boot's @ConfigurationPropertiesScan defining classpath scanning targets.
  • For example, use it as @CommandScan(basePackages = "org.example.commands")

ExitCode

  • @ExitCode in a method level with @ExceptionResolver would instruct non-interactive command what to return in case of an error.
@jvalkeal jvalkeal modified the milestone: 3.1.0-M1 Jan 25, 2023
jvalkeal added a commit to jvalkeal/spring-shell that referenced this issue Jan 27, 2023
- This is a first commit to add new annotation model
  which eventually will replace old legacy annotations
  like ShellComponent, ShellMethod, @ShellOption, etc.
- Adds subset of features needed for parity with manual
  use of CommandRegistration.
- Relates spring-projects#637
- Relates spring-projects#638
- Relates spring-projects#639
- Relates spring-projects#640
- Relates spring-projects#641
@jvalkeal jvalkeal self-assigned this Jan 29, 2023
jvalkeal added a commit that referenced this issue Feb 24, 2023
- Split and separate new annotations with legacy annotations
  on a registration level.
- Relates #637
@jvalkeal jvalkeal modified the milestones: 3.1.0-M1, 3.1.0-M2 Feb 24, 2023
jvalkeal added a commit that referenced this issue Feb 24, 2023
jvalkeal added a commit to jvalkeal/spring-shell that referenced this issue Mar 5, 2023
- Change ref field in OptionValues to providers
  takin an array.
- Relates spring-projects#637
jvalkeal added a commit that referenced this issue Mar 18, 2023
@jvalkeal jvalkeal modified the milestones: 3.1.0-M2, 3.1.0-RC1 Apr 7, 2023
jvalkeal added a commit that referenced this issue Apr 7, 2023
- Document better a relationship between annotation,
  legacy annotation and programmatic registration.
- Relates #637
jvalkeal added a commit that referenced this issue Apr 8, 2023
jvalkeal added a commit that referenced this issue Apr 10, 2023
- Add e2e samples
- Add short option snippets as tabs content(to get later
  converted to an actual tabs).
- Relates #637
jvalkeal added a commit that referenced this issue May 1, 2023
- Use tabbing model from a new docs backend.
- Relates #637
jvalkeal added a commit that referenced this issue May 1, 2023
@jvalkeal
Copy link
Contributor Author

jvalkeal commented May 1, 2023

Marking closed and expecting further issue in a separate tickes.

@jvalkeal jvalkeal closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant