I’m working with JBoss 4 & Spring. In a web application, I use Quartz scheduler to perform some scheduled task. In a Quartz job, I would like to get the server path Is it possible ? If yes, how ?
PS: Some context
I need the server path in Quartz job, because that job would send emails. The emails contains links to the website my application serves, and to build proper URLs, I need a server path. Hardcoding the server path is a no-no, as the application is deployed on various servers.
There’s no sensible way to get the data from inside the Quartz job, so it will have to be the other way around. Have a global configuration bean, call it ServerConfig or whatever. Let it implement
ServletContextAware, then it is automatically notified when a web context is started up.Now just inject that Bean into your Quartz job class and use
serverConfig.getServerRootUrl()to retrieve the root URL.