-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add implementation of custom spring events based on some internal logic
- Loading branch information
EMEA\VEA3SF
committed
Jan 21, 2024
1 parent
ce9bf21
commit 1754eb7
Showing
12 changed files
with
434 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.springpageable.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ProcessEventDto implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 1L; | ||
|
||
private UUID nextAutoPlanSubJobUuid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.springpageable.event; | ||
|
||
import com.springpageable.dto.ProcessEventDto; | ||
import com.springpageable.model.FutureDevice; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
@EqualsAndHashCode(callSuper = true) | ||
public class ProcessEvent extends ApplicationEvent { | ||
|
||
private final ProcessEventDto processEventDto; | ||
|
||
public ProcessEvent(FutureDevice futureDevice, ProcessEventDto processEventDto) { | ||
super(futureDevice); | ||
this.processEventDto = processEventDto; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/springpageable/event/ProcessEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.springpageable.event; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ProcessEventListener implements ApplicationListener<ProcessEvent> { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessEventListener.class); | ||
|
||
@Override | ||
public void onApplicationEvent(ProcessEvent event) { | ||
LOGGER.info("Received spring custom event - {}", event.getProcessEventDto()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/springpageable/event/ProcessEventPublisher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.springpageable.event; | ||
|
||
import com.springpageable.dto.ProcessEventDto; | ||
import com.springpageable.model.FutureDevice; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.UUID; | ||
|
||
@Component | ||
public class ProcessEventPublisher { | ||
|
||
private ApplicationEventPublisher applicationEventPublisher; | ||
|
||
public ProcessEventPublisher(ApplicationEventPublisher applicationEventPublisher) { | ||
this.applicationEventPublisher = applicationEventPublisher; | ||
} | ||
|
||
public void publishCustomEvent(FutureDevice futureDevice) { | ||
ProcessEventDto processEventDto = new ProcessEventDto(UUID.randomUUID()); | ||
var event = new ProcessEvent(futureDevice, processEventDto); | ||
applicationEventPublisher.publishEvent(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.