/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.remoting;

import org.jboss.logging.Logger;

import java.util.List;
import java.util.Map;

/**
 * Client is a convience method for invoking remote methods for a given subsystem
 *
 * @author <a href="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
 * @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
 * @version $Revision: 1.2.4.1 $
 */
public interface ClientInterceptor
{

   boolean isConnected (InvokerLocator locator) throws Exception;

   void connect (InvokerLocator locator) throws Exception;

   void disconnect (InvokerLocator locator) throws Exception;


    /**
     * invoke the method remotely
     *
     * @param sessionId
     * @param method
     * @param params
     * @param signature
     * @param sendPayload
     * @return
     * @throws Throwable
     */
    Object invoke (InvocationRequest invocation)
      throws Throwable;

    /**
     * If the client invoker has a client locator, call it to add the client's
     * callback handler.  Then call the server to add a callback handler
     * (regardless of client locator being null).  This will allow for pull or
     * push callbacks.
     * @param callbackHandler
     * @throws Throwable
     */
    void addListener(InvokerLocator locator, String sessionId, InvokerCallbackHandler callbackHandler) throws Throwable;

    /**
     * Removes callback handler as a callback listener from the server (and client in
     * the case that it was setup to receive async callbacks). See addListener().
     * @param callbackHandler
     * @throws Throwable
     */
    void removeListener(InvokerLocator locator, String sessionId, InvokerCallbackHandler callbackHandler) throws Throwable;

    List getCallbacks(InvokerLocator locator, String sessionId) throws Throwable;

}
