我在阅读 Apache Olingo v4 源代码时遇到了这个问题。这是实例化具体类的已知模式吗?
当抽象类 Odata 和 Concert 类 ODataImpl 在 newInstance() 方法中绑定在一起时,分离它们的好处或目的是什么?
public abstract class OData {
private static final String IMPLEMENTATION = "org.apache.olingo.server.core.ODataImpl";
public static OData newInstance() {
try {
final Class<?> clazz = Class.forName(OData.IMPLEMENTATION);
/*
* We explicitly do not use the singleton pattern to keep the server state free
* and avoid class loading issues also during hot deployment.
*/
final Object object = clazz.newInstance();
return (OData) object;
} catch (final Exception e) {
throw new ODataRuntimeException(e);
}
}