/** TODO(程序启动的时候就加载所有资源信息). */
  private void loadResourceDefine() {
    // 加载资源有效,且URL不为空的资源
    List<TResource> resources = resourceService.loadByEnableAndUrl();

    /*
     * 应当是资源url为key, 角色名称为value。角色名称就是那些以ROLE_为前缀的值
     */
    resourceMap = new HashMap<String, Collection<ConfigAttribute>>();

    for (TResource res : resources) {
      List<TRoleResource> rrList = rresourceDao.findByProperty("IResourceId", res.getId());
      for (TRoleResource rr : rrList) {
        ConfigAttribute ca = new SecurityConfig(roleDao.get(rr.getIRoleId()).getVcRole());

        String url = res.getVcUrl();
        if (resourceMap.containsKey(url)) {
          // 获得原来的集合
          Collection<ConfigAttribute> value = resourceMap.get(url);
          value.add(ca);
          resourceMap.put(url, value);
        } else { // 首次添加的key
          Collection<ConfigAttribute> atts = new ArrayList<ConfigAttribute>();
          atts.add(ca);
          resourceMap.put(url, atts);
        }
      }
    }
  }
  /**
   * 更新某个资源对应的权限
   *
   * @param resourceId
   */
  public void updateResourceRole(int resourceId) {

    TResource res = resourceService.get(resourceId);
    String url = res.getVcUrl();
    if (StringUtils.isNotBlank(url)) {
      resourceMap.remove(url); // 删除原先内容
      List<TRoleResource> rrList = rresourceDao.findByProperty("IResourceId", resourceId);
      for (TRoleResource rr : rrList) {
        ConfigAttribute ca = new SecurityConfig(roleDao.get(rr.getIRoleId()).getVcRole());

        if (resourceMap.containsKey(url)) {
          // 获得原来的集合
          Collection<ConfigAttribute> value = resourceMap.get(url);
          value.add(ca);
          resourceMap.put(url, value);
        } else { // 首次添加的key
          Collection<ConfigAttribute> atts = new ArrayList<ConfigAttribute>();
          atts.add(ca);
          resourceMap.put(url, atts);
        }
      }
    }
  }