I am using Spring annotations, I can pass the HttpRequestContext from the Controller to the Service.
I am looking for a static way or any better solution than passing RequestContext around.
I am using Spring annotations, I can pass the HttpRequestContext from the Controller to the Service.
I am looking for a static way or any better solution than passing RequestContext around.
I don't think this is a good idea. The service layer shouldn't know or care whether or not it's dealing with an HTTP client.
Static doesn't sound like the right idea, either. HttpRequestContext should be associated with an HttpRequest instance, not a particular class.
A better design, in my opinion, would fetch whatever the service needs out of the context and pass it in. No need for the service to be coupled to HTTP or the web layer.