public final class RecycleUtils extends Object
Weak references to objects are held by a thread-local queue. When a process has finished working
with an object, the recycle(java.lang.Object) method may be offer the recycled object to the queue for
consideration as reusable on the same thread.
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
clean(T instance)
Clean all instance fields.
|
static <T> void |
clean(T instance,
Class<? super T> top)
Clean all instance fields, walking up the class hierarchy to the indicated super class.
|
static <T> T |
getInstance(Class<T> c)
Get an instance of the given class that has previously been recycled on the same thread, or a
new instance using a default constructor if a recycled instance is not available.
|
static <T> T |
getRecycledInstance(Class<T> c)
Get an instance of the given class that has previously been recycled on the same thread, if
an instance of available.
|
static <T> T |
getRecycledInstance(String name,
Class<T> c)
Get an instance of the given class that has previously been recycled on the same thread, if
an instance of available.
|
static void |
recycle(Object instance)
Recycle a instance by its class, for later retrieval in the same thread.
|
static void |
recycle(String name,
Object instance)
Recycle a instance by its class and given name, for later retrieval in the same thread.
|
static void |
recycle(String name,
Object instance,
Class<?> recycleClass)
Recycle a instance by the given class and given name, for later retrieval in the same thread.
|
public static <T> T getRecycledInstance(Class<T> c)
T - recycled instance typec - class to get instance ofpublic static <T> T getRecycledInstance(String name, Class<T> c)
T - recycled instance typename - bean namec - class to get instance ofpublic static <T> T getInstance(Class<T> c)
T - recycled instance typec - class to get instance ofpublic static void recycle(Object instance)
Note that this method does not clean the instance, it only queues it for later retrieval by
getRecycledInstance(Class). The state of the instance should be cleared before
passing to this method. For a flexible means to clean instances using reflection
clean(Object, Class) may be considered, however note that a manually implemented
clean operation will generally perform faster.
instance - instance to recyclepublic static void recycle(String name, Object instance)
name - bean nameinstance - instance to recyclerecycle(java.lang.Object)public static void recycle(String name, Object instance, Class<?> recycleClass)
name - bean nameinstance - instance to recyclerecycleClass - class to register the instance underrecycle(java.lang.Object)public static <T> void clean(T instance)
T - recycled instance typeinstance - instance to cleanpublic static <T> void clean(T instance, Class<? super T> top)
T - recycled instance typeinstance - instance to cleantop - point in the class hierarchy at which to stop cleaning fieldsCopyright © 2005–2015 The Kuali Foundation. All rights reserved.