Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-336

IOCBeanManager.lookupBeans(class, qualifiers)

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 2.0.1.Final
    • Fix Version/s: 2.1.0.Beta1
    • Component/s: None
    • Labels:
      None

      Description

      Hi.

      Currently we can:-

      1) Lookup all beans of a particular type: IOCBeanManager.lookupBean(class)

      2) Lookup a single bean of a particular type matching particular qualifiers: IOCBeanManager.lookupBeans(class, qualifiers)

      We would like to be able to lookup a bean where qualifiers not only exist but equal one and other, for example:-

      @MyQualifier("v1")
      class MyBean1 {}

      @MyQualifier("v2")
      class MyBean2 {}

      Annotation qualifier = new SupportedFormat() {

      @Override
      public Class< ? extends Annotation> annotationType()

      { return SupportedFormat.class; }

      @Override
      public String value()

      { return "v1"; }

      };

      IOCBeanManger.lookupBean(MyBean.class, qualifier);

      This currently throws a IOCResolutionException exception as both MyBean1 and MyBean2 are found. Fair enough.

      Could you please consider adding the ability for either:-

      1) IOCBeanManager.lookupBeans(class, qualifiers). Note the pluralization. This would return MyBean1 and MyBean2 (and we can handle subsequent filtering); or

      2) IOCBeanManger.lookupBeanByQualifierEquality(class, qualifiers). This would check the annotations on the matched beans equal the qualifiers passed to the method (the current implementation of lookupBean just checks the set of annotations match).

      This is perhaps an edge case and we have a simple workaround (lookup beans by class and filter on the annotations ourselves) but it might be a "nice to have".

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                cbrock Mike Brock
                Reporter:
                manstis Michael Anstis
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: