hk2
  1. hk2
  2. HK2-77

Config beans are not singletons with HK2 2.x

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.*
    • Fix Version/s: 2.1.*
    • Component/s: None
    • Labels:
      None

      Description

      Now HK2 Config Beans have PerLookup context, so Proxy is created on every .get, e.g.:

      Thread [main] (Suspended)
      AccountConfigBean(Dom).createProxy(Class<T>) line: 947
      DomProxyCreator<T>.create(Inhabitant) line: 64
      DomProxyCreator<T>.create(Inhabitant) line: 54
      DomDescriptor<T>.initTheOne() line: 109
      DomDescriptor<T>.create(ServiceHandle<?>) line: 97
      SystemDescriptor<T>.create(ServiceHandle<?>) line: 404
      PerLookupContext.findOrCreate(ActiveDescriptor<T>, ServiceHandle<?>) line: 69
      ServiceHandleImpl<T>.getService() line: 154
      ServiceLocatorImpl.getService(Type, Annotation...) line: 402
      AccountManagerImpl.get(Class<T>, String) line: 404
      AccountManagerImpl.get(Class<T>) line: 118
      ConfigManagementTest.testGet() line: 139

      This may reduce performance.

        Activity

        Hide
        Mahesh Kannan added a comment -

        This is happening because the alias descriptors / AbstractActiveDescriptors are registered in per lookup scope.

        Show
        Mahesh Kannan added a comment - This is happening because the alias descriptors / AbstractActiveDescriptors are registered in per lookup scope.
        Hide
        jwells added a comment -

        Yes. It looks like a bug in the AliasDescriptor after it is reified. It is not setting the scope annotation (not the scope string, but the scope annotation).

        Show
        jwells added a comment - Yes. It looks like a bug in the AliasDescriptor after it is reified. It is not setting the scope annotation (not the scope string, but the scope annotation).
        Hide
        Mahesh Kannan added a comment -

        svn commit -m "Fix for HK2-77. The fix caches the proxy instance"
        Sending hk2/hk2-config/src/main/java/org/jvnet/hk2/config/DomProxyCreator.java
        Sending hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java
        Transmitting file data ..
        Committed revision 3891.

        If there are issues with AliasDescriptors / ActiveDescriptors we need to open separate issue.

        Show
        Mahesh Kannan added a comment - svn commit -m "Fix for HK2-77 . The fix caches the proxy instance" Sending hk2/hk2-config/src/main/java/org/jvnet/hk2/config/DomProxyCreator.java Sending hk2/hk2-config/src/test/java/org/jvnet/hk2/config/test/ConfigTest.java Transmitting file data .. Committed revision 3891. If there are issues with AliasDescriptors / ActiveDescriptors we need to open separate issue.

          People

          • Assignee:
            Mahesh Kannan
            Reporter:
            andriy.zhdanov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: