org.sakaiproject.entitybroker.util.core
Class AbstractEntityPropertiesService

java.lang.Object
  extended by org.sakaiproject.entitybroker.util.core.AbstractEntityPropertiesService
All Implemented Interfaces:
EntityPropertiesService
Direct Known Subclasses:
EntityPropertiesServiceSimple, EntityPropertiesServiceSpringImpl

public abstract class AbstractEntityPropertiesService
extends Object
implements EntityPropertiesService

This service allows us to track all the properties files related to describing the capabilities of our entities and the entities themselves, it allows lookup of strings as well
NOTE: For internal use only, has no dependencies

Author:
Aaron Zeckoski (azeckoski @ gmail.com)

Nested Class Summary
static interface AbstractEntityPropertiesService.MessageBundle
           
 
Field Summary
protected  Map<String,AbstractEntityPropertiesService.MessageBundle> prefixMap
           
 
Constructor Summary
AbstractEntityPropertiesService()
           
 
Method Summary
 Locale getLocale()
           
 String getProperty(String prefix, String key)
           
 String getProperty(String prefix, String key, Locale locale)
           
 String getProperty(String prefix, String key, Locale locale, String defaultValue)
           
 void loadProperties(String prefix, String baseName, ClassLoader classLoader)
           
abstract  List<String> registerLocaleMessages(String prefix, String baseName, Locale locale, ClassLoader classLoader)
          Override this to provide custom message handling, you must register the AbstractEntityPropertiesService.MessageBundle you create in this method so that the messages can be looked up later, register using registerPrefixMessageBundle(String, MessageBundle)
 void registerPrefixMessageBundle(String prefix, AbstractEntityPropertiesService.MessageBundle messageBundle)
          Register this message bundle with the internal storage
 boolean unloadProperties(String prefix)
           
 void unregisterPrefixMessageBundle(String prefix)
          Unregister this message bundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefixMap

protected Map<String,AbstractEntityPropertiesService.MessageBundle> prefixMap
Constructor Detail

AbstractEntityPropertiesService

public AbstractEntityPropertiesService()
Method Detail

registerPrefixMessageBundle

public void registerPrefixMessageBundle(String prefix,
                                        AbstractEntityPropertiesService.MessageBundle messageBundle)
Register this message bundle with the internal storage

Parameters:
prefix - the related entity prefix for this message bundle
messageBundle - the message bundle
Throws:
IllegalArgumentException - is any arguments are null

unregisterPrefixMessageBundle

public void unregisterPrefixMessageBundle(String prefix)
Unregister this message bundle

Parameters:
prefix - the related entity prefix for a message bundle
Throws:
IllegalArgumentException - is any arguments are null

getLocale

public Locale getLocale()
Specified by:
getLocale in interface EntityPropertiesService

loadProperties

public void loadProperties(String prefix,
                           String baseName,
                           ClassLoader classLoader)
Specified by:
loadProperties in interface EntityPropertiesService

registerLocaleMessages

public abstract List<String> registerLocaleMessages(String prefix,
                                                    String baseName,
                                                    Locale locale,
                                                    ClassLoader classLoader)
Override this to provide custom message handling, you must register the AbstractEntityPropertiesService.MessageBundle you create in this method so that the messages can be looked up later, register using registerPrefixMessageBundle(String, MessageBundle)

Parameters:
prefix - an entity prefix
baseName - (optional) the part before the .properties or _en.properties, example: location/dir/myentity.properties, if null then prefix is used
locale - the Locale to register messages for
classLoader - (optional) the ClassLoader to find the properties files in, if null then the default thread ClassLoader is used
Returns:
the list of registered keys for this Locale

unloadProperties

public boolean unloadProperties(String prefix)
Specified by:
unloadProperties in interface EntityPropertiesService

getProperty

public String getProperty(String prefix,
                          String key)
Specified by:
getProperty in interface EntityPropertiesService

getProperty

public String getProperty(String prefix,
                          String key,
                          Locale locale)
Specified by:
getProperty in interface EntityPropertiesService

getProperty

public String getProperty(String prefix,
                          String key,
                          Locale locale,
                          String defaultValue)
Specified by:
getProperty in interface EntityPropertiesService


Copyright © 2007-2012 CARET, University of Cambridge. All Rights Reserved.