Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a destroy-method in annotation-based bean?

I'm looking for a way to tell spring which method on an annotation-based bean it should call when it's destryoing that bean.

What I'm actually trying to achieve is, to be notified when a session-scoped bean is destroyed in order to persist some stuff from that session.

like image 677
chzbrgla Avatar asked Jun 06 '11 13:06

chzbrgla


1 Answers

You need to implement DisposableBean, or (preferably) annotate the method with javax.annotation.PreDestroy, which is more portable.

like image 112
artbristol Avatar answered Sep 19 '22 13:09

artbristol