package org.jboss.cache.optimistic;

import org.jboss.cache.TreeCache;
import org.jboss.cache.interceptors.Interceptor;
import org.jgroups.blocks.MethodCall;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * Handles putXXX() methods: if the given node doesn't exist, it will be created
 * (depending on the create_if_not_exists argument)
 *
 * @author Bela Ban
 * @version $Id: CreateIfNotExistsInterceptor.java,v 1.7 2005/01/26 11:45:14
 *          belaban Exp $
 */
public class MockInterceptor extends Interceptor
{


    public void setCache(TreeCache cache)
    {
        super.setCache(cache);

    }

    private Method called = null;

    private List calledlist = new ArrayList();

    public synchronized Object invoke(MethodCall m) throws Throwable
    {

        calledlist.add(m.getMethod());
        called = m.getMethod();

        return null;
    }


    /**
     * @return Returns the called.
     */
    public Method getCalled()
    {
        return called;
    }

    public List getAllCalled()
    {
        return calledlist;
    }

    /**
     * @param called The called to set.
     */
    public void setCalled(Method called)
    {
        this.called = called;
    }
}