You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by imranrazakhan <im...@gmail.com> on 2018/07/17 16:53:37 UTC

IPOJO Component is not exposing service properly

i have component like@Component(immediate = true)@Providespublic class
MyComponent implements MyService{@Override    public boolean islock()    {       
return true;    }}when i deploy in karaf with below commandbundle:install -s
mvn:com.my.osgi/mycomponent/0.0.1if i do service:list at karaf console it
shows output like[org.apache.felix.ipojo.Factory]    
--------------------------------      component.class =
com.my.osgi.mycomponent      component.description = factory
name="com.my.osgi.mycomponent" bundle="77" state="valid"
implementation-class="com.my.osgi.mycomponent"             requiredhandlers
list="[org.apache.felix.ipojo:properties, org.apache.felix.ipojo:callback,
org.apache.felix.ipojo:provides, org.apache.felix.ipojo:architect     ure]"            
missinghandlers list="[]"             provides
specification="com.my.osgi.mycomponent"             inherited
interfaces="[com.my.osgi.mycomponent]" superclasses="[]"     
component.providedServiceSpecifications = [com.my.osgi.mycomponent]     
factory.name = com.my.osgi.mycomponent      factory.state = 1     
service.bundleid = 77      service.id = 153      service.pid =
com.my.osgi.mycomponent      service.scope = singleton But i am expecting
like below, [com.my.osgi.mycomponent]    
-----------------------------------------------------     instance.name =
mycomponent.3c2c91a5-4c28-46c3-a08e-1470192ef353      service.bundleid = 76     
service.factoryPid = com.my.osgi.mycomponent      service.id = 397     
service.pid = com.my.osgi.mycomponent.3c2c91a5-4c28-46c3-a08e-1470192ef353     
service.scope = bundle What i am doing wrong



--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

Re: IPOJO Component is not exposing service properly

Posted by imranrazakhan <im...@gmail.com>.
yes, its working fine now. thanks



--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: IPOJO Component is not exposing service properly

Posted by Pierre De Rop <pi...@gmail.com>.
Hello;

maybe you could try by specifying a location "?" when creating the factory
configuration, something like:

    Configuration config =
this.configurationAdmin.createFactoryConfiguration("com.my.osgi.MyComponent",
"?")

regards
Pierre


On Wed, Jul 18, 2018 at 3:50 PM, imranrazakhan <im...@gmail.com>
wrote:

> I tried to use configurationAdmin in my Pax-Exam test class with below code
>
>     Configuration config =
> this.configurationAdmin.createFactoryConfiguration("
> com.my.osgi.MyComponent");
>     Hashtable props = new Hashtable();
>     props.put("myprop", "1");
>
>     config.update(props);
>
> Error if following
>
>     2018-07-18T15:42:20,201 | ERROR | CM Event Dispatcher (Fire
> ConfigurationEvent:
> pid=com.my.osgi.MyComponent.59c30147-0aea-412f-ad2b-52decc4482ee) |
> ipojo
> | 22 - org.apache.felix.ipojo - 1.12.1.patch20180226 | [ERROR] iPOJO
> Configuration Admin listener : Cannot use configuration
> pid=com.my.osgi.MyComponent.59c30147-0aea-412f-ad2b-52decc4482ee for
> bundle
> mvn:com.my.osgi/my-component/2.0.5-SNAPSHOT because it belongs to bundle
> local
>
>
>
>
>
> --
> Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-
> f4833200.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: IPOJO Component is not exposing service properly

Posted by imranrazakhan <im...@gmail.com>.
I tried to use configurationAdmin in my Pax-Exam test class with below code

    Configuration config =
this.configurationAdmin.createFactoryConfiguration("com.my.osgi.MyComponent");
    Hashtable props = new Hashtable();
    props.put("myprop", "1");
    
    config.update(props);

Error if following 

    2018-07-18T15:42:20,201 | ERROR | CM Event Dispatcher (Fire
ConfigurationEvent:
pid=com.my.osgi.MyComponent.59c30147-0aea-412f-ad2b-52decc4482ee) | ipojo                           
| 22 - org.apache.felix.ipojo - 1.12.1.patch20180226 | [ERROR] iPOJO
Configuration Admin listener : Cannot use configuration
pid=com.my.osgi.MyComponent.59c30147-0aea-412f-ad2b-52decc4482ee for bundle
mvn:com.my.osgi/my-component/2.0.5-SNAPSHOT because it belongs to bundle
local





--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: IPOJO Component is not exposing service properly

Posted by imranrazakhan <im...@gmail.com>.
@Clement  its working as expected. 

Now my question is how i can achieve this without changing in component
class?

As i am calling this in pax-exam test so can i instantiate this component in
pax-exam without adding @Instantiate in class?

I am using below class
https://github.com/apache/karaf/blob/master/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java


and following is my test

@Test
    public void serviceCreationIsWorking()
    {
        MyComponent serviceObject = getOsgiService(MyComponent.class,
30000l);
        System.out.println("getOsgiService=" + serviceObject);
        System.out.println("getOsgiService method=" +
serviceObject.islock());
     }






--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: IPOJO Component is not exposing service properly

Posted by Clement Escoffier <cl...@gmail.com>.
@Instantiate sorry.

Clement

> On 18 Jul 2018, at 09:28, imranrazakhan <im...@gmail.com> wrote:
> 
> its @Instance or @Instantiate, as it only shows @Instantiate
> 
> 
> 
> --
> Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: IPOJO Component is not exposing service properly

Posted by imranrazakhan <im...@gmail.com>.
its @Instance or @Instantiate, as it only shows @Instantiate



--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: IPOJO Component is not exposing service properly

Posted by Clement Escoffier <cl...@gmail.com>.
Hello,

It looks like you didn’t create an instance. Add the @Instance annotation on the class.

Clement

> On 17 Jul 2018, at 18:53, imranrazakhan <im...@gmail.com> wrote:
> 
> i have component like@Component(immediate = true)@Providespublic class
> MyComponent implements MyService{@Override    public boolean islock()    {       
> return true;    }}when i deploy in karaf with below commandbundle:install -s
> mvn:com.my.osgi/mycomponent/0.0.1if i do service:list at karaf console it
> shows output like[org.apache.felix.ipojo.Factory]    
> --------------------------------      component.class =
> com.my.osgi.mycomponent      component.description = factory
> name="com.my.osgi.mycomponent" bundle="77" state="valid"
> implementation-class="com.my.osgi.mycomponent"             requiredhandlers
> list="[org.apache.felix.ipojo:properties, org.apache.felix.ipojo:callback,
> org.apache.felix.ipojo:provides, org.apache.felix.ipojo:architect     ure]"            
> missinghandlers list="[]"             provides
> specification="com.my.osgi.mycomponent"             inherited
> interfaces="[com.my.osgi.mycomponent]" superclasses="[]"     
> component.providedServiceSpecifications = [com.my.osgi.mycomponent]     
> factory.name = com.my.osgi.mycomponent      factory.state = 1     
> service.bundleid = 77      service.id = 153      service.pid =
> com.my.osgi.mycomponent      service.scope = singleton But i am expecting
> like below, [com.my.osgi.mycomponent]    
> -----------------------------------------------------     instance.name =
> mycomponent.3c2c91a5-4c28-46c3-a08e-1470192ef353      service.bundleid = 76     
> service.factoryPid = com.my.osgi.mycomponent      service.id = 397     
> service.pid = com.my.osgi.mycomponent.3c2c91a5-4c28-46c3-a08e-1470192ef353     
> service.scope = bundle What i am doing wrong
> 
> 
> 
> --
> Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org