Class RpcInvocationEndedEvent
java.lang.Object
java.util.EventObject
com.vaadin.flow.server.communication.AbstractRpcInvocationEvent
com.vaadin.flow.server.communication.RpcInvocationEndedEvent
- All Implemented Interfaces:
Serializable
Event fired through the
service event bus
once a client-to-server RPC invocation has been handled, whether it completed
normally or threw. It is fired on the same thread as the matching
RpcInvocationStartedEvent.
The event tells how long the invocation took and whether it threw, so a listener that times invocations needs no state of its own and no listener for the started or failed event.
- Since:
- 25.3
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionRpcInvocationEndedEvent(UI ui, String type, int nodeId, String name) Creates a new event for an invocation that completed normally and whose duration was not measured.RpcInvocationEndedEvent(UI ui, String type, int nodeId, String name, Duration duration, Throwable error) Creates a new event carrying the measured duration of the invocation and the throwable it raised, if any. -
Method Summary
Modifier and TypeMethodDescriptionGets how long the invocation took, measured from just before theRpcInvocationStartedEventwas fired until the invocation was handled.getError()Gets the throwable raised by the invocation handler, which is the one the matchingRpcInvocationFailedEventcarried.Methods inherited from class com.vaadin.flow.server.communication.AbstractRpcInvocationEvent
getComponent, getName, getNodeId, getType, getUIMethods inherited from class java.util.EventObject
getSource, toString
-
Constructor Details
-
RpcInvocationEndedEvent
Creates a new event for an invocation that completed normally and whose duration was not measured.The event reports a
zeroduration and no error. UseRpcInvocationEndedEvent(UI, String, int, String, Duration, Throwable)to create an event with a measured duration or an error.- Parameters:
ui- the UI the invocation is handled against, notnulltype- the protocol-level invocation type, notnullnodeId- the id of the targetedStateNode, or-1if the invocation does not target a nodename- a human-readable identifier for the invocation, ornullif none applies
-
RpcInvocationEndedEvent
public RpcInvocationEndedEvent(UI ui, String type, int nodeId, String name, Duration duration, Throwable error) Creates a new event carrying the measured duration of the invocation and the throwable it raised, if any.- Parameters:
ui- the UI the invocation is handled against, notnulltype- the protocol-level invocation type, notnullnodeId- the id of the targetedStateNode, or-1if the invocation does not target a nodename- a human-readable identifier for the invocation, ornullif none appliesduration- the time from just before the started event was fired until the invocation was handled, notnullerror- the throwable raised by the invocation handler, ornullif it completed normally- Since:
- 25.4
-
-
Method Details
-
getDuration
Gets how long the invocation took, measured from just before theRpcInvocationStartedEventwas fired until the invocation was handled. It includes the time the listeners of the started and failed events took, but not the time spent on this event.- Returns:
- the duration, never negative
- Since:
- 25.4
-
getError
Gets the throwable raised by the invocation handler, which is the one the matchingRpcInvocationFailedEventcarried. An empty optional means the invocation completed normally.- Returns:
- the throwable, or an empty optional if the invocation did not throw
- Since:
- 25.4
-