Class AbstractSessionLockEvent
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SessionLockAcquiredEvent,SessionLockEvent,SessionLockReleasedEvent,SessionLockRequestedEvent
service event bus around acquisition and
release of a Vaadin session lock is about.
The same lock instance protects a session whether it is acquired by the
framework while handling a request or via VaadinSession.lock() (for
example from UI.access(Command)). Events are only fired for the
outermost lock-hold: taking the lock again on a thread that already holds it
fires nothing. Flow measures the lock-hold itself:
SessionLockAcquiredEvent.getWaitTime() tells how long the thread
waited for the lock and SessionLockReleasedEvent.getHoldTime() how
long it held it.
All events of a lock-hold are fired on the thread that takes the lock. A
listener can therefore tell whether the lock is taken while handling a
request (an incoming push message included) or outside of one, for example
from UI.access(Command) in a background thread, by checking whether
VaadinService.getCurrentRequest() returns a request. Note that the
request may belong to another session, when a request thread locks a session
that is not its own.
Listeners are added for the concrete event types
SessionLockRequestedEvent, SessionLockAcquiredEvent and
SessionLockReleasedEvent, since the event bus dispatches events by
their exact type. The wait time and the hold time are only measured while
there is a listener for the event that reports them.
- Since:
- 25.3
- See Also:
-
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSessionLockEvent(VaadinService service) Creates a new event without a session.protectedAbstractSessionLockEvent(VaadinService service, VaadinSession session) Creates a new event for the given session. -
Method Summary
Modifier and TypeMethodDescriptionGets the Vaadin service from which this event originates.Gets the Vaadin session whose lock is acquired or released.Gets the Vaadin service from which this event originates.Methods inherited from class java.util.EventObject
toString
-
Constructor Details
-
AbstractSessionLockEvent
Creates a new event without a session.- Parameters:
service- the Vaadin service whose session lock is being acquired or released, notnull
-
AbstractSessionLockEvent
Creates a new event for the given session.- Parameters:
service- the Vaadin service whose session lock is being acquired or released, notnullsession- the Vaadin session the lock belongs to, ornullif it is not known- Since:
- 25.4
-
-
Method Details
-
getSource
Gets the Vaadin service from which this event originates.- Overrides:
getSourcein classEventObject- Returns:
- the Vaadin service instance
-
getService
Gets the Vaadin service from which this event originates.- Returns:
- the Vaadin service instance
-
getSession
Gets the Vaadin session whose lock is acquired or released.The session is not known when the lock is taken for a new HTTP session before the Vaadin session has been created in it. It may also not be known after the Vaadin session has been removed from the HTTP session, since the lock does not keep a removed session in memory.
- Returns:
- the Vaadin session, or an empty optional if it is not known
- Since:
- 25.4
-