Interface UseCaseBus
-
public interface UseCaseBusThe use case bus invokes use cases as defined byUseCaseInvocationBuilder. Requests are serialized using the definedSerializer. All methods wait until a fitting response was received and can optionally deserialized with the definedDeserializer.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <P,E>
PayloadAndErrorPayload<P,E>invokeAndWait(EventType eventType, Object data, Class<P> payloadClass, Class<E> errorPayloadClass)Invokes the correct use case based on theEventTypewith the send data.<P,E>
PayloadAndErrorPayload<P,E>invokeAndWait(EventType eventType, Object data, Class<P> payloadClass, Class<E> errorPayloadClass, long timeout, TimeUnit unit)Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it.PayloadAndErrorPayload<Object,Object>invokeAndWaitNotDeserialized(EventType eventType, Object data)Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it.PayloadAndErrorPayload<Object,Object>invokeAndWaitNotDeserialized(EventType eventType, Object data, long timeout, TimeUnit unit)Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it.static UseCaseBususeCaseBus(SerializedMessageBus serializedMessageBus)
-
-
-
Method Detail
-
useCaseBus
static UseCaseBus useCaseBus(SerializedMessageBus serializedMessageBus)
-
invokeAndWait
<P,E> PayloadAndErrorPayload<P,E> invokeAndWait(EventType eventType, Object data, Class<P> payloadClass, Class<E> errorPayloadClass) throws InterruptedException, ExecutionException
Invokes the correct use case based on theEventTypewith the send data. The method waits until a response is received or an exception occurred. The response is deserialized based on the given classes.- Type Parameters:
P- the type to serialize the response payload toE- the type to serialize the error response payload to- Parameters:
eventType- theEventTypeto send the request ondata- the request datapayloadClass- the class to serialize the response payload toerrorPayloadClass- the class to serialize the error response payload to- Returns:
- the serialized response
- Throws:
InterruptedException- if the waitingThreadwas interruptedExecutionException- if an exception occurred
-
invokeAndWait
<P,E> PayloadAndErrorPayload<P,E> invokeAndWait(EventType eventType, Object data, Class<P> payloadClass, Class<E> errorPayloadClass, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it. The method waits until a response is received, an exception occurred or the timeout expired. The response is deserialized based on the given classes.- Type Parameters:
P- the type to serialize the response payload toE- the type to serialize the error response payload to- Parameters:
eventType- theEventTypeto send the request ondata- the request datapayloadClass- the class to serialize the response payload toerrorPayloadClass- the class to serialize the error response payload totimeout- the interval to waitunit- the unit to define the interval- Returns:
- the deserialized response
- Throws:
InterruptedException- if the waitingThreadwas interruptedExecutionException- if an exception occurredTimeoutException- if the timeout expires
-
invokeAndWaitNotDeserialized
PayloadAndErrorPayload<Object,Object> invokeAndWaitNotDeserialized(EventType eventType, Object data) throws InterruptedException, ExecutionException
Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it. The method waits until a response is received or an exception occurred. The response is not deserialized.- Parameters:
eventType- theEventTypeto send the request ondata- the request data- Returns:
- the raw response
- Throws:
InterruptedException- if the waitingThreadwas interruptedExecutionException- if an exception occurred
-
invokeAndWaitNotDeserialized
PayloadAndErrorPayload<Object,Object> invokeAndWaitNotDeserialized(EventType eventType, Object data, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Invokes the correct use case based on theEventTypewith the send data, which is serialized before sending it. The method waits until a response is received or an exception occurred. The response is not deserialized.- Parameters:
eventType- theEventTypeto send the request ondata- the request datatimeout- the interval to waitunit- the unit to define the interval- Returns:
- the raw response
- Throws:
InterruptedException- if the waitingThreadwas interruptedExecutionException- if an exception occurredTimeoutException- if the timeout expires
-
-