KickJava   Java API By Example, From Geeks To Geeks.

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


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

19 public class MockInterceptor extends Interceptor
20 {
21
22
23    public void setCache(CacheImpl cache)
24    {
25       super.setCache(cache);
26
27    }
28
29    private Method JavaDoc called = null;
30
31    private List JavaDoc calledlist = new ArrayList JavaDoc();
32
33    public synchronized Object JavaDoc invoke(MethodCall m) throws Throwable JavaDoc
34    {
35
36       calledlist.add(m.getMethod());
37       called = m.getMethod();
38
39       return null;
40    }
41
42
43    /**
44     * @return Returns the called.
45     */

46    public Method JavaDoc getCalled()
47    {
48       return called;
49    }
50
51    public List JavaDoc getAllCalled()
52    {
53       return calledlist;
54    }
55
56    /**
57     * @param called The called to set.
58     */

59    public void setCalled(Method JavaDoc called)
60    {
61       this.called = called;
62    }
63 }
Popular Tags