wangting
2024-11-05 19d2c06b04aab6d21a36bd5b41c78cdea8ae58b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.vci.server.framework.systemConfig.specialRole;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
 
import org.springframework.context.support.FileSystemXmlApplicationContext;
 
public class SpecialroleService {
 
    //spring配置文件路径
    private static String[] contestpaths = new String[]{"properties/applicationContext.xml"};
//    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(contestpaths);
    //通过相对路径读取配置文件
    private static FileSystemXmlApplicationContext fileSystemXmlApplicationContext = new FileSystemXmlApplicationContext(contestpaths);
    public static FileSystemXmlApplicationContext getFileSystemXmlApplicationContext() {
        return fileSystemXmlApplicationContext;
    }
    public static void setFileSystemXmlApplicationContext(
            FileSystemXmlApplicationContext fileSystemXmlApplicationContext) {
        SpecialroleService.fileSystemXmlApplicationContext = fileSystemXmlApplicationContext;
    }
    
    /**
     * 获取三员角色登录模块信息
     * @return
     */
    public SpecialRoleObject[] getSpecialRoleList(){
        List<SpecialRoleObject> list = new ArrayList<SpecialRoleObject>();
        Map<String, SpecialRoleObject> beansOfType = fileSystemXmlApplicationContext.getBeansOfType(SpecialRoleObject.class);
        Iterator<String> iterator = beansOfType.keySet().iterator();
        while(iterator.hasNext()){
            String next = iterator.next();
            SpecialRoleObject specialRoleObject = beansOfType.get(next);
            list.add(specialRoleObject);
        }
        return list.toArray(new SpecialRoleObject[]{});
    }
    
    
    /**
     * 获取过滤功能编号
     * @return
     */
    public List<String> getFilterFunctionNos(){
        try{
            SpecialRoleRightFilter filter = fileSystemXmlApplicationContext.getBean(SpecialRoleRightFilter.class);
            if(filter != null && filter.getFilterFunctionNos() != null){
                return filter.getFilterFunctionNos();
            }
        }catch(Throwable e){
            
        }
        return new ArrayList<String>();
    }
    
    public static void main(String[] args){
        String[] contestpaths = new String[]{"properties/applicationContext.xml"};
//        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(contestpaths);
        //通过相对路径读取配置文件
        FileSystemXmlApplicationContext fileSystemXmlApplicationContext = new FileSystemXmlApplicationContext(contestpaths);
        Map<String, SpecialRoleObject> beansOfType = fileSystemXmlApplicationContext.getBeansOfType(SpecialRoleObject.class);
        Iterator<String> iterator = beansOfType.keySet().iterator();
        while(iterator.hasNext()){
            String next = iterator.next();
            SpecialRoleObject specialRoleObject = beansOfType.get(next);
            //System.out.println(specialRoleObject.getPanelName());
        }
    }
}