private boolean select(RoutingContext context, String routeName) {
        if (config == null) {
            return true;
        }
        DocumentSelector selector = config.get(routeName);
        if (selector == null) {
            return true;
        }

        // Select based on message content.
        Message msg = context.getMessage();
        switch (msg.getType()) {

        case DocumentProtocol.MESSAGE_PUTDOCUMENT:
            return selector.accepts(((PutDocumentMessage)msg).getDocumentPut()) == Result.TRUE;

        case DocumentProtocol.MESSAGE_UPDATEDOCUMENT:
            return selector.accepts(((UpdateDocumentMessage)msg).getDocumentUpdate()) != Result.FALSE;

        case DocumentProtocol.MESSAGE_REMOVEDOCUMENT: {
            RemoveDocumentMessage removeMsg = (RemoveDocumentMessage)msg;
            if (removeMsg.getDocumentId().hasDocType()) {
                return selector.accepts(removeMsg.getDocumentRemove()) != Result.FALSE;
            } else {
                return true;
            }
        }
        case DocumentProtocol.MESSAGE_GETDOCUMENT: {
            GetDocumentMessage getMsg = (GetDocumentMessage)msg;
            if (getMsg.getDocumentId().hasDocType()) {
                DocumentGet getOp = new DocumentGet(getMsg.getDocumentId());
                return selector.accepts(getOp) != Result.FALSE;
            } else {
                return true;
            }
        }

        default:
            return true;
        }
    }
This method runs the selector associated with the given location on the content of the message. If the selector
validates the location, this method returns true.

@param context   the routing context that contains the necessary data.
@param routeName the candidate route whose selector to run.
@return whether or not to send to the given recipient.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/DocumentRouteSelectorPolicy.java