- java.lang.Object
-
- com.github.zhgzhg.tinydi.TinyDI.Config
-
- Enclosing class:
- TinyDI
public static class TinyDI.Config extends java.lang.ObjectTinyDI's configuration helper.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TinyDI.ConfigaggressiveEncapsulationCircumventing(boolean useEncapsulationCircumventing)Activates more aggressive encapsulation circumventing for Java version 16 or later.TinyDI.ConfigbasePackages(java.lang.String... basePackages)Specifies 1 or more fully-qualified base packages for recursive scanning.TinyDIconfigure()Locks TinyDI's configuration and returns the configured instance.java.lang.StringconfigureForStaticScan()Configures wrappedTinyDIinstance for the only purpose of producing static JSON result of the scanned class path and the found elements suitable for DI.TinyDI.ConfigignoredBasePackages(java.lang.String... ignoredBasePackages)Specifies 1 or more fully-qualified base packages to be excluded during recursive scanning.TinyDI.ConfigignoredClasses(java.lang.String... ignoredClasses)Specifies 1 or more fully-qualified classes to be excluded during recursive scanning.TinyDI.ConfigoverrideClasspath(java.lang.String... overridingClasspaths)Specifies 1 or more fully-qualified classpaths to be used during recursive scanning.TinyDI.Configrecords(Recorded... records)Includes arbitrary, unannotated object instances for injection.TinyDI.ConfigstaticScan(@NonNull java.io.InputStream jsonSource, @NonNull java.lang.String encoding)Specifies static, serialized in JSON format classpath scan to be used during the DI processTinyDI.ConfigstaticScan(@NonNull java.lang.String json)Specifies static, serialized in JSON format classpath scan to be used during the DI process.TinyDI.ConfigwithEnvironment(java.lang.String[] args, java.util.Map<java.lang.String,java.lang.String> environmentVars, java.util.Properties envProps)Registers custom command line arguments, environment parameters, and properties entirely substituting the detected.
-
-
-
Method Detail
-
staticScan
public TinyDI.Config staticScan(@NonNull @NonNull java.io.InputStream jsonSource, @NonNull @NonNull java.lang.String encoding)
Specifies static, serialized in JSON format classpath scan to be used during the DI process- Parameters:
jsonSource- Valid JSON file resource containing the serialized classpath scan result.encoding- The charset encoding of the JSON. SeeStandardCharsets.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
staticScan
public TinyDI.Config staticScan(@NonNull @NonNull java.lang.String json)
Specifies static, serialized in JSON format classpath scan to be used during the DI process.- Parameters:
json- A JSON string with the serialized classpath scan result.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
records
public TinyDI.Config records(Recorded... records)
Includes arbitrary, unannotated object instances for injection. They have to be bound dynamically with @Recordedannotation though. To accomplish that seeTinyDynamicDI.- Parameters:
records- One or more records to add.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
basePackages
public TinyDI.Config basePackages(java.lang.String... basePackages)
Specifies 1 or more fully-qualified base packages for recursive scanning. Real JVM bytecode must be present.- Parameters:
basePackages- One or more fully-qualified base package names.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
ignoredBasePackages
public TinyDI.Config ignoredBasePackages(java.lang.String... ignoredBasePackages)
Specifies 1 or more fully-qualified base packages to be excluded during recursive scanning. Real JVM bytecode must be present.- Parameters:
ignoredBasePackages- One or more fully-qualified base package names.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
ignoredClasses
public TinyDI.Config ignoredClasses(java.lang.String... ignoredClasses)
Specifies 1 or more fully-qualified classes to be excluded during recursive scanning. Real JVM bytecode must be present.- Parameters:
ignoredClasses- One or more fully-qualified class names.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
overrideClasspath
public TinyDI.Config overrideClasspath(java.lang.String... overridingClasspaths)
Specifies 1 or more fully-qualified classpaths to be used during recursive scanning. They override the automatically detected classpath. The module path won't be scanned in this case.- Parameters:
overridingClasspaths- One or more fully-qualified class paths.- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
withEnvironment
public TinyDI.Config withEnvironment(java.lang.String[] args, java.util.Map<java.lang.String,java.lang.String> environmentVars, java.util.Properties envProps)
Registers custom command line arguments, environment parameters, and properties entirely substituting the detected.- Parameters:
args- Command line arguments. By default an empty array.environmentVars- Environment variables. By default obtained via System.getenv().envProps- Environment properties. By default obtained via System.getProperties().- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
aggressiveEncapsulationCircumventing
public TinyDI.Config aggressiveEncapsulationCircumventing(boolean useEncapsulationCircumventing)
Activates more aggressive encapsulation circumventing for Java version 16 or later. The hack relies on additional libraries which must be manually added as a dependency - either Narcissus or ToolFactory JVM Driver.- Parameters:
useEncapsulationCircumventing- Set to true to activate the aggressive hack, and use false to deactivate it- Returns:
- The belonging instance for fluent config.
- Throws:
java.lang.IllegalArgumentException- Ifconfigure()has been called previously.
-
configure
public TinyDI configure()
Locks TinyDI's configuration and returns the configured instance.- Returns:
- Configured
TinyDIinstance.
-
configureForStaticScan
public java.lang.String configureForStaticScan()
Configures wrappedTinyDIinstance for the only purpose of producing static JSON result of the scanned class path and the found elements suitable for DI. Can be used to gather the needed for DI information during the build time which can speed up the execution and allow TinyDI to work on environments with limited reflection capabilities like Android and GraalVM native images. See com.github.zhgzhg.tinydi.build.BuildTimeScan utility for more information.- Returns:
- JSON string with the found elements of interest
-
-