class QuotaChecker {

    void checkServiceIdentityQuota(ObjectStoreConnection con, String domainName,
            ServiceIdentity service, String caller) {
        
        // if quota check is disabled we have nothing to do
        
        if (!quotaCheckEnabled) {
            return;
        }
        
        // if our service is null then there is no quota check
        
        if (service == null) {
            return;
        }
        
        // first retrieve the domain quota
        
        final Quota quota = getDomainQuota(con, domainName);
        
        // first we're going to verify the elements that do not
        // require any further data from the object store
        
        int objectCount = getListSize(service.getHosts());
        if (quota.getServiceHost() < objectCount) {
            throw ZMSUtils.quotaLimitError("service host quota exceeded - limit: "
                    + quota.getServiceHost() + " actual: " + objectCount, caller);
        }
        
        objectCount = getListSize(service.getPublicKeys());
        if (quota.getPublicKey() < objectCount) {
            throw ZMSUtils.quotaLimitError("service public key quota exceeded - limit: "
                    + quota.getPublicKey() + " actual: " + objectCount, caller);
        }
        
        // now we're going to check if we'll be allowed
        // to create this service in the domain
        
        objectCount = con.countServiceIdentities(domainName) + 1;
        if (quota.getService() < objectCount) {
            throw ZMSUtils.quotaLimitError("service quota exceeded - limit: "
                    + quota.getService() + " actual: " + objectCount, caller);
        }
    }

    public  QuotaChecker();

}