You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Marcel Offermans (JIRA)" <ji...@apache.org> on 2013/02/28 20:29:13 UTC

[jira] [Commented] (FELIX-3912) Support for static field injections and callback invocations

    [ https://issues.apache.org/jira/browse/FELIX-3912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13589834#comment-13589834 ] 

Marcel Offermans commented on FELIX-3912:
-----------------------------------------

Just to make sure, do you really need to use statics, or would a reusable (singleton) instance also work for you? If the latter is the case, setImplmentation does support you supplying an instance yourself: just pass it any Object that is not of the type Class and it will happily (re)use that one. So if you really just want to create an instance once, and reuse it over many tests, just keep passing that one to setInstance().
                
> Support for static field injections and callback invocations
> ------------------------------------------------------------
>
>                 Key: FELIX-3912
>                 URL: https://issues.apache.org/jira/browse/FELIX-3912
>             Project: Felix
>          Issue Type: Improvement
>          Components: Dependency Manager
>            Reporter: Tuomas Kiviaho
>
> I've got a case (JUnit tests) where static field injections and callback invocation would be more than welcome. I'm succesfully using DependencyManager in the same manner as Sonatype Sisu for my integration tests, but test execution times become quite high when using @TestRule instead of @ClassRule.
> The codebase seems to be crafted statics in mind since there are only handful of locations which prevent this. The biggest blocker is Component.setImplementation that would need an information preventing instantiation. The same information would be used to determine at callbacks and field injections whether to perform these or not.
> I guess that the most pain would come from annotation api where possibility of method overloading should be taken into account, but that could get static support later on. 
> I could provide a patch if this idea gets wind under it. Personally I dislike the idea of using statics anywhere else that within unit/integration tests.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira