public abstract class AbstractObjectResolver extends Object implements ObjectResolver
Modifier and Type | Field and Description |
---|---|
static String |
PROP_CACHED
The Key if the found Object should be cached (this will handle the Object as singleton).
|
static String |
PROP_OBJECT_RESOLVER_KEY
The Key which ObjectResolver implementation should be used.
|
Constructor and Description |
---|
AbstractObjectResolver() |
Modifier and Type | Method and Description |
---|---|
void |
addObjectResolver(ObjectResolver objectResolver)
Some Implementations of a
ObjectResolver are delegating the functionality
to other ObjectResolvers. |
protected abstract Object |
contentToObject(String key,
Properties properties,
byte[] content,
ContentResolver contentResolver)
Method to convert the given content-File to an Object must be implemented by SubClasses.
|
Object |
getObject(String key,
ContentResolver contentResolver)
Reads the byte[] content from the ContentResolver and creates an Object.
|
protected Properties |
getObjectProperties(String key,
ContentResolver contentResolver)
To get the additional Properties for the given byte[] content can be overwriten by subclasses.
|
protected String |
getObjectResolverKey() |
String |
getPropertySuffix() |
boolean |
isCached() |
void |
setCached(boolean cached) |
void |
setPropertySuffix(String propertySuffix) |
public static final String PROP_OBJECT_RESOLVER_KEY
public static final String PROP_CACHED
public void addObjectResolver(ObjectResolver objectResolver)
ObjectResolver
are delegating the functionality
to other ObjectResolvers.UnionObjectResolver
-------------------------------------- <objectResolver name="DefaultObjectResolver" class="org.settings4j.objectresolver.UnionObjectResolver"> <objectResolver-ref ref="JavaXMLBeansObjectResolver" /> <objectResolver-ref ref="SpringConfigObjectResolver" /> </objectResolver> --------------------------------------
addObjectResolver
in interface ObjectResolver
objectResolver
- the original objectResolver to delegate.public Object getObject(String key, ContentResolver contentResolver)
ContentResolver
.getContent(key + ".properties")ContentResolver.getContent(String key)
to an Object.getObject
in interface ObjectResolver
key
- The Key of the byte[] who should be converted to an Object.contentResolver
- The contentResolver, from where the content could be read.protected Properties getObjectProperties(String key, ContentResolver contentResolver)
The default implementation reads the PropertyFile from key + ".properties". If no property where found, or an error occurs, this method return null.
key
- the key of the byte[] Content to convert.contentResolver
- the ContentResolver to read the additional Property-File.Properties
Object or null if an error occurred.public String getPropertySuffix()
public void setPropertySuffix(String propertySuffix)
protected String getObjectResolverKey()
protected abstract Object contentToObject(String key, Properties properties, byte[] content, ContentResolver contentResolver)
key
- The Original Key of the Objectproperties
- The Property-File which where Found under key + ".properties"content
- The byte[] Content to convert.contentResolver
- the contentResolver to get possible additional content Files.public boolean isCached()
public void setCached(boolean cached)
Copyright © 2008–2014. All rights reserved.