Package org.fastnate.data
Class DefaultDataProviderFactory
java.lang.Object
org.fastnate.data.AbstractDataProviderFactory
org.fastnate.data.DefaultDataProviderFactory
- All Implemented Interfaces:
DataProviderFactory
Finds and builds all implementations of
DataProvider from the class path.
Each found non abstract class extending DataProvider is instantiated:
- First a constructor with parameters of an allowed type is searched.
- Then all fields and setters marked with
@Resourceare initiated. - At the end all methods marked with
@PostConstructare invoked. - If nothing fails, the new provider is
registered.
EntityImporter- the importer itselfFile- the data directory from the command line resp. from the propertyEntityImporter.DATA_FOLDER_KEY.Properties- thesettingsof theEntityImporterDataProvider- another provider, will throw an exception, if the given provider depends on the new one
EntityImporter.PACKAGES_KEY. In addition one can define one or more data providers in the file
/META-INF/services/org.fastnate.data.DataProvider.- Author:
- Tobias Liefke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <C extends DataProvider>
CaddProvider(EntityImporter importer, Class<C> providerClass) Tries to instantiate the provider from the given class.protected <C extends DataProvider>
CaddProvider(EntityImporter importer, Constructor<C> constructor) Tries to create a provider using the given constructor and adds it to list of providers in theEntityImporter.voidcreateDataProviders(EntityImporter importer) Discovers, builds and registers allDataProviders that are available for the current environment.Methods inherited from class org.fastnate.data.AbstractDataProviderFactory
buildReflections, findImporterDependency, findProviderClasses
-
Constructor Details
-
DefaultDataProviderFactory
public DefaultDataProviderFactory()
-
-
Method Details
-
addProvider
Tries to instantiate the provider from the given class.- Parameters:
importer- the current importer that will be used with that providerproviderClass- the class of the provider to instantiate- Returns:
- the created provider or
nullif the given class has no appropriate constructor
-
addProvider
protected <C extends DataProvider> C addProvider(EntityImporter importer, Constructor<C> constructor) Tries to create a provider using the given constructor and adds it to list of providers in theEntityImporter.- Parameters:
importer- the current instance of the importer for adding the new providerconstructor- the constructor of the new provider- Returns:
- the created provider or
nullif the given constructor is not appropriate
-
createDataProviders
Description copied from interface:DataProviderFactoryDiscovers, builds and registers allDataProviders that are available for the current environment. Ensures that the order of the providers is set in accordance with their dependencies.- Parameters:
importer- the current importer that needs the providers, new providers are added withEntityImporter.addDataProvider(DataProvider)orEntityImporter.addDataProvider(DataProvider, int)
-