Results 1 to 6 of 6

Thread: How to configure service properties on managed services

  1. #1
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default 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?
    -- m@

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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)?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default

    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.
    -- m@

  4. #4
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default

    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.
    -- m@

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6
    Join Date
    Apr 2011
    Posts
    1

    Default 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •