Results 1 to 2 of 2

Thread: ServiceReference not injecting

  1. #1
    Join Date
    Sep 2008
    Location
    Mont-Saint-Hilaire, QC
    Posts
    16

    Default ServiceReference not injecting

    Hi ppl, here is the pblm: I have 2 OSGi service I'm exposing in a given bundle:

    Code:
    <osgi:service 
       id="myOsgiService"
       interface="com.my.company.SomeDao" 
       ref="daoImplConfig1" />
    	
    <osgi:service 
       id="myOsgiService2" 
       interface="com.my.company.SomeDao" 
       ref="daoImplConfig2" />
    Now, I want to wire these two services. I can't do it as I usually do: by simple interface induction. So I'm trying to do:

    Code:
    @ServiceReference(serviceBeanName="myOsgiService")
    public void setDao(SomeDao someDao) {
    ...
    }
    
    // AND
    
    @ServiceReference(serviceBeanName="myOsgiService2")
    public void setOtherDao(SomeDao someDao) {
    ...
    }
    However, both end up being null, not injected.

    Am I using the annotation correctly? (I do have the annotation post-processor in my context).

    Thanks for your help.

    JS.

  2. #2
    Join Date
    Oct 2005
    Posts
    26

    Default

    Quote Originally Posted by jsbournival View Post
    Hi ppl, here is the pblm: I have 2 OSGi service I'm exposing in a given bundle:

    Code:
    <osgi:service 
       id="myOsgiService"
       interface="com.my.company.SomeDao" 
       ref="daoImplConfig1" />
    	
    <osgi:service 
       id="myOsgiService2" 
       interface="com.my.company.SomeDao" 
       ref="daoImplConfig2" />
    Now, I want to wire these two services. I can't do it as I usually do: by simple interface induction. So I'm trying to do:

    Code:
    @ServiceReference(serviceBeanName="myOsgiService")
    public void setDao(SomeDao someDao) {
    ...
    }
    
    // AND
    
    @ServiceReference(serviceBeanName="myOsgiService2")
    public void setOtherDao(SomeDao someDao) {
    ...
    }
    However, both end up being null, not injected.

    Am I using the annotation correctly? (I do have the annotation post-processor in my context).

    Thanks for your help.

    JS.
    IIRC serviceBeanName is not the id of the service its the id of the bean that the service exposes. so I think in your case its daoImplConfig1 etc.

Tags for this Thread

Posting Permissions

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