I am working on Adobe AEM 6.0 and still new to Apache Felix and Sling and I would like to know how to get instance of SlingHttpServletRequest from an OSGI service annotated with @Service.
Is it possible to get the request from ResourceResolverFactory or SlingRepository?
@Service
@Component(metatype = false)
public class TestServiceImpl implements TestService{
@Reference
private ResourceResolverFactory resourceResolverFactory;
@Reference
private SlingRepository repository;
}
I am aware that SlingHttpServletRequest is readily available for classes extending SlingAllMethodsServlet however as for my requirement I need to write a service rather than a servlet.
The rationale behind why I need SlingHttpServletRequest is because I need to get the client's IP address for audit logging purposes.
Is there any better way to do this? Or at least someone can help point me to correct direction how I can achieve such requirement.