⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datasourcemethoddefinitionsourceeditor.java

📁 hibernate annotation及acegi-security使用范例
💻 JAVA
字号:
/*
 * @(#)DataSourceMethodDefinitionSourceEditor.java	
 *
 * Copyright 2003 Copyright.com , Inc. All rights reserved.
 * Use is subject to license terms.
 */
package com.game.commons;

import java.beans.PropertyEditorSupport;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.acegisecurity.ConfigAttributeDefinition;
import org.acegisecurity.ConfigAttributeEditor;
import org.acegisecurity.intercept.method.MethodDefinitionMap;

import org.springframework.jdbc.core.JdbcTemplate;

/**
 * <br>Title:
 * <br>Description:
 * <br>Copyright: Copyright.com (c) 2003
 * <br>Company:
 * History:
 * create          2005-11-7 19:02:16
 *
 * @author youlq
 * @version 1.0
 */
public class DataSourceMethodDefinitionSourceEditor extends PropertyEditorSupport{
  protected JdbcTemplate jdbcTemplate;
  //~ Methods ================================================================
  public JdbcTemplate getJdbcTemplate(){
    return jdbcTemplate;
  }

  public void setJdbcTemplate(JdbcTemplate jdbcTemplate){
    this.jdbcTemplate=jdbcTemplate;
  }

  public void setAsText(String s) throws IllegalArgumentException{
    MethodDefinitionMap source=new MethodDefinitionMap();
    List rs;
    try{
      rs=jdbcTemplate.queryForList(s);
    } catch(Exception e){
      setValue(source);
      e.printStackTrace();
      return;
    }
    if((rs==null)||rs.size()==0){
      // Leave value in property editor null
    } else{
      // Now we have properties, process each one individually
      ConfigAttributeEditor configAttribEd=new ConfigAttributeEditor();

      for(Iterator iter=rs.iterator();iter.hasNext();){
        Map row=(Map)iter.next();
        String authority=(String)row.get("auth_name");
        String resource=(String)row.get("auth_string");
        if((null==authority)||(resource==null)){
          continue;
        }
        // Convert value to series of security configuration attributes
        configAttribEd.setAsText(authority);
        ConfigAttributeDefinition attr=(ConfigAttributeDefinition)configAttribEd .getValue();
        // Register name and attribute
        source.addSecureMethod(resource, attr);
      }
    }
    setValue(source);
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -