class CollectUserAgentFilter implements Filter {

    @Override
    public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain )
            throws IOException, ServletException
    {
        try
        {
            final HttpServletRequest request = (HttpServletRequest) servletRequest;
            String ua = request.getHeader( "User-Agent" );
            if ( ua != null && !ua.isEmpty() )
            {
                output.add( ua.split( " " )[0] );
            }
        }
        catch ( RuntimeException e )
        {
            // We're fine with that
        }

        filterChain.doFilter( servletRequest, servletResponse );
    }

    public  CollectUserAgentFilter( RecentK<String> output );

}