Top Description Fields Constructors Methods
org.springframework.context

public abstract Class ApplicationEvent

extends EventObject
Class Inheritance
Known Direct Subclasses
org.springframework.context.PayloadApplicationEvent, org.springframework.context.event.ApplicationContextEvent
Imports
java.time.Clock, java.util.EventObject

Class to be extended by all application events. Abstract as it doesn't make sense for generic events to be published directly.
Authors
Rod Johnson, Juergen Hoeller
See Also
org.springframework.context.ApplicationListener, org.springframework.context.event.EventListener

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Hides java.util.EventObject.serialVersionUID.

use serialVersionUID from Spring 1.2 for interoperability.
private final long
timestamp

System time when the event happened.

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
ApplicationEvent(Object
the object on which the event initially occurred or with which the event is associated (never null)
source
)

Create a new ApplicationEvent with its timestamp set to System#currentTimeMillis().

public
ApplicationEvent(Object
the object on which the event initially occurred or with which the event is associated (never null)
source
,
Clock
a clock which will provide the timestamp
clock
)

Create a new ApplicationEvent with its timestamp set to the value returned by Clock#millis() in the provided Clock.

Method Summary

Modifier and TypeMethod and Description
public final long
getTimestamp()

Return the time in milliseconds when the event occurred.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

use serialVersionUID from Spring 1.2 for interoperability.

timestampback to summary
private final long timestamp

System time when the event happened.

Constructor Detail

ApplicationEventback to summary
public ApplicationEvent(Object source)

Create a new ApplicationEvent with its timestamp set to System#currentTimeMillis().

Parameters
source:Object

the object on which the event initially occurred or with which the event is associated (never null)

See Also
ApplicationEvent(Object, Clock)
ApplicationEventback to summary
public ApplicationEvent(Object source, Clock clock)

Create a new ApplicationEvent with its timestamp set to the value returned by Clock#millis() in the provided Clock.

This constructor is typically used in testing scenarios.

Parameters
source:Object

the object on which the event initially occurred or with which the event is associated (never null)

clock:Clock

a clock which will provide the timestamp

Since
5.3.8
See Also
ApplicationEvent(Object)

Method Detail

getTimestampback to summary
public final long getTimestamp()

Return the time in milliseconds when the event occurred.

See Also
ApplicationEvent(Object), ApplicationEvent(Object, Clock)