org.apache.tapestry5.internal.services

## Class MessagesSourceImpl

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

- All Implemented Interfaces:
    MessagesSource, InvalidationEventHub, UpdateListener

      public class MessagesSourceImpl
      extends InvalidationEventHubImpl
      implements MessagesSource

  A utility class that encapsulates all the logic for reading properties files and assembling `Messages` from them, in accordance with extension rules and locale. This represents code that was refactored out of `ComponentMessagesSourceImpl`. This class can be used as a base class, though the existing code base uses it as a utility. Composition trumps inheritance! The message catalog for a component is the combination of all appropriate properties files for the component, plus any keys inherited form base components and, ultimately, the application global message catalog. At some point we should add support for per-library message catalogs. Message catalogs are read using the UTF-8 character set. This is tricky in JDK 1.5; we read the file into memory then feed that bytestream to Properties.load().

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessagesSourceImpl(boolean productionMode, URLChangeTracker tracker, ComponentResourceLocator resourceLocator, PropertiesFileParser propertiesFileParser)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkForUpdates()` Invoked to force the receiver to check for updates to whatever underlying resources it makes use of.
    `Messages` | `getMessages(MessagesBundle bundle, ComponentResourceSelector selector)` Used to obtain a `Messages` instance for a particular component, within a particular locale.
    `void` | `invalidate()`

    - ### 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`

    - ### Methods inherited from interface org.apache.tapestry5.services.InvalidationEventHub

      `addInvalidationCallback, addInvalidationListener, clearOnInvalidation`

- - ### Constructor Detail

    - #### MessagesSourceImpl

          public MessagesSourceImpl(boolean productionMode,
                                    URLChangeTracker tracker,
                                    ComponentResourceLocator resourceLocator,
                                    PropertiesFileParser propertiesFileParser)

  - ### Method Detail

    - #### checkForUpdates

          public void checkForUpdates()

      Description copied from interface: `UpdateListener`
      Invoked to force the receiver to check for updates to whatever underlying resources it makes use of.
      Specified by:
        `checkForUpdates` in interface `UpdateListener`

    - #### invalidate

          public void invalidate()

    - #### getMessages

          public Messages getMessages(MessagesBundle bundle,
                                      ComponentResourceSelector selector)

      Description copied from interface: `MessagesSource`
      Used to obtain a `Messages` instance for a particular component, within a particular locale. If the component extends from another component, then its localized properties will merge with its parent's properties (with the subclass overriding the super class on any conflicts).
      Specified by:
        `getMessages` in interface `MessagesSource`
      Parameters:
        `bundle` - defines the set of properties files to read, as well as a series of parent bundles to extend and override
        `selector` - defines the locale and other axes used to locate the necessary resources
      Returns:
        the message catalog for the bundle, for the indicated selector

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