org.apache.struts2.convention

## Class ConventionsServiceImpl

- java.lang.Object
- - org.apache.struts2.convention.ConventionsServiceImpl

- All Implemented Interfaces:
    ConventionsService

      public class ConventionsServiceImpl
      extends Object
      implements ConventionsService

  This class is the implementation of the `ConventionsService` interface and provides all of the defaults and annotation handling.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConventionsServiceImpl(String resultPath)` Constructs a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `determineResultPath(ActionConfig actionConfig)` Delegates to the other method but first looks up the Action's class using the given class name.
    `String` | `determineResultPath(Class<?> actionClass)` Locates the result location from annotations on the action class or the package or returns the default if no annotations are present.
    `Map<String,ResultTypeConfig>` | `getResultTypesByExtension(PackageConfig packageConfig)` Returns a mapping between the result type strings and the `ResultTypeConfig` instances based on the `PackageConfig` given.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ConventionsServiceImpl

          public ConventionsServiceImpl(String resultPath)

      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 Detail

    - #### determineResultPath

          public String determineResultPath(Class<?> actionClass)

      Locates the result location from annotations on the action class or the package or returns the default if no annotations are present.
      Specified by:
        `determineResultPath` in interface `ConventionsService`
      Parameters:
        `actionClass` - The action class.
      Returns:
        The result location if it is set in the annotations. Otherwise, the default result location is returned.

    - #### determineResultPath

          public String determineResultPath(ActionConfig actionConfig)

      Delegates to the other method but first looks up the Action's class using the given class name.
      Specified by:
        `determineResultPath` in interface `ConventionsService`
      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,

    - #### getResultTypesByExtension

          public Map<String,ResultTypeConfig> getResultTypesByExtension(PackageConfig packageConfig)

      Returns a mapping between the result type strings and the `ResultTypeConfig` instances based on the `PackageConfig` given.
      Specified by:
        `getResultTypesByExtension` in interface `ConventionsService`
      Parameters:
        `packageConfig` - The PackageConfig to get the result types for.
      Returns:
        The result types or an empty Map of nothing is configured.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.