SPIs suggesting registration in default lookup should encourage use of @ServiceProvider.
authorJesse Glick <jglick@netbeans.org>
Mon, 22 Dec 2008 19:52:28 -0500
changeset 491fc76c25553ea
parent 490 9ca5b3d4a70a
child 495 1bacd9548b74
SPIs suggesting registration in default lookup should encourage use of @ServiceProvider.
openide.util/src/org/openide/util/doc-files/api.html
openide.util/src/org/openide/util/lookup/Lookups.java
     1.1 --- a/openide.util/src/org/openide/util/doc-files/api.html	Fri Dec 19 10:24:30 2008 -0500
     1.2 +++ b/openide.util/src/org/openide/util/doc-files/api.html	Mon Dec 22 19:52:28 2008 -0500
     1.3 @@ -145,7 +145,7 @@
     1.4  <div class="nonnormative">
     1.5  
     1.6  The whole NetBeans platform is moving toward 
     1.7 -installation of services via XML layer or <code>META-INF/services</code>.
     1.8 +installation of services via XML layer or (via the <code>@ServiceProvider</code> annotation on classes) <code>META-INF/services</code>.
     1.9  Layer-based installation is more flexible in many ways. 
    1.10  
    1.11  <p>The need for having a standard interface to access such
    1.12 @@ -468,7 +468,9 @@
    1.13  <font class="type">org.me.MyService</font> it shall provide file name 
    1.14  <font class="function-name">META-INF/services/org.me.MyService</FONT> in its own JAR 
    1.15  with single line containing name of the implementation class (for example
    1.16 -<font class="type">org.you.MyServiceImpl</FONT>). The lookup infrastructure
    1.17 +<font class="type">org.you.MyServiceImpl</FONT>).
    1.18 +This is normally done more easily by using the <code>@ServiceProvider</code> annotation in <code>MyService.java</code>.
    1.19 +The lookup infrastructure
    1.20  will then load the implementation class and call its default constructor 
    1.21  to answer the query in the above example.
    1.22  <P>
    1.23 @@ -515,6 +517,7 @@
    1.24      gap for other modules if they need to get in front of your item. And, 
    1.25      again, to keep compatibility the position attribute must starts with
    1.26      comment delimiter.</p>
    1.27 +<p>Both extensions are supported by <code>@ServiceProvider</code>.</p>
    1.28  </DIV>
    1.29  
    1.30  <P>
    1.31 @@ -709,7 +712,9 @@
    1.32  can be found pretty useful when using this library in standalone applications:
    1.33  <code>Lookups.forPath(path)</code> scans all instances registered in the 
    1.34  <a href="#service-lookup">META-INF/services style</a> just it uses
    1.35 -<code>META-INF/namedservices/path</code> prefix instead. As a result to
    1.36 +<code>META-INF/namedservices/path</code> prefix instead.
    1.37 +(<code>@ServiceProvider</code> supports this mode.)
    1.38 +As a result to
    1.39  perform a successfull search for all <code>javax.xml.parsers.DocumentBuilderFactory</code> 
    1.40  inside <code>Lookups.forName("my/xml/app/data")</code> one can register the
    1.41  implementation into <code>META-INF/namedservices/my/xml/app/data/javax.xml.parsers.DocumentBuilderFactory</code>.
     2.1 --- a/openide.util/src/org/openide/util/lookup/Lookups.java	Fri Dec 19 10:24:30 2008 -0500
     2.2 +++ b/openide.util/src/org/openide/util/lookup/Lookups.java	Mon Dec 22 19:52:28 2008 -0500
     2.3 @@ -160,6 +160,7 @@
     2.4       * so there is "stability" in doing this provided some parent loaders are the same
     2.5       * as the previous ones.
     2.6       * @since 3.35
     2.7 +     * @see ServiceProvider
     2.8       */
     2.9      public static Lookup metaInfServices(ClassLoader classLoader) {
    2.10          return new MetaInfServicesLookup(classLoader, "META-INF/services/"); // NOI18N