As a workaround - I am toying with this idea ..
@Service
@Properties({
@Property(name = "sling.filter.scope", value = "REQUEST", propertyPrivate = true),
@Property(name = "service.ranking", intValue = 100, propertyPrivate = true)
})
public class RequestCountFilter implements Filter {
private AtomicLong requests = new AtomicLong(0);
@Override
public final void destroy() {
}
@Override
public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
request.setAttribute("monitoring.requests", requests);
chain.doFilter(request, response);
// Overflow check (if we had this many requests between restarts i need a raise)
if (requests.incrementAndGet() < 0) {
requests.set(0);
}
}
@Override
public final void init(FilterConfig config) throws ServletException {
}
}And then if I need the count - I can pull it from the servletRequestAttribute