class SpiderDetectorServiceImpl implements SpiderDetectorService {

    public boolean isSpider(String clientIP, String proxyIPs, String hostname, String agent) {
        // See if any agent patterns match
        if (null != agent)
        {
            synchronized(agents)
            {
                if (agents.isEmpty())
                    loadPatterns("agents", agents);
            }

            if(isUseCaseInsensitiveMatching()) {
                agent = StringUtils.lowerCase(agent);
                hostname = StringUtils.lowerCase(hostname);
            }

            for (Pattern candidate : agents) {

                // prevent matcher() invocation from a null Pattern object
                if (null != candidate && candidate.matcher(agent).find()) {
                    return true;
                }


            }
        }

        // No.  See if any IP addresses match
        if (isUseProxies() && proxyIPs != null) {
            /* This header is a comma delimited list */
            for (String xfip : proxyIPs.split(",")) {
                if (isSpider(xfip))
                {
                    return true;
                }
            }
        }

        if (isSpider(clientIP))
            return true;

        // No.  See if any DNS names match
        if (null != hostname)
        {
            synchronized(domains)
            {
                if (domains.isEmpty())
                    loadPatterns("domains", domains);
            }
            for (Pattern candidate : domains)
            {
                // prevent matcher() invocation from a null Pattern object
                if (null != candidate && candidate.matcher(hostname).find())
                {
                    return true;
                }
            }
        }

        // Not a known spider.
        return false;
    }

    @Autowired(required = true) public  SpiderDetectorServiceImpl(ConfigurationService configurationService);

}