package kcg.imis.sec.role;

import javax.annotation.Resource;

import kcg.imis.sec.mapper.SecurityMapper;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
  * @FileName : HierarchyStringsFactoryBean.java
  * @Project : 국제해양프로젝트
  * @Date : 2018. 3. 29. 
  * @작성자 : Moon
  * @변경이력 : 
  * @프로그램 설명 :
 */
public class HierarchyStringsFactoryBean implements FactoryBean<String>, ApplicationContextAware {
	
	@Resource(name = "securityMapper")
	SecurityMapper securityMapper;
	
    private String hierarchyStrings;
    private ApplicationContext context;
    
    public void init() throws Exception {
        hierarchyStrings = securityMapper.getHierarchyRoles();
    }

    public String getObject() throws Exception {
        if (hierarchyStrings == null) {
            init();
        }
        return hierarchyStrings;
    }

    public Class<String> getObjectType() {
        return String.class;
    }

    public boolean isSingleton() {
        return true;
    }

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.context = applicationContext;
	}

}
