DATAJDBC-200 - Renamed Events to have an 'Event' suffix.
Original pull request: #60.
This commit is contained in:
committed by
Mark Paluch
parent
3f89062bc1
commit
cc477f8c89
12
README.adoc
12
README.adoc
@@ -179,7 +179,7 @@ For example, the following listener will get invoked before an Aggregate gets sa
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public ApplicationListener<BeforeSave> timeStampingSaveTime() {
|
||||
public ApplicationListener<BeforeSaveEvent> timeStampingSaveTime() {
|
||||
|
||||
return event -> {
|
||||
|
||||
@@ -196,21 +196,21 @@ public ApplicationListener<BeforeSave> timeStampingSaveTime() {
|
||||
|===
|
||||
| Event | When It's Published
|
||||
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/BeforeDelete.java[`BeforeDelete`]
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/BeforeDeleteEvent.java[`BeforeDeleteEvent`]
|
||||
| before an aggregate root gets deleted.
|
||||
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterDelete.java[`AfterDelete`]
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterDeleteEvent.java[`AfterDeleteEvent`]
|
||||
| after an aggregate root got deleted.
|
||||
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/BeforeSave.java[`BeforeSave`]
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/BeforeSaveEvent.java[`BeforeSaveEvent`]
|
||||
| before an aggregate root gets saved, i.e. inserted or updated but after the decision was made if it will get updated or deleted.
|
||||
The event has a reference to an https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/core/conversion/AggregateChange.java[`AggregateChange`] instance.
|
||||
The instance can be modified by adding or removing https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/core/conversion/DbAction.java[`DbAction`]s.
|
||||
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterSave.java[`AfterSave`]
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterSaveEvent.java[`AfterSaveEvent`]
|
||||
| after an aggregate root gets saved, i.e. inserted or updated.
|
||||
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterCreation.java[`AfterCreation`]
|
||||
| https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/event/AfterLoadEvent.java[`AfterLoadEvent`]
|
||||
| after an aggregate root got created from a database `ResultSet` and all it's property set
|
||||
|===
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.data.jdbc.core.conversion.AggregateChange.Kind;
|
||||
import org.springframework.data.jdbc.core.conversion.Interpreter;
|
||||
import org.springframework.data.jdbc.core.conversion.JdbcEntityDeleteWriter;
|
||||
import org.springframework.data.jdbc.core.conversion.JdbcEntityWriter;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterDelete;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterDeleteEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterLoadEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterSave;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDelete;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSave;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterSaveEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDeleteEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSaveEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.Identifier;
|
||||
import org.springframework.data.jdbc.mapping.event.Identifier.Specified;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
@@ -71,7 +71,7 @@ public class JdbcEntityTemplate implements JdbcEntityOperations {
|
||||
|
||||
AggregateChange change = createChange(instance);
|
||||
|
||||
publisher.publishEvent(new BeforeSave( //
|
||||
publisher.publishEvent(new BeforeSaveEvent( //
|
||||
Identifier.ofNullable(entityInformation.getId(instance)), //
|
||||
instance, //
|
||||
change //
|
||||
@@ -79,7 +79,7 @@ public class JdbcEntityTemplate implements JdbcEntityOperations {
|
||||
|
||||
change.executeWith(interpreter);
|
||||
|
||||
publisher.publishEvent(new AfterSave( //
|
||||
publisher.publishEvent(new AfterSaveEvent( //
|
||||
Identifier.of(entityInformation.getId(instance)), //
|
||||
instance, //
|
||||
change //
|
||||
@@ -148,11 +148,11 @@ public class JdbcEntityTemplate implements JdbcEntityOperations {
|
||||
|
||||
Specified specifiedId = Identifier.of(id);
|
||||
Optional<Object> optionalEntity = Optional.ofNullable(entity);
|
||||
publisher.publishEvent(new BeforeDelete(specifiedId, optionalEntity, change));
|
||||
publisher.publishEvent(new BeforeDeleteEvent(specifiedId, optionalEntity, change));
|
||||
|
||||
change.executeWith(interpreter);
|
||||
|
||||
publisher.publishEvent(new AfterDelete(specifiedId, optionalEntity, change));
|
||||
publisher.publishEvent(new AfterDeleteEvent(specifiedId, optionalEntity, change));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.data.jdbc.mapping.event.Identifier.Specified;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AfterDelete extends JdbcEventWithId {
|
||||
public class AfterDeleteEvent extends JdbcEventWithId {
|
||||
|
||||
private static final long serialVersionUID = 3594807189931141582L;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AfterDelete extends JdbcEventWithId {
|
||||
* @param instance the deleted entity if it is available.
|
||||
* @param change the {@link AggregateChange} encoding the planned actions to be performed on the database.
|
||||
*/
|
||||
public AfterDelete(Specified id, Optional<Object> instance, AggregateChange change) {
|
||||
public AfterDeleteEvent(Specified id, Optional<Object> instance, AggregateChange change) {
|
||||
super(id, instance, change);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.jdbc.mapping.event.Identifier.Specified;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AfterSave extends JdbcEventWithIdAndEntity {
|
||||
public class AfterSaveEvent extends JdbcEventWithIdAndEntity {
|
||||
|
||||
private static final long serialVersionUID = 8982085767296982848L;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AfterSave extends JdbcEventWithIdAndEntity {
|
||||
* @param instance the newly saved entity.
|
||||
* @param change the {@link AggregateChange} encoding the planned actions to be performed on the database.
|
||||
*/
|
||||
public AfterSave(Specified id, Object instance, AggregateChange change) {
|
||||
public AfterSaveEvent(Specified id, Object instance, AggregateChange change) {
|
||||
super(id, instance, change);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import org.springframework.data.jdbc.mapping.event.Identifier.Specified;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BeforeDelete extends JdbcEventWithId {
|
||||
public class BeforeDeleteEvent extends JdbcEventWithId {
|
||||
|
||||
private static final long serialVersionUID = -5483432053368496651L;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BeforeDelete extends JdbcEventWithId {
|
||||
* @param entity the entity about to get deleted. Might be empty.
|
||||
* @param change the {@link AggregateChange} encoding the planned actions to be performed on the database.
|
||||
*/
|
||||
public <T> BeforeDelete(Specified id, Optional<Object> entity, AggregateChange change) {
|
||||
public <T> BeforeDeleteEvent(Specified id, Optional<Object> entity, AggregateChange change) {
|
||||
super(id, entity, change);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.springframework.data.jdbc.core.conversion.AggregateChange;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BeforeSave extends JdbcEventWithEntity {
|
||||
public class BeforeSaveEvent extends JdbcEventWithEntity {
|
||||
|
||||
private static final long serialVersionUID = -6996874391990315443L;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class BeforeSave extends JdbcEventWithEntity {
|
||||
* @param instance the entity about to get saved.
|
||||
* @param change
|
||||
*/
|
||||
public BeforeSave(Identifier id, Object instance, AggregateChange change) {
|
||||
public BeforeSaveEvent(Identifier id, Object instance, AggregateChange change) {
|
||||
super(id, instance, change);
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,8 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
import org.springframework.data.jdbc.core.conversion.DbAction;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDelete;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSave;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDeleteEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSaveEvent;
|
||||
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -196,7 +196,7 @@ public class JdbcRepositoryManipulateDbActionsIntegrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
ApplicationListener<BeforeDelete> softDeleteListener() {
|
||||
ApplicationListener<BeforeDeleteEvent> softDeleteListener() {
|
||||
|
||||
return event -> {
|
||||
|
||||
@@ -210,9 +210,9 @@ public class JdbcRepositoryManipulateDbActionsIntegrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
ApplicationListener<BeforeSave> logOnSaveListener() {
|
||||
ApplicationListener<BeforeSaveEvent> logOnSaveListener() {
|
||||
|
||||
// this would actually be easier to implement with an AfterSave listener, but we want to test AggregateChange
|
||||
// this would actually be easier to implement with an AfterSaveEvent listener, but we want to test AggregateChange
|
||||
// manipulation.
|
||||
return event -> {
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSave;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSaveEvent;
|
||||
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -77,7 +77,7 @@ public class JdbcRepositoryPropertyConversionIntegrationTests {
|
||||
|
||||
@Bean
|
||||
ApplicationListener applicationListener() {
|
||||
return (ApplicationListener<BeforeSave>) beforeInsert -> ((EntityWithColumnsRequiringConversions) beforeInsert
|
||||
return (ApplicationListener<BeforeSaveEvent>) beforeInsert -> ((EntityWithColumnsRequiringConversions) beforeInsert
|
||||
.getEntity()).setIdTimestamp(getNow());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.SqlGeneratorSource;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterDelete;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterDeleteEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterLoadEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterSave;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDelete;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSave;
|
||||
import org.springframework.data.jdbc.mapping.event.AfterSaveEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeDeleteEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.BeforeSaveEvent;
|
||||
import org.springframework.data.jdbc.mapping.event.Identifier;
|
||||
import org.springframework.data.jdbc.mapping.event.JdbcEvent;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
@@ -79,8 +79,8 @@ public class SimpleJdbcRepositoryEventsUnitTests {
|
||||
assertThat(publisher.events) //
|
||||
.extracting(e -> (Class) e.getClass()) //
|
||||
.containsExactly( //
|
||||
BeforeSave.class, //
|
||||
AfterSave.class //
|
||||
BeforeSaveEvent.class, //
|
||||
AfterSaveEvent.class //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,10 +95,10 @@ public class SimpleJdbcRepositoryEventsUnitTests {
|
||||
assertThat(publisher.events) //
|
||||
.extracting(e -> (Class) e.getClass()) //
|
||||
.containsExactly( //
|
||||
BeforeSave.class, //
|
||||
AfterSave.class, //
|
||||
BeforeSave.class, //
|
||||
AfterSave.class //
|
||||
BeforeSaveEvent.class, //
|
||||
AfterSaveEvent.class, //
|
||||
BeforeSaveEvent.class, //
|
||||
AfterSaveEvent.class //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ public class SimpleJdbcRepositoryEventsUnitTests {
|
||||
e -> e.getOptionalEntity().orElseGet(AssertionFailedError::new), //
|
||||
JdbcEvent::getId //
|
||||
).containsExactly( //
|
||||
Tuple.tuple(BeforeDelete.class, entity, Identifier.of(23L)), //
|
||||
Tuple.tuple(AfterDelete.class, entity, Identifier.of(23L)) //
|
||||
Tuple.tuple(BeforeDeleteEvent.class, entity, Identifier.of(23L)), //
|
||||
Tuple.tuple(AfterDeleteEvent.class, entity, Identifier.of(23L)) //
|
||||
);
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ public class SimpleJdbcRepositoryEventsUnitTests {
|
||||
assertThat(publisher.events) //
|
||||
.extracting(e -> (Class) e.getClass()) //
|
||||
.containsExactly( //
|
||||
BeforeDelete.class, //
|
||||
AfterDelete.class //
|
||||
BeforeDeleteEvent.class, //
|
||||
AfterDeleteEvent.class //
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user