KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > optimistic > MockFailureInterceptor


1 package org.jboss.cache.optimistic;
2
3 import org.jboss.cache.CacheSPI;
4 import org.jboss.cache.interceptors.Interceptor;
5 import org.jboss.cache.marshall.MethodCall;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
9
10 /**
11  * Handles putXXX() methods: if the given node doesn't exist, it will be created
12  * (depending on the create_if_not_exists argument)
13  *
14  * @author Bela Ban
15  * @version $Id: CreateIfNotExistsInterceptor.java,v 1.7 2005/01/26 11:45:14
16  * belaban Exp $
17  */

18 public class MockFailureInterceptor extends Interceptor
19 {
20
21
22     public void setCache(CacheSPI cache)
23     {
24         super.setCache(cache);
25     }
26
27
28     private List JavaDoc allCalled = new ArrayList JavaDoc();
29     private List JavaDoc failurelist = new ArrayList JavaDoc();
30
31     public Object JavaDoc invoke(MethodCall m) throws Throwable JavaDoc
32     {
33         if (failurelist.contains(m.getMethod()))
34         {
35             throw new Exception JavaDoc("Failure in method" + m);
36         }
37
38         allCalled.add(m.getMethod());
39
40         return null;
41     }
42
43
44     /**
45      * @return Returns the failurelist.
46      */

47     public List JavaDoc getFailurelist()
48     {
49         return failurelist;
50     }
51
52     /**
53      * @param failurelist The failurelist to set.
54      */

55     public void setFailurelist(List JavaDoc failurelist)
56     {
57         this.failurelist = failurelist;
58     }
59
60     /**
61      * @return Returns the called.
62      */

63     public List JavaDoc getAllCalled()
64     {
65         return allCalled;
66     }
67
68     /**
69      * @param called The called to set.
70      */

71     public void setAllCalled(List JavaDoc called)
72     {
73         this.allCalled = called;
74     }
75 }
Popular Tags