class AnyScopePropertyAccessor implements PropertyAccessor {

    @Override
    public void setProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name,
            Object value) {
        Request request = (Request) target;
        String attributeName = (String) name;
        String[] availableScopes = request.getAvailableScopes().toArray(new String[0]);
        for (String scopeName : availableScopes) {
            Map<String, Object> scope = request.getContext(scopeName);
            if (scope.containsKey(attributeName)) {
                scope.put(attributeName, value);
                return;
            }
        }
        if (availableScopes.length > 0) {
            request.getContext(availableScopes[0]).put(attributeName, value);
        }
    }

}