package Ġorg . d ri pto . spring y . core . event Ċ Ċ import Ġorg . springframework . boot . Application Runner Ċ import Ġorg . springframework . boot . autoconfigure . condition . Conditional On Bean Ċ import Ġorg . springframework . context . ApplicationContext Ċ import Ġorg . springframework . context . Application Event Ċ import Ġorg . springframework . context . Application Event Publisher Ċ import Ġorg . springframework . context . annotation . Bean Ċ import Ġorg . springframework . context . annotation . Configuration Ċ import Ġorg . springframework . context . event . EventListener Ċ Ċ class ĠCustom Spring Event Ġ( source : ĠAny , Ġval Ġmessage : ĠString ): ĠApplication Event ( source ) Ċ Ċ @ Configuration Ċ @ Conditional On Bean ( Event Trigger :: class ) Ċ class ĠCustom Spring Event Publisher Listener Ġ{ ĊĊĠĠĠ Ġ@ Bean ĊĠĠĠ Ġfun Ġcustom Spring Event Publisher ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Event Publisher : ĠApplication Event Publisher , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Context : ĠApplication Context ĊĠĠĠ Ġ) Ġ= ĠApplication Runner Ġ{ ĊĠĠĠĠĠĠĠ Ġapplication Event Publisher ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. also Ġ{ Ġprintln (" Publishing ĠCustom Spring Event === =") Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpublish Event ( Custom Spring Event ( application Context , Ġ" Custom Spring Event ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ EventListener ĊĠĠĠ Ġfun Ġcustom Spring EventListener ( event : ĠCustom Spring Event ) Ġ= Ġprintln (""" ĊĠĠĠĠĠĠĠ ĠCustom Spring Event ĠTrigger ed . ĊĠĠĠĠĠĠĠ ĠEvent : Ġ${ event . message } ĊĠĠĠ Ġ""" . trim Indent ()) Ċ } Ċ