/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.mx.server;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import org.jboss.mx.interceptor.AbstractInterceptor;
import javax.management.ReflectionException;
import javax.management.RuntimeErrorException;
import javax.management.RuntimeMBeanException;
import javax.management.MBeanException;
/**
*
* @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
* @version $Revision: 1.2 $
*
*/
public class Invocation
extends InvocationContext
implements Dispatcher
{
// Constructors --------------------------------------------------
public Invocation() {}
public Invocation(InvocationContext ic)
{
addContext(ic);
}
// Public --------------------------------------------------------
public void addContext(final InvocationContext ctx)
{
super.copy(ctx);
}
public Object dispatch() throws InvocationException
{
if (dispatcher == null)
return Void.TYPE;
return dispatcher.dispatch();
}
int ic_counter = 0;
public AbstractInterceptor nextInterceptor()
{
if (interceptors == null)
return null;
if (ic_counter < interceptors.size())
return (AbstractInterceptor)interceptors.get(ic_counter++);
else
return null;
}
public Object invoke() throws InvocationException
{
AbstractInterceptor ic = nextInterceptor();
if (ic == null)
return dispatch();
else
return ic.invoke(this);
}
Object retVal = null;
public String toString()
{
return getName() + " " + getType();
}
}