1 /*
2 * Copyright (C) 2012-2024 RRiBbit.org
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.rribbit.processing;
17
18 import java.rmi.Remote;
19 import java.rmi.RemoteException;
20
21 import org.rribbit.Request;
22 import org.rribbit.Response;
23 import org.rribbit.dispatching.RmiRequestDispatcher;
24
25 /**
26 * Interface required to create the {@link RmiRequestProcessorImpl}. Necessary, because Java RMI requires Remote interfaces that extend {@link Remote}. Note that an
27 * {@link RmiRequestProcessor} is not actually an {@link RequestProcessor}, because Java RMI does not allow non-remote methods in a remote interface. This is not a
28 * problem though, since an {@link RmiRequestProcessor} receives its requests via RMI and not via a Java interface.
29 *
30 * @author G.J. Schouten
31 *
32 */
33 public interface RmiRequestProcessor extends Remote {
34
35 /**
36 * The RMI Key that implementations of this interface must use to communicate with the {@link RmiRequestDispatcher}.
37 */
38 String REGISTRY_KEY = "RmiRequestProcessor";
39
40 /**
41 * Processes a {@link Request} and returns the {@link Response}. This method should just call {@link RequestProcessor#processRequest(Request)}, but is necessary, because Java RMI
42 * requires you to declare a {@link RemoteException} on remote methods.
43 *
44 * @param request The {@link Request} to process
45 * @return The {@link Response}
46 */
47 <T> Response<T> processRequestViaRMI(Request request) throws RemoteException;
48 }