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

Sisu adapter for jsr330 that is namespace independent #103

Open
cstamas opened this issue Dec 11, 2023 · 2 comments
Open

Sisu adapter for jsr330 that is namespace independent #103

cstamas opened this issue Dec 11, 2023 · 2 comments

Comments

@cstamas
Copy link
Member

cstamas commented Dec 11, 2023

Basically like plexus-shim, but for jsr330?

As this would allow us to move on with guice, possibly mix (or introduce own) jsr330-alike annotations?

@gnodet
Copy link
Contributor

gnodet commented Dec 12, 2023

Basically like plexus-shim, but for jsr330?

As this would allow us to move on with guice, possibly mix (or introduce own) jsr330-alike annotations?

See https://issues.apache.org/jira/browse/MNG-7954

If we could provide an adapter that could provide the following annotations in a org.apache.maven.api.di package, that would be awesome !

  • Inject
  • Named
  • Typed
  • PreDestroy
  • Priority
  • Singleton
    The following ones are optional imho, but good to have:
  • PostConstruct (not really necessary, as we're mostly using constructor injection)
  • EagerSingleton (maybe using a listener would do the trick)

I still think the problematic point will be to allow plugging in the maven SessionScoped and MojoExecutionScoped annotations which need to be annotated with a com.google.inject.ScopeAnnotation or a javax.inject.Scope annotation, see https://github.com/google/guice/blob/master/core/src/com/google/inject/internal/Annotations.java#L352-L354

@rmannibucau
Copy link

guess for the scope the thing can be to

  1. generate at build time a proxy (delegating subclass) - indeed you can replace it by run time at the cost of dependencies (still think we should be able to get rid of most of them but this point is not key for this issue)
  2. at runtime use the proxy passing a delegator which "reads" at invoke time the right instance in the session (from the TL and in attributes potentially)

means the bound bean is a singleton for the IoC but handles the @SessionScoped of maven properly, this sounds like less work than integrating more deeply with guice or sisu which is probably not desired for maven so ultimately I'd say that we only need

  • Inject
  • Singleton

Named, priority can easily be replaced by methods in beans since it is not really a JSR330 feature (behavior is undefined) so it is bad to fake it is a "feature".

Typed can easily be replaced by a delegating bean which downcast types (delegating pattern).

Lifecycle+eager can be replaced by lifecycle listeners we have in maven.

So overall only inject is really required in sisu from my window, rest is nice to have but not a requirement probably.

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

3 participants