RRB.java
/*
* Copyright (C) 2012-2024 RRiBbit.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.rribbit;
/**
* RRB is a convenience class that provides static access to a global {@link RequestResponseBus}. This is ideal for small-scaled Java Applications.
* <p />
* Larger applications will probably want to use a {@link RequestResponseBus} initialized in their Spring Context. Everyone who wants the {@link RequestResponseBus} then has to
* 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
* is convenient for your application.
*
* @author G.J. Schouten
*
*/
public final class RRB {
private static RequestResponseBus requestResponseBus;
/**
* This class is not supposed to be instantiated.
*/
private RRB() {}
/**
* Sets the global static {@link RequestResponseBus}.
*
* @param requestResponseBus
*/
public static void setRequestResponseBus(RequestResponseBus requestResponseBus) {
RRB.requestResponseBus = requestResponseBus;
}
/**
* 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(...);
*
* @return the global static {@link RequestResponseBus}
*/
public static RequestResponseBus get() {
return requestResponseBus;
}
/**
* Gets the global static {@link RequestResponseBus}. This method is intended for people who do like static imports and prefer syntax such as rrb().send(...);
*
* @return the global static {@link RequestResponseBus}
*/
public static RequestResponseBus rrb() {
return requestResponseBus;
}
}