class DBService implements RolesProvider {

    void executeDeleteMembership(ResourceContext ctx, String domainName, String roleName,
            String normalizedMember, String auditRef, String caller) {

        // our exception handling code does the check for retry count
        // and throws the exception it had received when the retry
        // count reaches 0

        for (int retryCount = defaultRetryCount; ; retryCount--) {

            try (ObjectStoreConnection con = store.getConnection(true, true)) {

                String principal = getPrincipalName(ctx);

                // first verify that auditing requirements are met

                checkDomainAuditEnabled(con, domainName, auditRef, caller, principal, AUDIT_TYPE_ROLE);

                // if this is the admin role then we need to make sure
                // the admin is not himself who happens to be the last
                // member in the role

                if (ZMSConsts.ADMIN_ROLE_NAME.equals(roleName)) {
                    List<RoleMember> members = con.listRoleMembers(domainName, roleName, false);
                    if (members.size() == 1 && members.get(0).getMemberName().equals(normalizedMember)) {
                        throw ZMSUtils.forbiddenError(caller +
                                ": Cannot delete last member of 'admin' role", caller);
                    }
                }

                // process our delete role member operation

                if (!con.deleteRoleMember(domainName, roleName, normalizedMember,
                        principal, auditRef)) {
                    con.rollbackChanges();
                    throw ZMSUtils.notFoundError(caller + ": unable to delete role member: " +
                            normalizedMember + " from role: " + roleName, caller);
                }

                // update our role and domain time-stamps, and invalidate local cache entry

                con.updateRoleModTimestamp(domainName, roleName);
                con.updateDomainModTimestamp(domainName);
                cacheStore.invalidate(domainName);

                // audit log the request

                auditLogRequest(ctx, domainName, auditRef, caller, ZMSConsts.HTTP_DELETE,
                        roleName, "{\"member\": \"" + normalizedMember + "\"}");

                return;

            } catch (ResourceException ex) {
                if (!shouldRetryOperation(ex, retryCount)) {
                    throw ex;
                }
            }
        }
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}