[ 
https://issues.apache.org/jira/browse/CAMEL-27232?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reassigned CAMEL-27232:
-----------------------------------

    Fix Version/s: 4.24.0
                       (was: 4.25.0)
         Assignee: Claus Ibsen

> camel-jbang - generated aesh metadata for the CLI commands (aesh-processor)
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-27232
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27232
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> The Camel CLI commands are read by aesh at run time from their annotations 
> (@CommandDefinition, @Option). The aesh annotation processor (aesh-processor) 
> generates the metadata at compile time instead, which avoids the annotation 
> proxy classes the JDK generates at run time.
> A prototype on top of CAMEL-27230 (aesh 3.19.2 + 
> MetadataProviderRegistry.useOnly) gave, median of 15 runs of the launcher:
> || Command || CAMEL-27230 || with generated metadata ||
> | camel version | 87 ms | 71 ms |
> | camel ps | 92 ms | 79 ms |
> | camel get route | 121 ms | 108 ms |
> | camel get --help | 125 ms | 97 ms |
> | camel --help | 243 ms | 210 ms |
> The help and parse golden files of camel-jbang-core are unchanged with the 
> generated metadata.
> h3. Plan (decided)
> The processor requires a no-arg constructor on each command. The commands get 
> one, and the CamelJBangMain is set after creation; the current constructor 
> CamelCommand(CamelJBangMain) and the 189 constructors that only call 
> super(main) are removed (no two constructors side by side). With that, the 
> released aesh-processor 3.19.2 works as is, and this does not wait for aesh.
> * CamelCommand: non-final main field, a no-arg constructor and 
> setCamelMain(CamelJBangMain); getMain() throws IllegalStateException when the 
> main was not set. Checked: no field initializer and no constructor uses the 
> main (184 of 189 constructors are only super(main), the other 5 do not need 
> it).
> * Call sites: CommandTree.lazy(() -> new X(this)) in CamelJBangMain (about 
> 159) - CommandTree can set the main in one place; commands that create other 
> commands (about 57, such as new Run(getMain()), also anonymous subclasses) 
> set it after new.
> * Plugins in Camel (tui, kubernetes, generate, validate, edit, mcp, test) and 
> the launcher (SelfUpdateCommand) move along.
> * camel-jbang-core: aesh-processor in the compiler annotation processor paths 
> (proc none for test compilation: @CommandDefinition is @Inherited, and 
> private nested test subclasses cannot be reached by the generated code), the 
> generated registry in MetadataProviderRegistry.useOnly, and CommandTree takes 
> the command name and aliases from the generated metadata instead of reading 
> @CommandDefinition.
> * Mixins: the package-private option fields of DurationMixin, 
> MavenResolverMixin, QuarkusPlatformMixin and QuarkusExtensionRegistryMixin 
> are used from other packages, and UpdateRun has a private @Mixin field: make 
> them reachable for the generated code (see 
> https://github.com/aeshell/aesh/issues/785, points 2 and 3, for the aesh 
> side).
> * Make the 23 private option fields package-private, so the generated code 
> does not need reflection for them.
> * Upgrade guide 4.25: third-party plugins whose commands extend CamelCommand 
> must use the no-arg constructor (the main is set by the CLI).
> * Later: the processor for the plugins with commands too.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to