Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hi thanks everyone for your answers. I think ServiceRegistry will work in an osgi container to instantiate a service but only within the same classloader. And that's facilitated by use of <a href="http://wiki.osgi.org/wiki/Fragment" rel="nofollow">osgi fragments</a>. So as long as the implementer is in a fragment that defines its Fragment-host as the bundle that contains the class that has the ServiceRegistry lookup code, then ServiceRegistry will work.</p> <p>This is why it is working in the xdocreport code I linked to. In this case the ServiceLoader code is called from an abstract class in <a href="http://code.google.com/p/xdocreport/source/browse/core/fr.opensagres.xdocreport.core/src/main/java/fr/opensagres/xdocreport/core/registry/AbstractRegistry.java?name=xdocreport-0.9.8" rel="nofollow">fr.opensagres.xdocreport.core</a> (a bundle), which is extended by concrete class in <a href="http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocreport.document/src/main/java/fr/opensagres/xdocreport/document/registry/XDocReportRegistry.java?name=xdocreport-0.9.8" rel="nofollow">fr.opensagres.xdocreport.document</a> (so the ServiceRegistry call is in fr.opensagres.xdocreport.document). The Service implementation is in <a href="http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocreport.document.docx/src/main/java/fr/opensagres/xdocreport/document/docx/discovery/DocxDocumentHandlerFactoryDiscovery.java?name=xdocreport-0.9.8" rel="nofollow">fr.opensagres.xdocreport.document.docx</a>. a fragment whose has defined its <a href="http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocreport.document.docx/TEMPLATE.MF?name=xdocreport-0.9.8" rel="nofollow">frament-host as fr.opensagres.xdocreport.document</a>.</p> <p>So fr.opensagres.xdocreport.document and fr.opensagres.xdocreport.document.docx use the same class loader...so it works!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload