JSF Managed bean facility @PostDestroy method emulation

as far as I know is that EJB 3.0 provide @PostDestroy annotation meaning when your bean is about to be destroyed the method with @PostDestroy annotation will be called.

What I am doing is this

public class SomeClass{

private EntityManager em;

public void doSomethingOnEM(...){...}

...

}

I set the em via the Managed Bean Facility what it does it calls my Utility class that returns a new instance of EntityManager. Now I do not know how to call the close() method on the em. In EJB 3 I would add

@PostDestroy

public void cleanUp(){

em.close();

}

but I am puzzled how would I do this in plain JSF managed beans. Any ideas? Thanks.

[708 byte] By [HaKia] at [2007-11-26 15:02:06]
# 1
If using JSF 1.2, in an EE environment (such as GlassFish), just annotate the desired method with @PreDestroy annotation, and the JSF implemenation will call said method when the bean is no longer in scope.
rlubkea at 2007-7-8 8:51:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...