org.openwms.core.integration.file
Class PreferencesDaoImpl

java.lang.Object
  extended by org.openwms.core.integration.file.PreferencesDaoImpl
All Implemented Interfaces:
EventListener, PreferenceDao<PreferenceKey>, org.springframework.context.ApplicationListener<PropertiesChangedEvent>

@Repository(value="preferencesFileDao")
public final class PreferencesDaoImpl
extends Object
implements PreferenceDao<PreferenceKey>, org.springframework.context.ApplicationListener<PropertiesChangedEvent>

A PreferencesDaoImpl reads a XML file of preferences and keeps them internally in a Map. An initial preferences file is expected to be at "classpath:org/openwms/core/integration/file/initial-preferences.xml" but this can be overridden with a property application.initial.properties in the configuration properties file.

On a PropertiesChangedEvent the internal Map is cleared and reloaded.

Since:
0.1
Version:
$Revision: $
Author:
Heiko Scherrer
See Also:
PropertiesChangedEvent

Field Summary
static String INITIAL_PREFERENCES_FILE
          The URL to the initial preferences XML file.
 
Method Summary
 List<AbstractPreference> findAll()
          Find all entities and return them as a List.
 AbstractPreference findByKey(PreferenceKey id)
          Find and return the entity identified by the natural unique key.
<T extends AbstractPreference>
List<T>
findByType(Class<T> clazz)
          Find all preferences of a particular type.
 void onApplicationEvent(PropertiesChangedEvent event)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_PREFERENCES_FILE

public static final String INITIAL_PREFERENCES_FILE
The URL to the initial preferences XML file. Default "classpath:org/openwms/core/integration/file/initial-preferences.xml"

See Also:
Constant Field Values
Method Detail

findByKey

public AbstractPreference findByKey(PreferenceKey id)
Find and return the entity identified by the natural unique key.

Specified by:
findByKey in interface PreferenceDao<PreferenceKey>
Parameters:
id - Natural key to find the entity (also known as business key)
Returns:
The found entity
See Also:
PreferenceDao.findByKey(java.io.Serializable)

findByType

public <T extends AbstractPreference> List<T> findByType(Class<T> clazz)
Find all preferences of a particular type.

Specified by:
findByType in interface PreferenceDao<PreferenceKey>
Type Parameters:
T - Any subtype of AbstractPreference
Parameters:
clazz - The type to search for
Returns:
A list of entities
See Also:
PreferenceDao.findByType(Class)

findAll

public List<AbstractPreference> findAll()
Find all entities and return them as a List.

Specified by:
findAll in interface PreferenceDao<PreferenceKey>
Returns:
List of all entities
See Also:
PreferenceDao.findAll()

onApplicationEvent

public void onApplicationEvent(PropertiesChangedEvent event)

Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener<PropertiesChangedEvent>
See Also:
ApplicationListener.onApplicationEvent(org.springframework.context.ApplicationEvent)


Copyright © 2005-2011 openwms.org. All Rights Reserved.