package net.ranides.assira.system;

import net.ranides.assira.reflection.IClass;
import net.ranides.assira.system.impl.HostCompositeContext;
import net.ranides.assira.system.impl.HostSimpleContext;
import net.ranides.assira.system.impl.HostSpringContext;

public interface HostContext {

    Object getBean(String name);

    <T> T getBean(Class<T> type);

    <T> T getBean(IClass<T> type);

    boolean isPrototype(String name);

    boolean isSingleton(String name);

    void registerPrototype(String name, Class<?> type);

    void registerPrototype(String name, IClass<?> type);

    void registerSingleton(String name, Object instance);

    static HostContext fromSpring(Object provider) {
        if(provider == null) {
            return null;
        }
        return new HostSpringContext(provider);
    }

    static HostContext simple() {
        return new HostSimpleContext();
    }

    static HostContext composite(HostContext... contexts) {
        return new HostCompositeContext(contexts);
    }

}
