SpringSource/spring-scala — pull request #12 by nurkiewicz (2013-04-09 20:47:17+00:00)
Title: Scala wrapper for ApplicationListener to allow pattern matching on ApplicationEvents

Tiny adapter to allow using pattern matching when receivng `ApplicationEvent` instead of extending type-parameterized interface.

Client beans can now write:

class AggregatingDestroyBean extends ApplicationListenerAdapter {
def onEvent = {
case closed: ContextClosedEvent => //...
}
}

or even listen for unrelated events (not possible due to type erasure in Java) and apply complex pattern matching on custom events on top of case classes:

class AggregatingAdvancedBean extends ApplicationListenerAdapter {
def onEvent = {
case closed: ContextClosedEvent => //...
case CustomEvent(id, true, _) if id > 42 => //...
}
}

Provides consistent API with similar [`TransactionSynchronizationManager`](https://github.com/SpringSource/spring-scala/blob/master/src/main/scala/org/springframework/scala/transaction/support/TransactionSynchronizationManager.scala).