001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.remoting.rmi;
018
019import java.lang.reflect.InvocationTargetException;
020import java.rmi.Remote;
021import java.rmi.RemoteException;
022
023import org.springframework.remoting.support.RemoteInvocation;
024
025/**
026 * Interface for RMI invocation handlers instances on the server,
027 * wrapping exported services. A client uses a stub implementing
028 * this interface to access such a service.
029 *
030 * <p>This is an SPI interface, not to be used directly by applications.
031 *
032 * @author Juergen Hoeller
033 * @since 14.05.2003
034 */
035public interface RmiInvocationHandler extends Remote {
036
037        /**
038         * Return the name of the target interface that this invoker operates on.
039         * @return the name of the target interface, or {@code null} if none
040         * @throws RemoteException in case of communication errors
041         * @see RmiServiceExporter#getServiceInterface()
042         */
043        public String getTargetInterfaceName() throws RemoteException;
044
045        /**
046         * Apply the given invocation to the target object.
047         * <p>Called by
048         * {@link RmiClientInterceptor#doInvoke(org.aopalliance.intercept.MethodInvocation, RmiInvocationHandler)}.
049         * @param invocation object that encapsulates invocation parameters
050         * @return the object returned from the invoked method, if any
051         * @throws RemoteException in case of communication errors
052         * @throws NoSuchMethodException if the method name could not be resolved
053         * @throws IllegalAccessException if the method could not be accessed
054         * @throws InvocationTargetException if the method invocation resulted in an exception
055         */
056        public Object invoke(RemoteInvocation invocation)
057                        throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
058
059}