Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9835

Detect beans when @Inject is present

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: Waiting for Triage
    • Component/s: Core:DI
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I recently had a look at a new Dependency Injection framework called Dagger from Jesse Wilson at Square.

      https://github.com/square/Dagger

      It has two cool features that I wish Spring had as well (will create a separate issue for the other feature). Dagger adds beans automatically to the application context (called ObjectGraph in Dagger) when a field or constructor is annotated with @Inject (Dagger doesn't support method injection). This means the bean itself doesn't need to be annotated at all. All the alternatives for this in Spring are not very appealing:

      (a) Using @Component leads to a dependency on the Spring API
      (b) Using @Named (without name) isn't very descriptive at all
      (c) Using @ManagedBean is awkward when not using JSF and requires one to add another dependency since it's not part of the JDK

      In short, it would be great if no annotation would be required.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              toellrich Thomas Oellrich
              Last updater:
              Chris Beams
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                5 years, 35 weeks, 2 days ago