if (app instanceof AbstractODataApplication) {
factoryClass = ((AbstractODataApplication) app).getServiceFactoryClass();
} else {
final String factoryClassName = servletConfig.getInitParameter(ODataServiceFactory.FACTORY_LABEL);
if (factoryClassName == null) {
throw new ODataRuntimeException("Servlet config missing: " + ODataServiceFactory.FACTORY_LABEL);
}
ClassLoader cl = (ClassLoader) servletRequest.getAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL);
if (cl == null) {
factoryClass = Class.forName(factoryClassName);
} else {
factoryClass = Class.forName(factoryClassName, true, cl);
}
}
ODataServiceFactory serviceFactory = (ODataServiceFactory) factoryClass.newInstance();
return serviceFactory;
} catch (Exception e) {
throw new ODataRuntimeException("Exception during ODataServiceFactory creation occured.", e);
}
}