package kcg.faics.sec.role;

import javax.annotation.Resource;

import kcg.faics.sec.service.impl.SecurityMapper;

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

/** 
 * HierarchyStringsFactoryBean.java
 * @author 임새미 
 * @since 2016. 10. 7.
 *
 *  	 수정일                     수정자                                       수정내용
 *  -------------	--------	---------------------------
 *  2016. 10. 7. 	    임새미				       최초생성
 * 
 */
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;
	}

}
