Package org.apache.struts2.convention
Class ConventionsServiceImpl
java.lang.Object
org.apache.struts2.convention.ConventionsServiceImpl
- All Implemented Interfaces:
ConventionsService
This class is the implementation of the ConventionsService
interface and provides all of the defaults and annotation handling.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetermineResultPath(Class<?> actionClass) Locates the result location from annotations on the action class or the package or returns the default if no annotations are present.determineResultPath(Class<?> actionClass, PackageConfig packageConfig) Locates the result location likeConventionsService.determineResultPath(Class), using the package's scopedstruts.convention.result.pathwhen the action carries no@ResultPath.determineResultPath(ActionConfig actionConfig) Delegates to the other method but first looks up the Action's class using the given class name.determineResultPath(ActionConfig actionConfig, PackageConfig packageConfig) Locates the result location likeConventionsService.determineResultPath(ActionConfig), using the package's scopedstruts.convention.result.pathwhen the action carries no@ResultPath.getResultTypesByExtension(PackageConfig packageConfig) Returns a mapping between the result type strings and theResultTypeConfiginstances based on thePackageConfiggiven.voidsetScopedConstantProvider(ScopedConstantProvider scopedConstantProvider)
-
Constructor Details
-
ConventionsServiceImpl
Constructs a new instance.- Parameters:
resultPath- The result path that is configured in the Struts configuration files using the constant name of struts.convention.result.path.
-
-
Method Details
-
setScopedConstantProvider
-
determineResultPath
Locates the result location from annotations on the action class or the package or returns the default if no annotations are present.- Specified by:
determineResultPathin interfaceConventionsService- Parameters:
actionClass- The action class.- Returns:
- The result location if it is set in the annotations. Otherwise, the default result location is returned.
-
determineResultPath
Locates the result location likeConventionsService.determineResultPath(Class), using the package's scopedstruts.convention.result.pathwhen the action carries no@ResultPath.- Specified by:
determineResultPathin interfaceConventionsService- Parameters:
actionClass- The action class.packageConfig- The package the action belongs to, or null for the global default.- Returns:
- The result location.
-
determineResultPath
Delegates to the other method but first looks up the Action's class using the given class name.- Specified by:
determineResultPathin interfaceConventionsService- Parameters:
actionConfig- (Optional) The configuration for the action that the result is being built for or null if the default result path is needed.- Returns:
- The result location if it is set in the annotations for the class of the ActionConfig. Otherwise, the default result location is returned. If null is passed in, the default is returned,
-
determineResultPath
Locates the result location likeConventionsService.determineResultPath(ActionConfig), using the package's scopedstruts.convention.result.pathwhen the action carries no@ResultPath.- Specified by:
determineResultPathin interfaceConventionsService- Parameters:
actionConfig- (Optional) The configuration for the action, or null when there is no action.packageConfig- The package whose scoped value applies, or null for the global default.- Returns:
- The result location.
-
getResultTypesByExtension
Returns a mapping between the result type strings and theResultTypeConfiginstances based on thePackageConfiggiven.- Specified by:
getResultTypesByExtensionin interfaceConventionsService- Parameters:
packageConfig- The PackageConfig to get the result types for.- Returns:
- The result types or an empty Map of nothing is configured.
-