Add support for bean configurations #1520
Comments
Our bean injection is really simple and therefore not flexible. There are already several requests to enhance this. And even there is an implementation with a provider pattern. Please search the existing issues. |
Sounds like an interesting idea. Maybe this could be more intelligent by looking at all available configuration classes for This could be a powerfull Feature. @WonderCsabo @yDelouis what do you think? |
I agree we should provide a way to configure the injection. It would be very useful for testing.
|
|
To be honest, i do not like extending our beans too much. The current bean architecture only allows very-very limited configuration. Implementing proper dependency injection with all the fancy things is really not trivial, and i am not sure we have to do that. A jack of all trades would be nice integration with Dagger for instance. BTW, we already have an implementation which allows specifying how to create the injected beans. Maybe we can use it. |
@WonderCsabo i can understand your concerns, but actually i think this feature would be awesome. i have at least one case where this would be usefull for my app that i develop in my freetime and both app in my company have a "BeanFactory" also i think that this should be relativly simple to imlement. |
On this issue, @dodgex sees the same benefits mentioned on #2200 , though simply "processing @EConfiguration classes first and keep the info about the available/provided beans" would mean to have to store this information somewhere else (since if kept on memory, and incremental processing takes place, there is no guarantee that the @WonderCsabo , @dodgex having a ".androidannotations" folder holding this kind of information could be definitely a solution to this issue. I know it adds complexity, but it permits to implement advanced features, including injection of interfaces without any further configuration (which is simply a "powerful" feature, and relies just on the "ability" of AA to record annotated classes). It would permit to keep track of all the The process for the generation of a ".androidannoitations" folder which could contain an androidannotations.xml holding this information probably should be something like:
BTW, I do know that libs like Dagger could handle this part, but I don't see that value in "forcing" AA users to use Dagger, for something that is in fact no that complex to add to AA. |
@smaugho please remember that AA is not only wants to support incremental compilation, but also is highly modularized and support plugins. Introducing some holder file which tries to retain information can only be implemented in the core processor, and somehow should be passed down to handlers. I still think implementing it would add too much complexity, and would be error prone. |
@WonderCsabo , so for having this functionality on AA, then you're recommendation is instead go with Dagger? Maybe we should build a plugin for AA and Dagger, which in fact simplifies the usage of Dagger (which is complicated for many people). But even for doing that, we'll need some mechanism to know the existing BTW, if plugins would be able to add behaviors to existing annotations, that would be really good for this kind of plugins, or at least be notify of other annotations.. For instance, a Dagger plugin, could automatically create a module for all the Beans on the system, and initialize a component for injections in the @eApplication (or each activity if it doesn't exist). For doing so, it should be notified at least of annotations like @ebean or @EActivity... but right now if we try to do this in a plugin, it doesn't work at all.. since only one handler for the same annotation is selected (I think). |
Iny my project, i use AAs Yes, only one handler is used for an annotation. Changing this would cause problems, for example which is the order for the handlers to process the same thing, etc. |
For multiple handles, we could simply make a light version. It could work "aggregating" info. Let's see, right now to make this in AA we simply "force" the user to add another annotation. So if I have a Plugin A and Plugin B, which adds annotations to enrich @PluginAAnnotation
@PluginBAnnotation
@EBean
public void SomeBeanEnrichedWithPlugins {
} So far, there isn't any control to determine in which order others plugins will "aggregate" their information. So what I'm saying (for aggregation), it is to simplify that, plugin devs don't need to create an extra annotation (and users don't have to learn a new one). They simply add another Handler for So, if somebody builds a Dagger plugin, which should recollect all the So I'm not sure if the order in which the handlers is called changes this fact, since right now it doesn't care about it neither when adding multiple annotations. |
|
In my opinion we shoud reduce complexity of the project instead of increasing it even more. Our Processors are not built to be extensible by plugins. I think that even the plugin system itself is not the best solution. It works but i think it should have be done diffrent. But again, that would have required even more refactoring as the plugin system in its current form took. |
Sometimes there is a need to inject objects, which are from outside current project. In this case no clean solution is available now. I think about Configuration classes with @EConfiguration. Those classes will be singletons only. To distinguish how to inject Bean, new field configuration could be added to @bean.
The text was updated successfully, but these errors were encountered: