Java Code Examples for com.alipay.sofa.rpc.common.RpcConstants#HIDE_KEY_PREFIX

The following examples show how to use com.alipay.sofa.rpc.common.RpcConstants#HIDE_KEY_PREFIX . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractInterfaceConfig.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
/**
 * 接口属性和方法属性加载配置到缓存
 *
 * @param rebuild 是否重建
 * @return Map<String Object> unmodifiableMap
 */
public synchronized Map<String, Object> getConfigValueCache(boolean rebuild) {
    if (configValueCache != null && !rebuild) {
        return configValueCache;
    }
    Map<String, Object> context = new HashMap<String, Object>(32);
    Map<String, String> providerParams = getParameters();
    if (providerParams != null) {
        context.putAll(providerParams); // 复制接口的自定义参数
    }
    Map<String, MethodConfig> methodConfigs = getMethods();
    if (CommonUtils.isNotEmpty(methodConfigs)) {
        for (MethodConfig methodConfig : methodConfigs.values()) {
            String prefix = RpcConstants.HIDE_KEY_PREFIX + methodConfig.getName() + RpcConstants.HIDE_KEY_PREFIX;
            Map<String, String> methodparam = methodConfig.getParameters();
            if (methodparam != null) { // 复制方法级自定义参数
                for (Map.Entry<String, String> entry : methodparam.entrySet()) {
                    context.put(prefix + entry.getKey(), entry.getValue());
                }
            }
            // 复制方法级参数属性
            BeanUtils.copyPropertiesToMap(methodConfig, prefix, context);
        }
    }
    // 复制接口级参数属性
    BeanUtils.copyPropertiesToMap(this, StringUtils.EMPTY, context);
    configValueCache = Collections.unmodifiableMap(context);
    return configValueCache;
}
 
Example 2
Source File: RpcInternalContext.java    From sofa-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 合法的内置key,以"_"或者"."开头
 *
 * @param key 参数key
 * @return 是否合法
 */
public static boolean isValidInternalParamKey(String key) {
    char c = key.charAt(0);
    return c == RpcConstants.INTERNAL_KEY_PREFIX || c == RpcConstants.HIDE_KEY_PREFIX;
}
 
Example 3
Source File: RpcInternalContext.java    From sofa-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 是否"."开头的隐藏key
 *
 * @param key 参数key
 * @return 是否隐藏key
 */
static boolean isHiddenParamKey(String key) {
    char c = key.charAt(0);
    return c == RpcConstants.HIDE_KEY_PREFIX;
}
 
Example 4
Source File: ParameterConfig.java    From sofa-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * 自定义的key是否合法
 *
 * @param paramkey 参数key
 * @return 是否合法
 */
public static boolean isValidParamKey(String paramkey) {
    char c = paramkey.charAt(0);
    return c != RpcConstants.HIDE_KEY_PREFIX && c != RpcConstants.INTERNAL_KEY_PREFIX;
}
 
Example 5
Source File: AbstractInterfaceConfig.java    From sofa-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * Buildmkey string.
 *
 * @param methodName the method name
 * @param key        the key
 * @return the string
 */
private String buildmkey(String methodName, String key) {
    return RpcConstants.HIDE_KEY_PREFIX + methodName + RpcConstants.HIDE_KEY_PREFIX + key;
}
 
Example 6
Source File: FilterInvoker.java    From sofa-rpc with Apache License 2.0 2 votes vote down vote up
/**
 * Buildmkey string.
 *
 * @param methodName the method name
 * @param key        the key
 * @return the string
 */
private String buildMethodKey(String methodName, String key) {
    return RpcConstants.HIDE_KEY_PREFIX + methodName + RpcConstants.HIDE_KEY_PREFIX + key;
}