/***************************************
 *                                     *
 *  JBoss: The OpenSource J2EE WebOS   *
 *                                     *
 *  Distributable under LGPL license.  *
 *  See terms of license at gnu.org.   *
 *                                     *
 ***************************************/
package org.jboss.ejb3.remoting;

import javax.management.MBeanServer;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;

/**
 * AOPRemotingInvocationHandler is a ServerInvocationHandler that will forward requests to the
 * aop Dispatcher
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.2.2.5 $
 */
public class EJB3RemotingInvocationHandler implements ServerInvocationHandler
{
   private ServerInvoker invoker;
   private MBeanServer server;

   public EJB3RemotingInvocationHandler()
   {
      super();
   }

   /**
    * set the invoker that owns this handler
    *
    * @param invoker
    */
   public void setInvoker(ServerInvoker invoker)
   {
      this.invoker = invoker;
   }

   /**
    * set the mbean server that the handler can reference
    *
    * @param server
    */
   public void setMBeanServer(MBeanServer server)
   {
      this.server = server;
   }

   /**
    * method is called to destroy the handler and remove all pending notifications and listeners
    * from the notification cache
    */
   public synchronized void destroy()
   {
   }

   protected void finalize() throws Throwable
   {
      destroy();
      super.finalize();
   }

   public Object invoke(InvocationRequest invocation)
           throws Throwable
   {
      /*
      EJBRemoteInvocation inv =(EJBRemoteInvocation)invocation.getParameter();
      Container container = (Container)Registry.lookup(inv.getContainerId());
      return container.remoteInvoke(inv);
      */
      throw new RuntimeException("ABORT NOT USED ANYMORE");
   }

   /**
    * Adds a callback handler that will listen for callbacks from
    * the server invoker handler.
    *
    * @param callbackHandler
    */
   public void addListener(InvokerCallbackHandler callbackHandler)
   {
      //TODO: implement for callback api -TME
   }

   /**
    * Removes the callback handler that was listening for callbacks
    * from the server invoker handler.
    *
    * @param callbackHandler
    */
   public void removeListener(InvokerCallbackHandler callbackHandler)
   {
      //TODO: implement for callback api -TME
   }
}
