[wildfly-dev] Application shutdown code: recommended approach?

Thomas Segismont tsegismo at redhat.com
Thu May 23 08:54:42 EDT 2013


Hi,

I recently created this BZ for EAP6.1:

Bug 958217 - Unable to call Stateless bean methods from Singleton 
PreDestroy callback
https://bugzilla.redhat.com/show_bug.cgi?id=958217

I though I could call any EJB bean from a @Singleton @PreDestroy method 
but, as Jaikiran pointed out, the @DependsOn annotation is needed to 
prevent dependencies from being shutdown before this last call.

While it is doable to manually list a few dependencies, it is obviously 
not an option if your shutdown code virtually needs any of your EJB 
beans to be available: in RHQ, we want to be able to shutdown a Quartz 
scheduler gracefully, and the jobs running at shutdown might depend on 
any EJB bean.

I though of adding a DeploymentUnitProcessor which would automatically 
make a "special" @Singleton bean (marked with an annotation) depend on 
all over beans in the RHQ deployment.

What do you think?

Thanks and regards,
Thomas


More information about the wildfly-dev mailing list