package org.jfox.framework;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;

/**
 * @author <a href="mailto:yangyong@ufsoft.com.cn">Young Yang</a>
 */

public class ComponentContext {

    /**
     * Module desc
     */
    private String module;

    private String moduleDir;

    private boolean singleton;

    private boolean typeSingleton;

    /**
     * user attributes
     */
    private HashMap attributes = new HashMap();


    public ComponentContext() {
    }

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    public String getModuleDir() {
        return moduleDir;
    }

    public void setModuleDir(String moduleDir) {
        this.moduleDir = moduleDir;
    }

    public boolean isSingleton() {
        return singleton;
    }

    public void setSingleton(boolean singleton) {
        this.singleton = singleton;
    }

    public boolean isTypeSingleton() {
        return typeSingleton;
    }

    public void setTypeSingleton(boolean typeSingleton) {
        this.typeSingleton = typeSingleton;
    }

    public Iterator getAttributeNames() {
        return Collections.unmodifiableMap(new HashMap(attributes)).keySet().iterator();
    }

    public synchronized void setAttribute(String name, Object value){
        attributes.put(name,value);
    }

    public synchronized Object removeAttribute(String name){
        return attributes.remove(name);
    }

    public Object getAttribute(String name){
        return attributes.get(name);
    }

    public static void main(String[] args) {

    }
}

