Is there any way to know when a war is being hot deployed so I can shutdown the old executor that is running scheduled tasks? I'm using jboss 6 and I have a scheduled thread pool that is updating da开发者_StackOverflow社区ta periodically in the background. When I hot deploy that thread pool is not shutdown and new starts up so I have multiple scheduled thread pools.
Thanks for any input.
Yes, but it depends on where you start your Executor
and which technology you use:
in ServletContextListener: start
Executor
incontextInitialized()
and shut it down incontextDestroyed()
.in servlet, start
Executor
ininit()
, shut it down withdestroy()
in EJB/Spring bean: start in method annotated with
@PostConstruct
, shutdown in@PreDestroy
.
Sure. It depends on how do you run this thread. If for example you are running it from sevlet use servlet's destroy()
method to stop it. If you are using Spring use lifecicle of its Application context.
精彩评论