[
https://issues.apache.org/jira/browse/BEANUTILS-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12602623#action_12602623
]
Aaron Zeckoski commented on BEANUTILS-312:
------------------------------------------
I have done this in the past with an API like this one:
{code}
public interface CacheProvider {
/**
* Create a cache by the given name (or if the cache already exists then
reset it),
* the cache will be used to cache one type of persistent objects,
* the cache only needs to exist in your implementation as it will be
accessed using the given name
* @param cacheName a string which uniquely identifies this cache
* @throws IllegalArgumentException if the cache name is invalid
* @throws IllegalStateException if the cache cannot be created
*/
public void createCache(String cacheName);
/**
* Puts an object in the specified cache
* @param cacheName a string which uniquely identifies this cache
* @param key the key for a persistent object (this will be the persistent
id)
* @param value a persistent object (this can be a null to cache a miss)
* @throws IllegalArgumentException if the cache name is invalid or
cacheName or key is null
*/
public void put(String cacheName, String key, Object value);
/**
* Gets an object from the cache if it can be found (maybe be a null),
* use the exists check to see if the object is in the cache before
retrieving
* @param cacheName a string which uniquely identifies this cache
* @param key the key for a persistent object (this will be the persistent
id)
* @return the cached persistent object (may be null)
* @throws IllegalArgumentException if the cache name is invalid or any
arguments are null
* @throws CacheKeyNotFoundException if this key does not exist in the cache
*/
public Object get(String cacheName, String key);
/**
* Removes an object from the cache if it exists or does nothing
* @param cacheName a string which uniquely identifies this cache
* @param key the key for a persistent object (this will be the persistent
id)
* @return true if the object was removed or false if it could not be found
in the cache
* @throws IllegalArgumentException if the cache name is invalid or any
arguments are null
*/
public boolean remove(String cacheName, String key);
/**
* Check if a key exists in the cache and return true if it does
* @param cacheName a string which uniquely identifies this cache
* @param key the key for a persistent object (this will be the persistent
id)
* @return true if the object was removed or false if it could not be found
in the cache
* @throws IllegalArgumentException if the cache name is invalid or any
arguments are null
*/
public boolean exists(String cacheName, String key);
/**
* Clear out all cached items from this cache
* @param cacheName a string which uniquely identifies this cache
* @throws IllegalArgumentException if the cache name is invalid
*/
public void clear(String cacheName);
}
{code}
Is that what you were thinking of?
> Expose the caches in PropertyBeanUtils so they can be controlled if needed
> --------------------------------------------------------------------------
>
> Key: BEANUTILS-312
> URL: https://issues.apache.org/jira/browse/BEANUTILS-312
> Project: Commons BeanUtils
> Issue Type: Improvement
> Components: Bean / Property Utils
> Affects Versions: 1.8.0-BETA
> Reporter: Aaron Zeckoski
> Fix For: 1.8.0
>
> Attachments:
> beanutils-add-cache-setters-getters-remove-fasthashmap.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> We have an extension to commons beanutils which allows us to make it
> work with public fields as well (and a few other improvements we
> needed like deep cloning). In 1.8.0-BETA it is easier to handle this
> extension (thanks!) but it could be even easier if there was a way to
> get and set the caches which are used for storing the
> PropertyDescriptors. Just switching the type from FastHashMap to Map
> and making a setter and getter which are publicly visible would be
> enough to reduce our the work in extending this significantly.
> The attached patch exposes the caches in PropertyBeanUtils and sets them to
> be Map instead of FastHashMap. This also involves a change to PropertyUtils
> (also changing FastHashMap to Map). The patch is fairly small and was built
> again the trunk.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.