Announcement Announcement Module

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
Is that possible to get osgi service reference without proxy? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is that possible to get osgi service reference without proxy?

    It's easy to get an OSGi service with following simple configuration:
    <reference id="asyncMessageService" interface=""/>

    While it always return a proxy to original bean or service exposed by other bundles. I am wondering is that possible to get original instance instead proxy?


  • #2
    Yes, you can by casting the proxy to a Spring DM interface. See the reference documentation:

    and the ImportedOsgiServiceProxy javadoc:


    • #3
      Hi Costin, first thanks for the reply.

      I tried following configuration:
      <reference id="myService" interface=""/>
      <bean id="serviceConsumer" class="MyServiceConsumerImpl">
        <property name="serviceReferenceField" ref="myService"/>                                      
        <property name="myServiceFiled" ref="myService"/>                                               
      I have bean exported as OSGi service from other bundle.

      My goal is to get the bean injected to serviceConsumer as myServiceFiled. Not the proxy created by Spring DM. I am not interested to get the raw ServiceReference.

      I don't like proxy for the service like cache interface, which could be invoked thousands times per second.

      Apologize if didn't make it clear at first place.

      However, I could get the raw service object by following code:
      ServiceReference nativeReference = ((ServiceReferenceProxy)serviceReference).getTargetServiceReference(); myServiceImpl= (;
      I want to know is it possible to inject raw instance by configuration instead of my code. Or it could be a feature for future.