bloritsch 2002/10/03 10:37:15
Modified: util/src/java/org/apache/excalibur/util MultiDelegate.java
MultiDelegateFactory.java
Log:
updates to JavaDocs, and more explicit throws clauses. Also *only* throw
IllegalArgumentException
Revision Changes Path
1.2 +6 -1
jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/MultiDelegate.java
Index: MultiDelegate.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/MultiDelegate.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultiDelegate.java 3 Oct 2002 16:59:39 -0000 1.1
+++ MultiDelegate.java 3 Oct 2002 17:37:15 -0000 1.2
@@ -111,11 +111,16 @@
/**
* Adds a new delegate to the MultiDelegate's list. The Delegate is only added
* if it does not yet exist in the list.
+ *
+ * @param o The delegate we are adding to this MultiDelegate. The delegate
+ * must use the same interface this MultiDelegate is using.
*/
public void add (Object o);
/**
* Removes a delegate from the MultiDelegate's list.
- */
+ *
+ * @param o The delegate we are removing from this MultiDelegate.
+ */
public void remove (Object o);
}
1.2 +16 -5
jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/MultiDelegateFactory.java
Index: MultiDelegateFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/MultiDelegateFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultiDelegateFactory.java 3 Oct 2002 16:59:39 -0000 1.1
+++ MultiDelegateFactory.java 3 Oct 2002 17:37:15 -0000 1.2
@@ -52,6 +52,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -93,8 +94,12 @@
}
/**
- * Creates a new MultiDelegateHandler. The handler's add and remove methods
will only accept
- * objects that implements the interface given in delegateClass.
+ * Creates a new MultiDelegateHandler. The handler's add and remove methods
will
+ * only accept objects that implements the interface given in delegateClass.
+ * The Class passed in must be an interface with only one method that
returns
+ * <code>void</code>
+ *
+ * @param delegateClass The interface representing the MultiDelegate.
*/
public MultiDelegateHandler( Class delegateClass )
{
@@ -104,14 +109,21 @@
/**
* Handles invocations. If the call is made through the MultiDelegate
interface,
* the appropriate methods are called. Otherwise the delegate methods are
called.
+ *
+ * @param proxy The object to forward the method invocations to.
+ * @param method The method that was called
+ * @param args The arguments used for the method
+ *
+ * @return Object must always be an "instance" of void.class
*/
- public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws IllegalAccessException, InvocationTargetException
{
if (method.equals (addMethod))
{
if( args[0] == null )
{
- throw new NullPointerException( "Argument to
MultiDelegate.add(Object) is null." );
+ throw new IllegalArgumentException( "Argument to
MultiDelegate.add(Object) is null." );
}
if( !delegateClass.isAssignableFrom(args[0].getClass()) )
@@ -205,5 +217,4 @@
new Class[]{ MultiDelegate.class, delegateInterface },
new MultiDelegateHandler( delegateInterface ));
}
-
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>