日期:2014-05-20  浏览次数:20682 次

请教下selffacotry的问题
今天看别人代码, 看到这么一段

public Object selfFactory() {
Class cl = this.getClass();
Constructor cons;

try {
cons = cl.getConstructor(null);
} catch(SecurityException e) {
throw new RuntimeException(e);
} catch(NoSuchMethodException e) {
throw new RuntimeException(e);
}

try {
return cons.newInstance(null);
} catch(IllegalArgumentException e1) {
throw new RuntimeException(e1);
} catch(InstantiationException e1) {
throw new RuntimeException(e1);
} catch(IllegalAccessException e1) {
throw new RuntimeException(e1);
} catch(InvocationTargetException e1) {
throw new RuntimeException(e1);
}
}

请教一下, 这个selffactory() 是属于那一种模式的应用么?作用是什么? 谢谢指教

------解决方案--------------------
这个类是做基类用的?
------解决方案--------------------
反射,返回本类的一个实例

------解决方案--------------------
探讨
反射,返回本类的一个实例