commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1090352 - in /commons/proper/discovery/trunk: RELEASE-NOTES.txt src/changes/changes.xml src/site/xdoc/best-practices.xml
Date Fri, 08 Apr 2011 17:06:18 GMT
Author: simonetripodi
Date: Fri Apr  8 17:06:17 2011
New Revision: 1090352

URL: http://svn.apache.org/viewvc?rev=1090352&view=rev
Log:
DISCOVERY-9: Documentation of other use cases

Modified:
    commons/proper/discovery/trunk/RELEASE-NOTES.txt
    commons/proper/discovery/trunk/src/changes/changes.xml
    commons/proper/discovery/trunk/src/site/xdoc/best-practices.xml

Modified: commons/proper/discovery/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/RELEASE-NOTES.txt?rev=1090352&r1=1090351&r2=1090352&view=diff
==============================================================================
--- commons/proper/discovery/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/discovery/trunk/RELEASE-NOTES.txt Fri Apr  8 17:06:17 2011
@@ -36,6 +36,7 @@ JIRA Issues Addressed
 ---------------------
 * DISCOVERY-3 (https://issues.apache.org/jira/browse/DISCOVERY-3)
 * DISCOVERY-7 (https://issues.apache.org/jira/browse/DISCOVERY-7)
+* DISCOVERY-9 (https://issues.apache.org/jira/browse/DISCOVERY-9)
 * DISCOVERY-11 (https://issues.apache.org/jira/browse/DISCOVERY-11)
 * DISCOVERY-12 (https://issues.apache.org/jira/browse/DISCOVERY-12)
 * DISCOVERY-14 (https://issues.apache.org/jira/browse/DISCOVERY-14)

Modified: commons/proper/discovery/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/changes/changes.xml?rev=1090352&r1=1090351&r2=1090352&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/changes/changes.xml (original)
+++ commons/proper/discovery/trunk/src/changes/changes.xml Fri Apr  8 17:06:17 2011
@@ -29,6 +29,9 @@
     <action dev="simonetripodi" type="update" issue="DISCOVERY-7">
       Discovery failed to load an inner class.
     </action>
+    <action dev="simonetripodi" type="update" issue="DISCOVERY-9">
+      Documentation of other use cases.
+    </action>
     <action dev="simonetripodi" type="fix" issue="DISCOVERY-11">
       Service.providers Enumeration does not catch and discard
       UnsatisfiedLinkErrors and ExceptionInInitializerErrors.

Modified: commons/proper/discovery/trunk/src/site/xdoc/best-practices.xml
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/site/xdoc/best-practices.xml?rev=1090352&r1=1090351&r2=1090352&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/site/xdoc/best-practices.xml (original)
+++ commons/proper/discovery/trunk/src/site/xdoc/best-practices.xml Fri Apr  8 17:06:17 2011
@@ -151,7 +151,7 @@ used and maintains internal state.
 [NEED BETTER EXAMPLE]
 <ul>
 <source>
-    import org.apache.commons.discovery.DiscoverClass;
+    import org.apache.commons.discovery.DiscoverClasses;
     import org.apache.commons.logging.LogFactory;
     ...
     DiscoverClass discoverClass = new DiscoverClass();
@@ -164,6 +164,29 @@ for the name of a class that implements 
 Failing that, it uses JDK1.3-style service discovery.
 </p>
 
+<p>To find <b>all</b> the SPI implementation classes from user-code, use
<code>DiscoverClasses</code> instead:</p>
+<source>
+    import org.apache.commons.discovery.ResourceClassIterator;
+    import org.apache.commons.discovery.ResourceClass:
+    import org.apache.commons.discovery.resource.classes.DiscoverClasses;
+    import org.apache.commons.logging.LogFactory;
+    ...
+    DiscoverClasses&lt;LogFactory&gt; discovery = new DiscoverClasses&lt;TestInterface2&gt;(loaders);
+    ResourceClassIterator&lt;LogFactory&gt; iter = discovery.findResourceClasses(name);
+    while (iter.hasNext()) {
+        ResourceClass&lt;LogFactory&gt; resource = iter.nextResourceClass();
+        try {
+            Class&lt;? extends LogFactory&gt; implClass = resource.loadClass();
+                if (implClass != null) {
+                    // TODO do something
+                }
+            } catch (Exception e) {
+                // TODO handle exception
+            }
+        }
+    }
+</source>
+
 <p>To instantiate a class directly from user-code:
 [NEED BETTER EXAMPLE]
 <ul>



Mime
View raw message