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.lang.Nullable;
024import org.springframework.remoting.support.RemoteInvocation;
025
026/**
027 * Interface for RMI invocation handlers instances on the server,
028 * wrapping exported services. A client uses a stub implementing
029 * this interface to access such a service.
030 *
031 * <p>This is an SPI interface, not to be used directly by applications.
032 *
033 * @author Juergen Hoeller
034 * @since 14.05.2003
035 */
036public interface RmiInvocationHandler extends Remote {
037
038        /**
039         * Return the name of the target interface that this invoker operates on.
040         * @return the name of the target interface, or {@code null} if none
041         * @throws RemoteException in case of communication errors
042         * @see RmiServiceExporter#getServiceInterface()
043         */
044        @Nullable
045        public String getTargetInterfaceName() throws RemoteException;
046
047        /**
048         * Apply the given invocation to the target object.
049         * <p>Called by
050         * {@link RmiClientInterceptor#doInvoke(org.aopalliance.intercept.MethodInvocation, RmiInvocationHandler)}.
051         * @param invocation object that encapsulates invocation parameters
052         * @return the object returned from the invoked method, if any
053         * @throws RemoteException in case of communication errors
054         * @throws NoSuchMethodException if the method name could not be resolved
055         * @throws IllegalAccessException if the method could not be accessed
056         * @throws InvocationTargetException if the method invocation resulted in an exception
057         */
058        @Nullable
059        public Object invoke(RemoteInvocation invocation)
060                        throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
061
062}