commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1090658 - /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java
Date Sat, 09 Apr 2011 19:37:55 GMT
Author: simonetripodi
Date: Sat Apr  9 19:37:55 2011
New Revision: 1090658

URL: http://svn.apache.org/viewvc?rev=1090658&view=rev
Log:
added 'shortcuts' static methods to create SPInterface instances, writing 'new SPInterface<MyType>(MyType.class)'
is redundant

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java?rev=1090658&r1=1090657&r2=1090658&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/SPInterface.java
Sat Apr  9 19:37:55 2011
@@ -34,6 +34,75 @@ import org.apache.commons.discovery.Disc
 public class SPInterface<T> {
 
     /**
+     * Construct object representing Class {@code provider}.
+     *
+     * @param <T> The SPI type
+     * @param provider The SPI class
+     * @return A new object representing Class {@code provider}
+     * @since 0.5
+     */
+    public static <T> SPInterface<T> newSPInterface(Class<T> provider)
{
+        return newSPInterface(provider, provider.getName());
+    }
+
+    /**
+     * Construct object representing Class {@code provider}.
+     *
+     * @param <T> The SPI type
+     * @param provider The SPI class
+     * @param propertyName when looking for the name of a class implementing
+     *        the provider class, a discovery strategy may involve looking for
+     *        (system or other) properties having either the name of the class
+     *        (provider) or the <code>propertyName</code>.
+     * @return A new object representing Class {@code provider}
+     * @since 0.5
+     */
+    public static <T> SPInterface<T> newSPInterface(Class<T> provider,
String propertyName) {
+        return new SPInterface<T>(provider, propertyName);
+    }
+
+    /**
+     * Construct object representing Class {@code provider}.
+     *
+     * @param <T> The SPI type
+     * @param provider The SPI class
+     * @param constructorParamClasses classes representing the
+     *        constructor argument types
+     * @param constructorParams objects representing the
+     *        constructor arguments
+     * @return A new object representing Class {@code provider}
+     * @since 0.5
+     */
+    public static <T> SPInterface<T> newSPInterface(Class<T> provider,
+            Class<?> constructorParamClasses[],
+            Object constructorParams[]) {
+        return newSPInterface(provider, provider.getName(), constructorParamClasses, constructorParams);
+    }
+
+    /**
+     * Construct object representing Class {@code provider}.
+     *
+     * @param <T> The SPI type
+     * @param provider The SPI class
+     * @param propertyName when looking for the name of a class implementing
+     *        the provider class, a discovery strategy may involve looking for
+     *        (system or other) properties having either the name of the class
+     *        (provider) or the <code>propertyName</code>.
+     * @param constructorParamClasses classes representing the
+     *        constructor argument types
+     * @param constructorParams objects representing the
+     *        constructor arguments
+     * @return A new object representing Class {@code provider}
+     * @since 0.5
+     */
+    public static <T> SPInterface<T> newSPInterface(Class<T> provider,
+            String propertyName,
+            Class<?> constructorParamClasses[],
+            Object constructorParams[]) {
+        return new SPInterface<T>(provider, propertyName, constructorParamClasses,
constructorParams);
+    }
+
+    /**
      * The service programming interface: intended to be
      * an interface or abstract class, but not limited
      * to those two.



Mime
View raw message