-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support Generic Auto Provides/Requires #498
Conversation
Did somebody hit a limitation here / was there a requirement for this? The autoProvides is for wiring across modules. I tend to believe that cross-module dependencies should be interfaces and I tend to think they shouldn't use generic types. Has someone hit an issue here? |
Is it so inconceivable that a module would provide generic types? I've got a mongo common library that handles authentication and provides some common |
Factory beans that return |
That sounds like a concrete class being used across a module boundary - so yeah I'm really surprised as that sounds like relatively tight coupling between modules. Can you share an example? [so that I can get a sense of the coupling, I'm also wondering if this is changing with the java module system in terms of tight coupling] Noting that this is a breaking change - it would need a bump to the major version. |
Surprisingly, it doesn't break anything except the plugins. |
an example of wrapping? @Singleton
public record WrapperClass(Map<String, String> map){} Then you can inject WrapperClass into a bean in some module B. |
I meant a real world example - as in, we are using tight coupling between 2 modules with a concrete class (and not an interface). What is real world example where this is a good idea (versus a bad idea because that is tight coupling between modules that uses an implementation - a non-abstract implementation class to coupling 2 modules together ... and I'm going "Really??"). |
I don't follow, the point of this PR is that we can avoid concrete wrapper classes and use the generic interface/super classes directly |
I did think of an example though. Some time ago I was helping out a guy on discord with avaje and he was quite confused about the current behavior, he had a common library that would configure a Jackson The problem was that ObjectMapper is auto provided as public final class ModuleClass implements Module {
// ...rest of the module class
@Override
public Class<?>[] autoProvides() {
return autoProvides;
}
private static final Class<?>[] autoProvides = {
Versioned.class,
}; so naturally his compilation would fail. I ended up telling him he had to manually use Honestly, any sort of avaje-based configuration library that configures third-party classes would appreciate #501 |
d48cd94
to
e6ee3d4
Compare
Module
interface to useType[]
instead ofClass<?>[]
GenericType
Type[]
instead ofClass<?>[]
Now we can have a generic (factory) bean in Module A:
The generated Avaje Module class will have:
and in Module B we can reference via: