假设我在层次结构中的所有类都只有默认构造函数,那么创建 Log 实例有什么问题,如下所示?
public abstract class AbstractService {
protected static Log log=null;
public AbstractService(){
log=LogFactory.getLog(this.getClass().getName());
}
public void foo(){
log.debug("base foo() : ");
}
}
class ServiceA extends AbstractService {
public void foo(){
super.foo();
log.debug("Overloaded foo() in ServiceA");
}
}
class ServiceB extends AbstractService {
public void foo(){
super.foo();
log.debug("Overloaded foo() in ServiceB");
}
}