You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by imranrazakhan <im...@gmail.com> on 2018/07/15 19:10:20 UTC

Deployment difference between karaf feature bundle and karaf bundle:install

How below both deployments are different

    <feature name="my-base-bundles" version="${project.version}">
            <bundle
start-level="86">mvn:com.my.osgi/mycomponent/0.0.1</bundle>
    </feature>

and

    bundle:install -s mvn:com.my.osgi/mycomponent/0.0.1

what i observed is deploying with feature shows service:list like

    [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

and by deploying with bundle:install

    [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

it work fine but my pax-exam tests are getting failed as after installing i
look for service

    serviceReferences =
this.bundleContext.getServiceReferences("com.my.osgi.mycomponent", filter);

how i should deploy in pax-exam so i can access services like feature
deployments?



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deployment difference between karaf feature bundle and karaf bundle:install

Posted by imranrazakhan <im...@gmail.com>.
>> if you do getServiceReferences("my-stuff") in the bundle 
providing itself the my-stuff service, it's a bad design and it should 
directly use the instance (service providers and service "clients" 
should be in separated bundles

Thanks for highlighting, i am doing this way in my integration test only.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deployment difference between karaf feature bundle and karaf bundle:install

Posted by jb...@nanthrax.net.
Because, if bundle service reference is a requirement for the resolver, 
so, the resolver can install & start the feature/bundle providing the 
service (capability).

When you directly install the bundle, it's up to you to first install 
the bundle providing the service.

By the way, if you do getServiceReferences("my-stuff") in the bundle 
providing itself the my-stuff service, it's a bad design and it should 
directly use the instance (service providers and service "clients" 
should be in separated bundles).

Regards
JB

On 2018-07-15 21:44, imranrazakhan wrote:
> 1- if both bundles are same then why service references are different 
> for
> both?
> 2- why following code line is successful for one deployment(feature 
> based
> deployment) and failing for other, i want that below code line should
> successful if i do deployment with bundle:install
> 
> serviceReferences =
> this.bundleContext.getServiceReferences("com.my.osgi.mycomponent", 
> null)
> 
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html



Re: Deployment difference between karaf feature bundle and karaf bundle:install

Posted by imranrazakhan <im...@gmail.com>.
1- if both bundles are same then why service references are different for
both?
2- why following code line is successful for one deployment(feature based
deployment) and failing for other, i want that below code line should
successful if i do deployment with bundle:install 

serviceReferences =
this.bundleContext.getServiceReferences("com.my.osgi.mycomponent", null)





--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deployment difference between karaf feature bundle and karaf bundle:install

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
That's not the same as:

1. you specify start-level in  the feature (whereas you use the default
one with  bundle:intall)
2. resolver is involved in feature (using capabilities/requirements of
features and bundles) whereas bundle:* commands don't care.

Feature deployment is directly supported in pax-exam if you use the Pax
Exam Karaf Container. It's what we do internally in Karaf itests.

Regards
JB

On 15/07/2018 21:10, imranrazakhan wrote:
> How below both deployments are different
> 
>     <feature name="my-base-bundles" version="${project.version}">
>             <bundle
> start-level="86">mvn:com.my.osgi/mycomponent/0.0.1</bundle>
>     </feature>
> 
> and
> 
>     bundle:install -s mvn:com.my.osgi/mycomponent/0.0.1
> 
> what i observed is deploying with feature shows service:list like
> 
>     [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
> 
> and by deploying with bundle:install
> 
>     [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
> 
> it work fine but my pax-exam tests are getting failed as after installing i
> look for service
> 
>     serviceReferences =
> this.bundleContext.getServiceReferences("com.my.osgi.mycomponent", filter);
> 
> how i should deploy in pax-exam so i can access services like feature
> deployments?
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com