public DataProvider getDataProvider ( ) { if ( this . dataProvider == null ) { // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "begin"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "begin"); DataSchema schema = getSchema ( ) ; // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getSchema", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "begin"); String [ ] facetFieldList = getFacetFieldList ( ) ; // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getFacetFieldList", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "begin"); final ApplicationContext applicationContext1 = getApplicationContext ( ) ; final DatasourceConfig config = applicationContext1 . getConfig ( DatasourceConfig . class ) ; GenericDataSource dataSource = new GenericDataSource ( config . getFilename ( ) , null , GenericDataSource . DataSourceType . ServletRelativeDataSource ) ; switch ( config . getDataSourceProvider ( ) ) { case ClientSideSearchDataProvider : dataSource . setDataSourceProvider ( DataSourceProvider . ClientSideSearchDataProvider ) ; this . dataProvider = new ClientSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case ServerSideLuceneDataProvider : dataSource . setDataSourceProvider ( DataSourceProvider . ServerSideLuceneDataProvider ) ; this . dataProvider = new ServerSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case GoogleAppEngineLuceneDataSource : dataSource . setDataSourceProvider ( DataSourceProvider . GoogleAppEngineLuceneDataSource ) ; this . dataProvider = new ServerSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case LocalClientSideDataProvider : default : dataSource . setDataSourceProvider ( DataSourceProvider . LocalClientSideDataProvider ) ; this . dataProvider = new DefaultLocalJSONDataProvider ( dataSource , schema , facetFieldList ) ; break ; } // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "DefaultLocalJSONDataProvider", "end"); // EventLogger.logEvent("org.wwarn.surveyor.client.mvp.SimpleClientFactory", "getDataProvider", "end"); } return this . dataProvider ; }
Lazy initialise Dataprovider