From: Steve F. <sm...@us...> - 2003-08-22 04:32:39
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv5322/src/core/com/mockobjects/dynamic Modified Files: InvocationDispatcher.java Log Message: Further implementation for InvocationDispatcher Index: InvocationDispatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationDispatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InvocationDispatcher.java 20 Aug 2003 21:47:58 -0000 1.1 +++ InvocationDispatcher.java 20 Aug 2003 22:38:40 -0000 1.2 @@ -7,15 +7,18 @@ import java.util.ArrayList; import java.util.Iterator; +import java.util.ListIterator; -public class InvocationDispatcher { +import com.mockobjects.Verifiable; + +public class InvocationDispatcher implements Verifiable { private ArrayList invokables = new ArrayList(); public Object dispatch(Invocation invocation) throws Throwable { - Iterator i = invokables.iterator(); - while (i.hasNext()) { - Invokable invokable = (Invokable)i.next(); + ListIterator i = invokables.listIterator(invokables.size()); + while (i.hasPrevious()) { + Invokable invokable = (Invokable)i.previous(); if (invokable.matches(invocation)) { return invokable.invoke(invocation); } @@ -25,6 +28,17 @@ public void add(Invokable invokable) { invokables.add(invokable); + } + + public void verify() { + Iterator i = invokables.iterator(); + while (i.hasNext()) { + ((Verifiable)i.next()).verify(); + } + } + + public void clear() { + invokables.clear(); } } |