org.apache.tapestry5.internal.services

## Class ComponentTemplateSourceImpl

- java.lang.Object
- - org.apache.tapestry5.internal.event.InvalidationEventHubImpl
  - - org.apache.tapestry5.internal.services.ComponentTemplateSourceImpl

- All Implemented Interfaces:
    ComponentTemplateSource, InvalidationEventHub, UpdateListener

      public final class ComponentTemplateSourceImpl
      extends InvalidationEventHubImpl
      implements ComponentTemplateSource, UpdateListener

  Service implementation that manages a cache of parsed component templates.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ComponentTemplateSourceImpl(boolean productionMode, TemplateParser parser, ComponentResourceLocator locator, ClasspathURLConverter classpathURLConverter)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkForUpdates()` Checks to see if any parsed resource has changed.
    `InvalidationEventHub` | `getInvalidationEventHub()` Event hub used to notify listeners that underlying component template files have changed.
    `ComponentTemplate` | `getTemplate(ComponentModel componentModel, ComponentResourceSelector selector)` Provides access to a template.
    `ComponentTemplate` | `getTemplate(ComponentModel componentModel, Locale locale)` Resolves the component name to a localized `Resource` (using the `ComponentTemplateLocator` chain of command service).
    `void` | `registerAsUpdateListener(UpdateListenerHub hub)`
    `void` | `setupReload(ReloadHelper helper)`

    - ### Methods inherited from class org.apache.tapestry5.internal.event.InvalidationEventHubImpl

      `addInvalidationCallback, addInvalidationListener, clearOnInvalidation, fireInvalidationEvent`

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

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

- - ### Constructor Detail

    - #### ComponentTemplateSourceImpl

          public ComponentTemplateSourceImpl(@Inject @Symbol(value="tapestry.production-mode")
                                             boolean productionMode,
                                             TemplateParser parser,
                                             ComponentResourceLocator locator,
                                             ClasspathURLConverter classpathURLConverter)

  - ### Method Detail

    - #### registerAsUpdateListener

          @PostInjection
          public void registerAsUpdateListener(UpdateListenerHub hub)

    - #### setupReload

          @PostInjection
          public void setupReload(ReloadHelper helper)

    - #### getTemplate

          public ComponentTemplate getTemplate(ComponentModel componentModel,
                                               ComponentResourceSelector selector)

      Description copied from interface: `ComponentTemplateSource`
      Provides access to a template. The template will be parsed as necessary. If no template for the exact component is found, then the template for the component's parent is returned. In this way, it is possible for a component to extend the behavior of its super-class without duplicating the super-class component's template. In some cases, the empty template will be returned.
      Specified by:
        `getTemplate` in interface `ComponentTemplateSource`
      Parameters:
        `componentModel` - model for the component whose template is to be accessed
        `selector` - defines locale and other information needed to locate template
      Returns:
        the cached template instance

    - #### getTemplate

          public ComponentTemplate getTemplate(ComponentModel componentModel,
                                               Locale locale)

      Resolves the component name to a localized `Resource` (using the `ComponentTemplateLocator` chain of command service). The localized resource is used as the key to a cache of `ComponentTemplate`s. If a template doesn't exist, then the missing ComponentTemplate is returned.

    - #### checkForUpdates

          public void checkForUpdates()

      Checks to see if any parsed resource has changed. If so, then all internal caches are cleared, and an invalidation event is fired. This is brute force ... a more targeted dependency management strategy may come later.
      Specified by:
        `checkForUpdates` in interface `UpdateListener`

    - #### getInvalidationEventHub

          public InvalidationEventHub getInvalidationEventHub()

      Description copied from interface: `ComponentTemplateSource`
      Event hub used to notify listeners that underlying component template files have changed.
      Specified by:
        `getInvalidationEventHub` in interface `ComponentTemplateSource`
      See Also:
        `ComponentTemplates`

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.