Felix
  1. Felix
  2. FELIX-3377

Allow a component to update its own service properties

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: scr-1.6.0
    • Fix Version/s: scr-1.6.2
    • Labels:
      None

      Description

      If you just register a service in code, you can give the ServiceRegistration to the service and it can update its service properties to reflect what it can discover about its environment. This proposes that services registered through DS should be able to do this too, by calling an updateProperties(Dictionary) method on the ComponentContext. (Since we'd need a spec update to add the method to ComponentContext, I added a new interface that ComponentContextImpl implements).

      Right now a service could get Config Admin and modify the properties there, but then (a) the update method is called even though the component itself initiated the changes and (b) the new property values are persisted which is presumably not desired.

      According to the spec config admin properties override default property values specified in the component xml. I think that in order to reduce confusion, once a property has been set through config admin it should not be possible to update it through this update method. This also makes implementing this idea easy.

      IIUC this idea does not make sense for component factories.

      This idea was originally suggested by Erin Schnabel in OSGI bug 2250.

      1. FELIX-3377.diff
        16 kB
        David Jencks
      2. FELIX-3377-2.diff
        17 kB
        David Jencks
      3. FELIX-3377-3.diff
        18 kB
        David Jencks
      4. FELIX-3377-4.diff
        32 kB
        David Jencks
      5. FELIX-3377-returnDictionary.patch
        29 kB
        Felix Meschberger
      6. FELIX-3377-4-fmeschbe.patch
        52 kB
        Felix Meschberger

        Activity

        David Jencks created issue -
        David Jencks made changes -
        Field Original Value New Value
        Attachment FELIX-3377.diff [ 12517377 ]
        David Jencks made changes -
        Description If you just register a service in code, you can give the ServiceRegistration to the service and it can update its service properties to reflect what it can discover about its environment. This proposes that services registered through DS should be able to do this too, by calling an updateProperties(Dictionary) method on the ComponentContext. (Since we'd need a spec update to add the method to ComponentContext, I added a new interface that ComponentContextImpl implements).

        Right now a service could get Config Admin and modify the properties there, but then (a) the update method is called even though the component itself initiated the changes and (b) the new property values are persisted which is presumably not desired.

        According to the spec config admin properties override default property values specified in the component xml. I think that in order to reduce confusion, once a property has been set through config admin it should not be possible to update it through this update method. This also makes implementing this idea easy.

        IIUC this idea does not make sense for component factories.
        If you just register a service in code, you can give the ServiceRegistration to the service and it can update its service properties to reflect what it can discover about its environment. This proposes that services registered through DS should be able to do this too, by calling an updateProperties(Dictionary) method on the ComponentContext. (Since we'd need a spec update to add the method to ComponentContext, I added a new interface that ComponentContextImpl implements).

        Right now a service could get Config Admin and modify the properties there, but then (a) the update method is called even though the component itself initiated the changes and (b) the new property values are persisted which is presumably not desired.

        According to the spec config admin properties override default property values specified in the component xml. I think that in order to reduce confusion, once a property has been set through config admin it should not be possible to update it through this update method. This also makes implementing this idea easy.

        IIUC this idea does not make sense for component factories.

        This idea was originally suggested by Erin Schnabel in OSGI bug 2250.
        David Jencks made changes -
        Attachment FELIX-3377-2.diff [ 12517486 ]
        David Jencks made changes -
        Attachment FELIX-3377-3.diff [ 12518123 ]
        David Jencks made changes -
        Attachment FELIX-3377-4.diff [ 12525714 ]
        Felix Meschberger made changes -
        Attachment FELIX-3377-returnDictionary.patch [ 12525742 ]
        Felix Meschberger made changes -
        Attachment FELIX-3377-4-fmeschbe.patch [ 12526017 ]
        Felix Meschberger made changes -
        Assignee Felix Meschberger [ fmeschbe ]
        Felix Meschberger made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s scr-1.6.2 [ 12315248 ]
        Resolution Fixed [ 1 ]
        Felix Meschberger made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Felix Meschberger
            Reporter:
            David Jencks
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development