Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
How to configure service properties on managed services Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to configure service properties on managed services

    In Spring DM 1.2 is there any way to configure service properties on a managed service factory so they are applied to each service that is registered? Something like this:
    Code:
    <osgix:managed-service-factory 
    	factory-pid="my.pid" 
    	interface="my.Service" 
    	update-strategy="container-managed">
    	<osgi:service-properties>
    		<entry key="prop1" value="val1"/>
    	</osgi:service-properties>
    	<bean class="my.impl.ServiceImpl"/>
    </osgix:managed-service-factory>
    I've added an <osgi:service-properties> element here, but this is not valid. Is there any way to achieve this?

  • #2
    The intent for managed-service-factory is to use a template bean to automatically publish beans based on the configurations available; any change made to the configuration is reflected onto the published services.
    You don't need to create the service yourself, just configure the bean and you're set (as described here (2.0.0.M1 documentation: http://static.springsource.org/osgi/...vice-factories).

    Applying the configuration to each service registered is a bit problematic since it's likely that the configuration will change or that the number of services vs configs differs - how should these conflicts be resolved (in a declarative way)?

    Comment


    • #3
      Yes, I understand the intention of managed service factories, I would just like to be able to attache service properties to the services created by the factory.

      In my situation, my managed service factory would be creating services based on a generic interface, so many bundles will be contributing services based on this single generic interface and I use service properties to differentiate between them.

      For a contrived example, the Spring docs have a managed service factory that creates a java.util.Queue. Imagine I'd like to create lots of Queue services, but of different types, like java.util.Queue<String> and java.util.Queue<Long>. One bundle would like to use the Queue<String> and another the Queue<Long>. The way I went about this was to register the services with properties, like

      Code:
      <osgi:service ref="myStringQueue" interface="java.util.Queue">
        <osgi:service-properties>
          <entry key="targetClassName" value="java.lang.String"/>
        </osgi:service-properties>
      </osgi:service>
      
      <osgi:service ref="myLongQueue" interface="java.util.Queue">
        <osgi:service-properties>
          <entry key="targetClassName" value="java.lang.Long"/>
        </osgi:service-properties>
      </osgi:service>
      so consumers of these services can be wired up like

      Code:
      <osgi:reference id="stringQueueConsumer" interface="java.util.Queue"
        filter="(targetClassName=java.lang.String)"/>
      
      <osgi:reference id="longQueueConsumer" interface="java.util.Queue"
        filter="(targetClassName=java.lang.Long)"/>
      In this situation I don't have extending interfaces to differentiate between different gerneric Queue implementations, so the OSGi filters help.

      Comment


      • #4
        I think this is related to

        http://jira.springframework.org/browse/OSGI-747

        which I just uploaded an example patch that allows configuring service properties as described on this thread.

        Comment


        • #5
          Hi guys,

          The latest trunk version contains an update regarding this issue - it is now possible to use service-properties for published service factories. Let me know how it works for you.

          Cheers,

          Comment


          • #6
            Re:

            The intention between the service provider companies are increased in massive amount and therefor consumer would often fail difficulties to choose the right service provider. So in these conditions, you may have to do a lot of research and follow certain strategies which could assures you that you would never face any difficulties in the future.Managed IT services is among one of those and everyone try show that they are best but in reality they would have nothing to prove that they are successful marketers and can deliver the desire of certain customer.

            Comment

            Working...
            X