I have this singleton class which will start when the application starts and the method invokes itself for every 30 seconds.
@Singleton
@Startup
public class myClass{
@Schedule(second="*/30", minute="*", hour="*")
public void serviceRequest(){
String url = "";
//send request
}
}
the url will be something like http://localhost:7001/webapp/rest/tasks/mytask. I don't want to hardcode the url. Instead, I want to somehow get that from the system (or somewhere). I've tried injecting resource like HttpServletRequest but that didn't work.
Thanks in advance.
The url will be provided by an external service so I dont need to worry about host and port number since ill get full url to that rest service. Because the service isn't available so I made an in house rest service to test my functionality. I guess I will harcode the url for now.