/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3;

import java.lang.reflect.Method;
import org.jboss.aop.Advisor;
import org.jboss.aop.MethodInfo;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;

/**
 * Representation of an EJB invocation on the serverside
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.2.2.4 $
 */
public class EJBContainerInvocation extends MethodInvocation
{
   protected BeanContext ctx;

   public EJBContainerInvocation(MethodInfo info, Interceptor[] interceptors)
   {
      super(info, interceptors);
   }

   public EJBContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor)
   {
      super(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
   }

   public EJBContainerInvocation()
   {
      super(null, null);
   }

   public BeanContext getBeanContext()
   {
      return ctx;
   }

   public void setBeanContext(BeanContext ctx)
   {
      this.ctx = ctx;
   }

   public Invocation getWrapper(Interceptor[] newchain)
   {
      return new EJBContainerInvocationWrapper(this, newchain);
   }

   public Invocation copy()
   {
      EJBContainerInvocation wrapper = new EJBContainerInvocation(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
      wrapper.metadata = this.metadata;
      wrapper.currentInterceptor = this.currentInterceptor;
      wrapper.setTargetObject(this.getTargetObject());
      wrapper.setArguments(this.getArguments());
      wrapper.setBeanContext(this.ctx);
      return wrapper;
   }

}
