1 /*
2 * Copyright (C) 2012-2025 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.dispatching;
17
18 import org.rribbit.Request;
19 import org.rribbit.Response;
20 import org.rribbit.processing.RequestProcessor;
21
22 /**
23 * A {@link RequestDispatcher} takes care of dispatching {@link Request} objects to a {@link RequestProcessor}. This could involve transportation over a network or communication protocol.
24 * Implementations are responsible for encoding the {@link Request} object and decoding the {@link Response} object.
25 * <p />
26 * A single {@link RequestDispatcher} is always supposed to communicate with only a single {@link RequestProcessor}, for simplicity and ease of possible network configurations.
27 *
28 * @author G.J. Schouten
29 *
30 */
31 public interface RequestDispatcher {
32
33 /**
34 * Dispatches a {@link Request} to a {@link RequestProcessor} and returns the {@link Response}.
35 *
36 * @param request The {@link Request} to be dispatched to a {@link RequestProcessor}
37 * @return The {@link Response} to be returned from the {@link RequestProcessor}
38 */
39 <T> Response<T> dispatchRequest(Request request);
40 }