java - Can I ensure that one of my Spring ApplicationListeners gets executed last? -
i have several services listening spring events make changes underlying data model. these work implementing applicationlistener<foo>
. once of foo
listeners modify underlying data model, user interface needs refresh reflect changes (think firetabledatachanged()
).
is there way ensure specific listener foo
last? or there way call function when other listeners done? i'm using annotation based wiring , java config, if matters.
all beans implementing applicationlistener
should implement ordered
, provide reasonable order value. lower value, sooner listener invoked:
class firstlistener implements applicationlistener<foo>, ordered { public int getorder() { return 10; } //... } class secondlistener implements applicationlistener<foo>, ordered { public int getorder() { return 20; } //... } class lastlistener implements applicationlistener<foo>, ordered { public int getorder() { return lowest_precedence; } //... }
moreover can implement priorityordered
make sure 1 of listeners invoked first.
Comments
Post a Comment