kiran bharadwaj wrote: > Bundle A: Import Package: com.osgi.P1;version=1.0.0, > com.osgi.P2;version=1.1.0 > Bundle B: Export Package: com.osgi.P1;version=1.0.0;uses:=P2;
For P1 in Bundle B to use P2, Bundle B must either export or import P2, but in your example above it does neither, so this is not a valid example. In your follow-up message you asked about what happens if Bundle B imports P2. First of all, that would make your example valid, because "uses" must refer to a package that is either imported or exported by the bundle, so in your follow-up it now refers to a package that is imported, which is correct. So, in your follow-up question, Bundle B imports P2 for versions >= 1.0.0. This means that the resolver would wire A to B for P1 version 1.0.0 and would wire both A and B to D for P2 version 1.1.0. If Bundle B were to import P2 version = 1.0.0 (i.e., "[1.0.0,1.0.0]"), then the resolve would fail since there would be no way to satisfy A's requirement for P2 1.1.0 and B's requirement for P2 1.0.0. > Bundle C: Export Package: com.osgi.P2;version=1.0.0 > Bundle D: Export Package: com.osgi.P2;version=1.1.0 > Bundle A is wired to B then for P1. Does bundle A uses Bundle D or > Bundle C for P2. > What is the exact use of uses directive? "uses" declares intra-bundle package dependencies. Consider a bundle that exports package foo and imports package javax.servlet: package org.bar.foo; public interface MyInterface { public void register(javax.servlet.Servlet servlet); } It should be clear from the code above that the exported package foo will "use" the imported package javax.servlet, since the Servlet type is used in the signature of one of its methods. The "uses" directive tells the framework this piece of information, because if it did not, the bundle exporting package foo could be wired to one version of javax.servlet while an importer of package foo could be wired to a different version of javax.servlet. Without the "uses" directive, there is no way for the framework to detect such a situation. In OSGi R3 this was not an issue since there could only ever be one version of a package shared at a time. > 2) Also please let me know how to differentiate the separator "," > which is used as a separtor > of package names in uses directive as well as used as a separator > between two exports. > eg: Export-Package: com.osgi;uses:=p1,p2;mandatory:=security, > com.osgi1;uses:=p3 As Niclas points out, you must use quotes. Any directive or attribute value that contains a comma must be in quotes. -> richard _______________________________________________ osgi-dev mailing list osgi-dev@bundles.osgi.org http://bundles.osgi.org/mailman/listinfo/osgi-dev