Class AbstractSetup
java.lang.Object
de.iip_ecosphere.platform.support.setup.AbstractSetup
- Direct Known Subclasses:
CollectorSetup,InstalledDependenciesSetup
Basic class for a YAML-based component setup. Implementing classes must have a public no-arg constructor.
Each property requires a public getter and setter in Java Bean Style.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the default setup file with extension (no path).static final StringThe name of the default setup file, no extension, no path.static final StringName of the default setup override file with extension (no path).private static Stringstatic final Stringprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the default file name used for loading.Returns the (parent) folder where the oktoflow plugins are located (the folder itself or by default its sub-folders "plugins" or "oktoPlugins").static booleanisNotEmpty(String str) Returns if a string is valid, i.e.static <C> CreadFromYaml(Class<C> cls) Reads a configuration fromgetDefaultFileName()in the root folder of the JAR/classpath.static <C> CreadFromYaml(Class<C> cls, InputStream in) Reads a instance fromin.static <C> CreadFromYaml(Class<C> cls, InputStream in, InputStream overwrite) Reads a instance fromin.static <C> CreadFromYaml(Class<C> cls, String filename) Reads a configuration from the root folder of the JAR/classpath.static <C> CreadFromYaml(Class<C> cls, String filename, String overwrite) Reads a configuration from the root folder of the JAR/classpath.static <C> CreadFromYamlWithPath(Class<C> cls, String yamlPath) Reads a configuration fromgetDefaultFileName()in the root folder of the JAR/classpath.static <C> CreadFromYamlWithPath(Class<C> cls, String yamlPath, InputStream in, InputStream overwrite) Reads a instance fromin.static <C> CreadFromYamlWithPath(Class<C> cls, String yamlPath, String filename) Reads a configuration from the root folder of the JAR/classpath.static <C> CreadFromYamlWithPath(Class<C> cls, String yamlPath, String filename, String overwrite) Reads a configuration from the root folder of the JAR/classpath.Reads a configuration from the root folder of the JAR/classpath as mapping.readMappingFromYaml(String filename) Reads a configuration from the root folder of the JAR/classpath as mapping.static StringsetDefaultFileName(String name) Sets the default file name used for loading, by defaultDEFAULT_FNAME.voidsetPluginsFolder(String pluginsFolder) Changes the (parent) folder where the oktoflow plugins are located.voidsetPluginsFolderFile(File pluginsFolder) Changes the (parent) folder where the oktoflow plugins are located.
-
Field Details
-
PARAM_PLUGINS
- See Also:
-
DEFAULT_NAME
The name of the default setup file, no extension, no path.- See Also:
-
DEFAULT_FNAME
Name of the default setup file with extension (no path).- See Also:
-
DEFAULT_OVERRIDE_FNAME
Name of the default setup override file with extension (no path).- See Also:
-
defaultFName
-
pluginsFolder
-
-
Constructor Details
-
AbstractSetup
public AbstractSetup()
-
-
Method Details
-
getDefaultFileName
Returns the default file name used for loading.- Returns:
- the default file name, by default
DEFAULT_FNAME
-
setDefaultFileName
Sets the default file name used for loading, by defaultDEFAULT_FNAME. [testing]- Parameters:
name- the new default filename- Returns:
- the default filename before
-
setPluginsFolder
Changes the (parent) folder where the oktoflow plugins are located. [yaml convention]- Parameters:
pluginsFolder- the plugins folder
-
setPluginsFolderFile
Changes the (parent) folder where the oktoflow plugins are located. [yaml convention]- Parameters:
pluginsFolder- the plugins folder
-
getPluginsFolder
Returns the (parent) folder where the oktoflow plugins are located (the folder itself or by default its sub-folders "plugins" or "oktoPlugins").- Returns:
- the folder, by default taken from
PARAM_PLUGINS(env or sys property), fallback "plugins"
-
readFromYaml
Reads a configuration fromgetDefaultFileName()in the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to read- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readFromYamlWithPath
Reads a configuration fromgetDefaultFileName()in the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readyamlPath- path within yaml to read from, may be null or empty for none- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readFromYaml
Reads a configuration from the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readfilename- the filename (a leading "/" is added if missing for JAR/classpath resource access)- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readFromYamlWithPath
public static <C> C readFromYamlWithPath(Class<C> cls, String yamlPath, String filename) throws IOException Reads a configuration from the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readyamlPath- path within yaml to read from, may be null or empty for nonefilename- the filename (a leading "/" is added if missing for JAR/classpath resource access)- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readFromYaml
public static <C> C readFromYaml(Class<C> cls, String filename, String overwrite) throws IOException Reads a configuration from the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readfilename- the filename (a leading "/" is added if missing for JAR/classpath resource access)overwrite- the name of an optional file (a leading "/" is added if missing for JAR/classpath resource access, usingMultiResourceResolver.SETUP_RESOLVER) overwriting values infilename, may be null for none, does not lead to an exception if file does not exist- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readFromYamlWithPath
public static <C> C readFromYamlWithPath(Class<C> cls, String yamlPath, String filename, String overwrite) throws IOException Reads a configuration from the root folder of the JAR/classpath. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readyamlPath- path within yaml to read from, may be null or empty for nonefilename- the filename (a leading "/" is added if missing for JAR/classpath resource access)overwrite- the name of an optional file (a leading "/" is added if missing for JAR/classpath resource access, usingMultiResourceResolver.SETUP_RESOLVER) overwriting values infilename, may be null for none, does not lead to an exception if file does not exist- Returns:
- the configuration instance
- Throws:
IOException- if the file cannot be read/found, the configuration class cannot be instantiated
-
readMappingFromYaml
Reads a configuration from the root folder of the JAR/classpath as mapping.- Returns:
- the setup mapping
- Throws:
IOException- if the file cannot be read/found
-
readMappingFromYaml
Reads a configuration from the root folder of the JAR/classpath as mapping.- Parameters:
filename- the filename to read from- Returns:
- the setup mapping
- Throws:
IOException- if the file cannot be read/found
-
isNotEmpty
Returns if a string is valid, i.e. not null and not empty.- Parameters:
str- the string- Returns:
truefor valid and not empty,falseelse
-
readFromYaml
Reads a instance fromin. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readin- the stream to read from (ignored if null, else being closed)- Returns:
- the configuration instance
- Throws:
IOException- if the data cannot be read, the configuration class cannot be instantiated
-
readFromYaml
public static <C> C readFromYaml(Class<C> cls, InputStream in, InputStream overwrite) throws IOException Reads a instance fromin. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readin- the stream to read from (ignored if null, else being closed)overwrite- optional stream to overwrite values taken fromin- Returns:
- the configuration instance
- Throws:
IOException- if the data cannot be read, the configuration class cannot be instantiated
-
readFromYamlWithPath
public static <C> C readFromYamlWithPath(Class<C> cls, String yamlPath, InputStream in, InputStream overwrite) throws IOException Reads a instance fromin. Unknown properties are ignored.- Type Parameters:
C- the specific type of configuration to read- Parameters:
cls- the class of configuration to readyamlPath- path within yaml to read from, may be null or empty for nonein- the stream to read from (ignored if null, else being closed)overwrite- optional stream to overwrite values taken fromin- Returns:
- the configuration instance
- Throws:
IOException- if the data cannot be read, the configuration class cannot be instantiated
-