Class JavaApplication
java.lang.Object
io.micronaut.starter.feature.lang.java.JavaApplication
- All Implemented Interfaces:
io.micronaut.core.naming.Described,io.micronaut.core.naming.Named,io.micronaut.core.order.Ordered,ApplicationFeature,Feature,JavaApplicationFeature
@Requires(property="micronaut.starter.feature.java.application.enabled",
value="true",
defaultValue="true")
@Singleton
public class JavaApplication
extends Object
implements JavaApplicationFeature
Represents the Java application feature that can be applied during project generation.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddApplication(GeneratorContext generatorContext, ModuleContext module) Adds the application template to the given ModuleContext.protected voidaddApplicationTest(GeneratorContext generatorContext, ModuleContext module) Adds an application test template to the given ModuleContext.protected com.fizzed.rocker.RockerModelapplication(GeneratorContext generatorContext, ModuleContext module) Generates the RockerModel for the application template based on the provided GeneratorContext and ModuleContext.protected com.fizzed.rocker.RockerModelapplicationTest(GeneratorContext generatorContext) Generates the RockerModel for the application test template based on the provided GeneratorContext.voidapply(GeneratorContext generatorContext) If this method is called for a given feature that means the feature was explicitly selected, included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set), or added explicitly by another feature throughFeatureContext.addFeature(Feature).getName()The name of the feature.protected StringgetPath()Returns the path where the application Java file will be generated.@Nullable StringmainClassName(GeneratorContext generatorContext) protected booleanshouldGenerateApplicationFile(GeneratorContext generatorContext) Determines whether an application file should be generated based on the provided GeneratorContext.booleanThis method must be implemented to ensure it is only selectable for the desired application types.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.projectgen.core.feature.ApplicationFeature
isVisibleMethods inherited from interface io.micronaut.core.naming.Described
getDescriptionMethods inherited from interface io.micronaut.projectgen.core.feature.Feature
getCategory, getDescription, getFrameworkDocumentation, getThirdPartyDocumentation, getTitle, isCommunity, isPreview, processSelectedFeaturesMethods inherited from interface io.micronaut.projectgen.core.feature.JavaApplicationFeature
getOrder
-
Constructor Details
-
JavaApplication
-
-
Method Details
-
mainClassName
- Specified by:
mainClassNamein interfaceApplicationFeature
-
getName
Description copied from interface:FeatureThe name of the feature. It must be unique. -
supports
Description copied from interface:FeatureThis method must be implemented to ensure it is only selectable for the desired application types. This method is not used for determining if a default feature should be applied. -
apply
Description copied from interface:FeatureIf this method is called for a given feature that means the feature was explicitly selected, included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set), or added explicitly by another feature throughFeatureContext.addFeature(Feature). At this point the feature list is set and cannot change.- Specified by:
applyin interfaceApplicationFeature- Specified by:
applyin interfaceFeature- Parameters:
generatorContext- THe generator context
-
shouldGenerateApplicationFile
Determines whether an application file should be generated based on the provided GeneratorContext. The decision is made based on the application type and the presence of the FunctionFeature.- Parameters:
generatorContext- the context used to generate the project- Returns:
- true if an application file should be generated, false otherwise
-
addApplication
Adds the application template to the given ModuleContext. The application template is generated based on the provided GeneratorContext and ModuleContext. The template is added with the name "application" and is located at the path specified by the getPath() method.- Parameters:
generatorContext- the context used to generate the projectmodule- the module context to which the application template is added
-
application
protected com.fizzed.rocker.RockerModel application(GeneratorContext generatorContext, ModuleContext module) Generates the RockerModel for the application template based on the provided GeneratorContext and ModuleContext. The RockerModel is generated using the application template, passing in the project, features, JavaApplicationRenderingContext, and whether the Slf4jJulBridge feature is present. The JavaApplicationRenderingContext is constructed with the default environment and whether eager initialization of singletons is required.- Parameters:
generatorContext- the context used to generate the projectmodule- the module context used to determine the default environment- Returns:
- the RockerModel for the application template
-
addApplicationTest
Adds an application test template to the given ModuleContext. The application test template is generated based on the provided GeneratorContext. The template is added with the name "applicationTest" and is located at the path specified by the getTestSourcePath() method of the GeneratorContext.- Parameters:
generatorContext- the context used to generate the projectmodule- the module context to which the application test template is added
-
applicationTest
Generates the RockerModel for the application test template based on the provided GeneratorContext. The RockerModel is generated using a TestRockerModelProvider, which is constructed with various test templates. The test framework and project are retrieved from the GeneratorContext, and the transactional flag is determined based on the presence of the TransactionalNotSupported feature. The TestRockerModelProvider is then used to find the appropriate RockerModel based on the language and test framework.- Parameters:
generatorContext- the context used to generate the project- Returns:
- the RockerModel for the application test template
-
getPath
Returns the path where the application Java file will be generated. The path is in the format "src/main/java/{packagePath}/Application.java", where {packagePath} is a placeholder that will be replaced with the actual package path during template rendering.- Returns:
- the path to the application Java file
-