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;
17
18 /**
19 * RRB is a convenience class that provides static access to a global {@link RequestResponseBus}. This is ideal for small-scaled Java Applications.
20 * <p />
21 * Larger applications will probably want to use a {@link RequestResponseBus} initialized in their Spring Context. Everyone who wants the {@link RequestResponseBus} then has to
22 * get it from the Spring Context. Alternatively, you could first initialize the Spring Context and then get the {@link RequestResponseBus} out of it and set it in RRB, if that
23 * is convenient for your application.
24 *
25 * @author G.J. Schouten
26 *
27 */
28 public final class RRB {
29
30 private static RequestResponseBus requestResponseBus;
31
32 /**
33 * This class is not supposed to be instantiated.
34 */
35 private RRB() {}
36
37 /**
38 * Sets the global static {@link RequestResponseBus}.
39 *
40 * @param requestResponseBus
41 */
42 public static void setRequestResponseBus(RequestResponseBus requestResponseBus) {
43 RRB.requestResponseBus = requestResponseBus;
44 }
45
46 /**
47 * Gets the global static {@link RequestResponseBus}. This method is intended for people who don't like static imports and prefer syntax such as RRB.get().send(...);
48 *
49 * @return the global static {@link RequestResponseBus}
50 */
51 public static RequestResponseBus get() {
52 return requestResponseBus;
53 }
54
55 /**
56 * Gets the global static {@link RequestResponseBus}. This method is intended for people who do like static imports and prefer syntax such as rrb().send(...);
57 *
58 * @return the global static {@link RequestResponseBus}
59 */
60 public static RequestResponseBus rrb() {
61 return requestResponseBus;
62 }
63 }