Cache and Cache Manger events in CDI
A long time ago, in a coffee bar far, far away, Infinispan met CDI. The two had the most amazing espressos, but they noticed that service was not as efficient as they wished. To help them out, the CDI support has been extended to include CDI Events.
In case you haven’t heard about CDI events, here is a really quick example:
When Waiter receives an order - he fires a CDI event. On the other hand Barista acts as a listener for ordered coffees (@CoffeeOrdered and @Observes). As a result Barista and Waiter are loosely coupled and moreover they don’t know anything about each other.
Now let’s complicate this situation a little bit… Let’s assume that when Waiter is passing an order to Barista, he might be actually busy processing another order. So let’s introduce a little buffer between them - Waiter puts an order into the Cache and later on - Barista takes it and prepares our delicious coffee…
As you can see - introducing CDI improved the service a lot. Now Waiter does not hurry Barista with the orders. This is why they serve the best espresso in the world there…
They have also a lot more time to think about other improvements (and to be honest… I think they will introduce CacheEntryModifiedEvent, CacheEntryRemovedEvent and CacheStartedEvent really shortly)… Or perhaps they’ll find some other ideas in Infinispan’s manual?
Tags: event cdi