Class JdbcFeature
java.lang.Object
io.micronaut.starter.feature.database.jdbc.JdbcFeature
- All Implemented Interfaces:
io.micronaut.core.naming.Described
,io.micronaut.core.naming.Named
,io.micronaut.core.order.Ordered
,Feature
,OneOfFeature
,DatabaseDriverConfigurationFeature
public abstract class JdbcFeature
extends Object
implements OneOfFeature, DatabaseDriverConfigurationFeature
Abstract base feature for JDBC-related functionality.
This class provides common configuration keys and behavior for JDBC connection setup, including default database driver selection, configuration property keys, and integration with supported database types.
-
Field Summary
FieldsFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDatabaseConfigRecipe
(GeneratorContext generatorContext, List<String> recipes) Adds a database configuration recipe to the list of recipes based on the features present in the GeneratorContext.Returns the configuration property key for the database driver class name.Class<?>
int
getOrder()
The order of a feature controls the order in which it applies.Returns the configuration property key for the database password.Returns the configuration property key for the database connection URL.Returns the configuration property key for the database username.void
processSelectedFeatures
(FeatureContext featureContext) If this method is called for a given feature then that feature was explicitly selected or was included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set)
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.starter.feature.database.DatabaseDriverConfigurationFeature
applyDefaultConfig
Methods inherited from interface io.micronaut.core.naming.Described
getDescription
Methods inherited from interface io.micronaut.projectgen.core.feature.Feature
apply, getDescription, getFrameworkDocumentation, getName, getThirdPartyDocumentation, getTitle, isCommunity, isPreview, isVisible, supports
-
Field Details
-
PROPERTY_DATASOURCES_DEFAULT_DB_TYPE
- See Also:
-
-
Constructor Details
-
JdbcFeature
-
-
Method Details
-
getOrder
public int getOrder()Description copied from interface:Feature
The order of a feature controls the order in which it applies. The order of a feature is important to ensure that any previous work done by other features that may be required is done. SeeFeaturePhase
for a list of phases to choose from. -
getFeatureClass
- Specified by:
getFeatureClass
in interfaceOneOfFeature
-
processSelectedFeatures
Description copied from interface:Feature
If this method is called for a given feature then that feature was explicitly selected or was included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set)
. This method can be implemented to allow features to modify the list of features that will apply to the project. The methodsFeatureContext.addFeature(Feature)
andFeatureContext.exclude(FeaturePredicate)
are the primary ways to add and remove features from the context.FeatureContext.isPresent(Class)
can be used to determine the existence of other features in order to make decisions.- Specified by:
processSelectedFeatures
in interfaceFeature
- Parameters:
featureContext
- The feature context
-
getCategory
- Specified by:
getCategory
in interfaceFeature
- Returns:
- The Category to which the feature belongs to.
-
getUrlKey
Description copied from interface:DatabaseDriverConfigurationFeature
Returns the configuration property key for the database connection URL.- Specified by:
getUrlKey
in interfaceDatabaseDriverConfigurationFeature
- Returns:
- the URL configuration key
-
getDriverKey
Description copied from interface:DatabaseDriverConfigurationFeature
Returns the configuration property key for the database driver class name.- Specified by:
getDriverKey
in interfaceDatabaseDriverConfigurationFeature
- Returns:
- the driver class name configuration key
-
getUsernameKey
Description copied from interface:DatabaseDriverConfigurationFeature
Returns the configuration property key for the database username.- Specified by:
getUsernameKey
in interfaceDatabaseDriverConfigurationFeature
- Returns:
- the username configuration key
-
getPasswordKey
Description copied from interface:DatabaseDriverConfigurationFeature
Returns the configuration property key for the database password.- Specified by:
getPasswordKey
in interfaceDatabaseDriverConfigurationFeature
- Returns:
- the password configuration key
-
addDatabaseConfigRecipe
Adds a database configuration recipe to the list of recipes based on the features present in the GeneratorContext.The method checks for the presence of specific database features (e.g., PostgreSQL, MySQL, MariaDB, SQLServer, Oracle) in the GeneratorContext and adds the corresponding JDBC configuration recipe to the list. If none of the specific database features are present, it defaults to adding the H2 JDBC configuration recipe.
- Parameters:
generatorContext
- the context of the project generation, used to check for the presence of specific database featuresrecipes
- the list of recipes to which the database configuration recipe will be added
-