code: public static void copyPropertiesToMap(Object bean, String prefix, Map<String, Object> map) {
          Class clazz = bean.getClass();
          Method[] methods = bean.getClass().getMethods();
          for (Method method : methods) {
              // 复制属性
              Class returnc = method.getReturnType();
              if (ReflectUtils.isBeanPropertyReadMethod(method)) {
                  String propertyName = ReflectUtils.getPropertyNameFromBeanReadMethod(method);
                  try {
                      if (ReflectUtils.getPropertySetterMethod(clazz, propertyName, returnc) == null) {
                          continue; // 还需要有set方法
                      }
                  } catch (Exception e) {
                      continue;
                  }
                  Object val;
                  try {
                      val = method.invoke(bean);
                  } catch (InvocationTargetException e) {
                      throw new SofaRpcRuntimeException("Can't access copy " + propertyName, e.getCause());
                  } catch (IllegalAccessException e) {
                      throw new SofaRpcRuntimeException("Can't access copy " + propertyName, e);
                  }
                  if (val != null) { // 值不为空，放入缓存
                      map.put(prefix + propertyName, val);
                  }
              }
          }
          Field[] fields = bean.getClass().getFields();
          for (Field field : fields) {
              String fieldName = field.getName();
              if (map.containsKey(prefix + fieldName)) {
                  continue;
              }
              int m = field.getModifiers();
              if (!Modifier.isStatic(m) && !Modifier.isTransient(m)) {
                  Object val = null;
                  try {
                      if (field.isAccessible()) {
                          val = field.get(bean);
                      } else {
                          try {
                              field.setAccessible(true);
                              val = field.get(bean);
                          } finally {
                              field.setAccessible(false);
                          }
                      }
                  } catch (IllegalAccessException e) {
                      // LOGGER.warn("Can't access field" + fieldName + "when copy value to context", e);
                  }
                  if (val != null) {
                      map.put(prefix + fieldName, val);
                  }
              }
          }
      }
docs: 复制属性到map，可以自定义前缀
  
  @param bean   对象
  @param prefix 放入key的前缀
  @param map    要写入的map