Class LocaleMessageProviderRegistry

java.lang.Object
com.isomorphic.util.LocaleMessageProviderRegistry

public class LocaleMessageProviderRegistry extends Object
Allows to register custom LocaleMessageProvider. Framework will look up for registered custom provider and use it to get i18n message when parsing XML sources.

Providers can be registered (added) just for data sources and/or for any other XML source. Providers may be configured for all sources or for sources with specific prefix or which names match the regex specified during provider registration. Note that the provider implementation is not controlled, so it completely valid to use same instance for different look up configurations.

Providers can be unregistered (removed) using the ID that is returned when provider was registered. Each add method returns an unique ID which later may be used to remove that specific provider. Note that removing provider by unique ID will remove only that specific provider which when added returned this ID.

When framework is looking up for provider it will pick up first provider matching configuration according to the look up order (see below) and providers registration order.

Look up order for data source:

Look up order for any other source:
  • Method Details

    • addLocaleMessageProvider

      public static int addLocaleMessageProvider(LocaleMessageProvider lmp)
      Registers LocaleMessageProvider for all sources.
      Parameters:
      lmp - provider to register
      Returns:
      unique ID
    • addLocaleMessageProvider

      public static int addLocaleMessageProvider(LocaleMessageProvider lmp, String prefix)
      Registers LocaleMessageProvider for sources which names start with prefix.
      Parameters:
      lmp - provider to register
      prefix - prefix to use
      Returns:
      unique ID
    • addLocaleMessageProvider

      public static int addLocaleMessageProvider(LocaleMessageProvider lmp, Pattern regex)
      Registers LocaleMessageProvider for sources which names match the regex.
      Parameters:
      lmp - provider to register
      regex - regex to match
      Returns:
      unique ID
    • addDSLocaleMessageProvider

      public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp)
      Registers LocaleMessageProvider for all data sources.
      Parameters:
      lmp - provider to register
      Returns:
      unique ID
    • addDSLocaleMessageProvider

      public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp, String prefix)
      Registers LocaleMessageProvider for data sources which names start with prefix.
      Parameters:
      lmp - provider to register
      prefix - prefix to use
      Returns:
      unique ID
    • addDSLocaleMessageProvider

      public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp, Pattern regex)
      Registers LocaleMessageProvider for data sources which names match the regex.
      Parameters:
      lmp - provider to register
      regex - regex to match
      Returns:
      unique ID
    • removeLocaleMessageProvider

      public static boolean removeLocaleMessageProvider(int id)
      Unregisters LocaleMessageProvider by its unique ID.
      Parameters:
      id - unique id
      Returns:
      true if provider was successfully removed, false otherwise
    • getLocaleMessageProvider

      public static LocaleMessageProvider getLocaleMessageProvider(String id)
      Looks up LocaleMessageProvider by source id.
      Parameters:
      id - source id
      Returns:
      LocaleMessageProvider or null if not found
    • getDSLocaleMessageProvider

      public static LocaleMessageProvider getDSLocaleMessageProvider(String id)
      Looks up LocaleMessageProvider by data source id.
      Parameters:
      id - source id
      Returns:
      LocaleMessageProvider or null if not found