Interface ComponentClassResolver

  • All Known Implementing Classes:
    ComponentClassResolverImpl

    @UsesConfiguration(LibraryMapping.class)
    public interface ComponentClassResolver
    Resolves page names and component types to fully qualified class names. Pages and components may be provided by the application or inside a mapped package. Page names often appear inside URLs, and component types often appear in component templates (when specifying the type of an embedded component). The service is configured using a collection of LibraryMappings. Each mapping maps a prefix, such as "core" to a root package name, such as "org.apache.tapestry5.corelib". The root package is expected to have sub-packages: "pages", "components", "mixins" and "base" ("base" is for base classes). The resolver performs a search of the classpath (via ClassNameLocator), to build up a set of case-insensitive maps from logical page name, component type, or mixin type to fully qualified class name. Certain ambiguities occur if mapped packages overlap, either in terms of the the prefixes or the package names. Keep things clearly separate to avoid lookup problems.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String canonicalizePageName​(java.lang.String pageName)
      Returns the canonical form of a page name.
      java.lang.String getClassName​(java.lang.String logicalName)
      Returns the class name for a page, component or class given its logical name.
      java.util.List<java.lang.String> getComponentNames()
      Returns a list of all component names, in sorted order.
      java.util.Map<java.lang.String,​ControlledPackageType> getControlledPackageMapping()
      Used to identify which packages are controlled packages (from which components are loaded).
      java.util.Map<java.lang.String,​java.lang.String> getFolderToPackageMapping()
      A mapping from virtual folder name to a package name (used for converting classpath Assets to client URLs).
      java.util.Collection<LibraryMapping> getLibraryMappings()
      Returns the library mappings.
      java.lang.String getLibraryNameForClass​(java.lang.String className)
      Given a class name of a component class, returns the library name (as defined by a contributed library name).
      java.util.List<java.lang.String> getLibraryNames()
      Returns the names of all libraries (as configured).
      java.lang.String getLogicalName​(java.lang.String className)
      Returns the logical name for a page, component or mixin fully classified class name.
      java.util.List<java.lang.String> getMixinNames()
      Returns a list of all mixin names, in sorted order.
      java.util.List<java.lang.String> getPageNames()
      Returns a list of all page names, in sorted order.
      boolean isPage​(java.lang.String pageClassName)
      Returns true if the class name is specifically a page class, and not a component, mixin or base class.
      boolean isPageName​(java.lang.String pageName)
      For a particular path, determines if the path is a logical page name.
      java.lang.String resolveComponentTypeToClassName​(java.lang.String componentType)
      Converts a component type (a logical component name such as might be used inside a template or annotation) into a fully qualified class name.
      java.lang.String resolveMixinTypeToClassName​(java.lang.String mixinType)
      Converts a logical mixin type (as with component types) into a fully qualified class name.
      java.lang.String resolvePageClassNameToPageName​(java.lang.String pageClassName)
      Converts a fully qualified page class name into a page name (often, for inclusion as part of the URI).
      java.lang.String resolvePageNameToClassName​(java.lang.String pageName)
      Converts a logical page name (such as might be encoded into a URL) into a fully qualified class name.
    • Method Detail

      • resolvePageNameToClassName

        java.lang.String resolvePageNameToClassName​(java.lang.String pageName)
        Converts a logical page name (such as might be encoded into a URL) into a fully qualified class name. The case of the page name is irrelevant.
        Parameters:
        pageName - page name
        Returns:
        fully qualified class name for the page
        Throws:
        UnknownValueException - if the name does not match a known page class
      • isPageName

        boolean isPageName​(java.lang.String pageName)
        For a particular path, determines if the path is a logical page name. The check is case insensitive.
        Parameters:
        pageName - potential logical page name
        Returns:
        true if the page name is valid
      • getPageNames

        java.util.List<java.lang.String> getPageNames()
        Returns a list of all page names, in sorted order. These are the "canonical" page names.
      • resolvePageClassNameToPageName

        java.lang.String resolvePageClassNameToPageName​(java.lang.String pageClassName)
        Converts a fully qualified page class name into a page name (often, for inclusion as part of the URI). This value may later be passed to resolvePageNameToClassName(String).
        Parameters:
        pageClassName - fully qualified name of a page class
        Returns:
        equivalent logical page name
        Throws:
        java.lang.IllegalArgumentException - if the name can not be resolved
      • canonicalizePageName

        java.lang.String canonicalizePageName​(java.lang.String pageName)
        Returns the canonical form of a page name. The canonical form uses character case matching the underlying class name.
        Throws:
        UnknownValueException - if the page name does not match a logical page name
      • resolveComponentTypeToClassName

        java.lang.String resolveComponentTypeToClassName​(java.lang.String componentType)
        Converts a component type (a logical component name such as might be used inside a template or annotation) into a fully qualified class name. Case is ignored in resolving the name.
        Parameters:
        componentType - a logical component type
        Returns:
        fully qualified class name
        Throws:
        UnknownValueException - if the component type can not be resolved
      • resolveMixinTypeToClassName

        java.lang.String resolveMixinTypeToClassName​(java.lang.String mixinType)
        Converts a logical mixin type (as with component types) into a fully qualified class name. Case is ignored when resolving the name.
        Parameters:
        mixinType - a logical mixin type
        Returns:
        fully qualified class name
        Throws:
        UnknownValueException - if the mixin type can not be resolved
      • getFolderToPackageMapping

        java.util.Map<java.lang.String,​java.lang.String> getFolderToPackageMapping()
        A mapping from virtual folder name to a package name (used for converting classpath Assets to client URLs). This is derived from the contributed LibraryMappings. It is allowed to contribute multiple root packages as a single folder name. In this case, the best common package name is used. For example, if both com.example.main and com.example.extras is mapped to folder "example", then the package mapping for "example" will be com.example.
        Since:
        5.2.0
        See Also:
        ClasspathAssetAliasManager
      • getLibraryNames

        java.util.List<java.lang.String> getLibraryNames()
        Returns the names of all libraries (as configured). This does not include the application itself (which is a library with the virtual path of empty string).
        Returns:
        sorted names of libraries
        Since:
        5.4
      • getControlledPackageMapping

        java.util.Map<java.lang.String,​ControlledPackageTypegetControlledPackageMapping()
        Used to identify which packages are controlled packages (from which components are loaded). Future expansion may allow for additional packages which are live reloaded but not components (or perhaps are transformed, but not as components).
        Returns:
        a mapping from package name to ControlledPackageType.
        Since:
        5.3
      • isPage

        boolean isPage​(java.lang.String pageClassName)
        Returns true if the class name is specifically a page class, and not a component, mixin or base class.
        Parameters:
        pageClassName -
        Returns:
        true if a page class
        Since:
        5.3
      • getLibraryNameForClass

        java.lang.String getLibraryNameForClass​(java.lang.String className)
        Given a class name of a component class, returns the library name (as defined by a contributed library name).
        Parameters:
        className -
        Returns:
        library name
        Throws:
        java.lang.IllegalArgumentException - if the class can't be matched to a contributed root package