package factory;
import java.io.*;
import java.lang.reflect.*;
import dao.*;
import biz.*;
import view.*;
import daoImpl.*;
public class Factory {
String daoName;
String viewName;
String bizName;
public Factory(){
loading();
}
private void loading() {
try {
FileReader fr = new FileReader("config.txt");
BufferedReader br = new BufferedReader(fr);
daoName = br.readLine();
bizName = br.readLine();
viewName = br.readLine();
br.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Object createObject(String name) {
try {
Class c = Class.forName(name);
Object o = c.newInstance();
return o ;
} catch (Exception e) {
return null;
}
}
public View getView(){
Daodao = (Dao) this.createObject(daoName);
Biz biz = (Biz) this.createObject(bizName);
View view = (View)this.createObject(viewName);