Class XMLPreferenceDaoImpl

java.lang.Object
org.openwms.core.preferences.impl.file.XMLPreferenceDaoImpl
All Implemented Interfaces:
EventListener, PreferenceDao, org.springframework.context.ApplicationListener<org.openwms.core.event.ReloadFilePreferencesEvent>

@Transactional(propagation=MANDATORY) @Repository class XMLPreferenceDaoImpl extends Object implements PreferenceDao, org.springframework.context.ApplicationListener<org.openwms.core.event.ReloadFilePreferencesEvent>
A XMLPreferenceDaoImpl reads an XML file of Preferences and keeps them in-memory in a Map. An initial preferences file can be configured with a property openwms.core.config.initial-properties in the application.properties file.

On a ReloadFilePreferencesEvent the internal Map is cleared and reloaded.

Author:
Heiko Scherrer
See Also:
  • ReloadFilePreferencesEvent
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • ctx

      private final org.springframework.context.ApplicationContext ctx
    • unmarshaller

      private final org.springframework.oxm.Unmarshaller unmarshaller
    • fileName

      @Value("${openwms.core.config.initial-properties}") private String fileName
    • fileResource

      private org.springframework.core.io.Resource fileResource
    • preferences

      private Preferences preferences
    • prefs

      private final Map<PreferenceKey,GenericPreference> prefs
  • Constructor Details

    • XMLPreferenceDaoImpl

      XMLPreferenceDaoImpl(org.springframework.context.ApplicationContext ctx, org.springframework.oxm.Unmarshaller unmarshaller)
  • Method Details

    • findAll

      public List<GenericPreference> findAll()
      Find all entities and return them as a List.
      Specified by:
      findAll in interface PreferenceDao
      Returns:
      List of all entities
    • onApplicationEvent

      @Measured public void onApplicationEvent(org.openwms.core.event.ReloadFilePreferencesEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.openwms.core.event.ReloadFilePreferencesEvent>
    • loadResources

      @PostConstruct private void loadResources()
      On bean initialization load all Preferences into a Map.
    • initialPropertiesExist

      private boolean initialPropertiesExist()
    • reloadResources

      private void reloadResources()