package component;
import manager.ManagerInterface;
import manager.IllegalParameterException;
import context.Context;
import java.util.Hashtable;
/**
* Created by IntelliJ IDEA.
* User: saturn
* Date: 2003-9-30
* Time: 13:17:50
* To change this template use Options | File Templates.
*/
public class Manager implements ManagerInterface{
//constant section
public static final String NGOBJECT = "component";
public static final String INTERFACES = "interfaces";
public static final String CLASSES = "classes";
public static final String NAME = "name";
//end
protected Manager(){
if(cont == null){
try{
cont = (Context) context.Manager.getInstance().getInstance(context.Manager.CONTEXT, Context.class);
}catch(IllegalParameterException ipe){
//nerver arrive here
}
}
}
public static ManagerInterface getInstance(){
return new Manager();
}
protected Context cont = null;
public Context getContext(){
return cont;
}
public Object getInstance(String name, Class type) throws IllegalParameterException
{
IllegalParameterException ipe = new IllegalParameterException("IllegalArgument");
if(NGOBJECT.equals(name)&&(type.equals(FComponent.class))){
Object interfaces = getContext().getValue(INTERFACES);
Object classes = getContext().getValue(CLASSES);
Object objectName = getContext().getValue(NAME);;
if(Hashtable.class.isInstance(interfaces)&&Hashtable.class.isInstance(classes)){
return new FComponentImp((Hashtable)interfaces, (Hashtable)classes, (String)objectName);
}
}
throw ipe;
}
}