Package org.apache.openjpa.util
Class ProxyManagerImpl
java.lang.Object
org.apache.openjpa.util.ProxyManagerImpl
- All Implemented Interfaces:
ProxyManager
Default implementation of the
ProxyManager interface.- Author:
- Abe White, Mark Struberg
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanallowsDuplicates(Class type) Return whether the given collection type allows duplicates.Return a new array of the same component type as the given array and containing the same elements.copyCalendar(Calendar orig) Return a copy of the given calendar with the same information.copyCollection(Collection orig) Return a new collection of the same type as the given one with a copy of all contained elements.copyCustom(Object orig) Return a copy of the given object with the same information, or null if this manager cannot copy the object.Return a copy of the given date with the same information.Return a new map of the same type as the given one with a copy of all contained key/value pairs.protected ConstructorfindCopyConstructor(Class cls) Find an appropriate copy constructor for the given type, or return null if none.protected MethodfindGetter(Class type, Method setter) Return the getter corresponding to the given setter, or null.protected byte[]generateProxyBeanBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a bean proxy for the given type.protected byte[]generateProxyCalendarBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a calendar proxy for the given type.protected byte[]generateProxyCollectionBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a collection proxy for the given type.protected byte[]generateProxyDateBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a date proxy for the given type.protected byte[]generateProxyMapBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a map proxy for the given type.booleanWhether to perform runtime checks to ensure that all elements added to collection and map proxies are the proper element/key/value type as defined by the metadata.booleanWhether loading of collections should be delayed until an operation is performed that requires them to be loaded.protected static StringgetProxyClassName(Class type, boolean runtime) Return the name of the proxy class to generate for the given type.booleanWhether proxies produced by this factory will useChangeTrackers to try to cut down on data store operations at the cost of some extra bookkeeping overhead.Return a mutable view of class names we know cannot be proxied correctly by this manager.protected booleanReturn whether the given collection type maintains an artificial ordering.protected booleanReturn whether the given method is a setter.protected booleanisUnproxyable(Class type) Return whether the given type is known to be unproxyable.protected ClassloadBuildTimeProxy(Class type, ClassLoader loader) Load the proxy class generated at build time for the given type, returning null if none exists.protected Class<?>loadDelayedProxy(Class<?> type) static voidUsage: java org.apache.openjpa.util.proxy.ProxyManagerImpl [option]* <class name>+
Where the following options are recognized: -utils/-u <number>: Generate proxies for the standard java.util collection, map, date, and calendar classes of the given Java version.newCalendarProxy(Class type, TimeZone zone) Return a new calendar proxy.newCollectionProxy(Class type, Class elementType, Comparator compare, boolean autoOff) Return a proxy for the given collection type.newCustomProxy(Object orig, boolean autoOff) Return a proxy for the given object, or null if this manager cannot proxy the object.newDateProxy(Class type) Return a new date proxy.newMapProxy(Class type, Class keyType, Class elementType, Comparator compare, boolean autoOff) Return a proxy for the given map type.voidsetAssertAllowedType(boolean assertType) Whether to perform runtime checks to ensure that all elements added to collection and map proxies are the proper element/key/value type as defined by the metadata.voidsetDelayCollectionLoading(boolean delay) Whether loading of collections should be delayed until an operation is performed that requires them to be loaded.voidsetTrackChanges(boolean track) Whether proxies produced by this factory will useChangeTrackers to try to cut down on data store operations at the cost of some extra bookkeeping overhead.voidsetUnproxyable(String clsNames) Provided for auto-configuration.protected ClassReturn the concrete type for proxying.protected ClasstoProxyableMapType(Class type) Return the concrete type for proxying.
-
Field Details
-
TYPE_OBJECT
public static final org.apache.xbean.asm9.Type TYPE_OBJECT
-
-
Constructor Details
-
ProxyManagerImpl
public ProxyManagerImpl()
-
-
Method Details
-
getTrackChanges
public boolean getTrackChanges()Whether proxies produced by this factory will useChangeTrackers to try to cut down on data store operations at the cost of some extra bookkeeping overhead. Defaults to true. -
setTrackChanges
public void setTrackChanges(boolean track) Whether proxies produced by this factory will useChangeTrackers to try to cut down on data store operations at the cost of some extra bookkeeping overhead. Defaults to true. -
getAssertAllowedType
public boolean getAssertAllowedType()Whether to perform runtime checks to ensure that all elements added to collection and map proxies are the proper element/key/value type as defined by the metadata. Defaults to false. -
setAssertAllowedType
public void setAssertAllowedType(boolean assertType) Whether to perform runtime checks to ensure that all elements added to collection and map proxies are the proper element/key/value type as defined by the metadata. Defaults to false. -
getDelayCollectionLoading
public boolean getDelayCollectionLoading()Whether loading of collections should be delayed until an operation is performed that requires them to be loaded. This property only applies to proxies that implement java.util.Collection (ie. not arrays or maps). Defaults to false.- Specified by:
getDelayCollectionLoadingin interfaceProxyManager
-
setDelayCollectionLoading
public void setDelayCollectionLoading(boolean delay) Whether loading of collections should be delayed until an operation is performed that requires them to be loaded. Defaults to false. -
getUnproxyable
Return a mutable view of class names we know cannot be proxied correctly by this manager. -
setUnproxyable
Provided for auto-configuration. Add the given semicolon-separated class names to the set of class names we know cannot be proxied correctly by this manager. -
copyArray
Description copied from interface:ProxyManagerReturn a new array of the same component type as the given array and containing the same elements. Works for both primitive and object array types.- Specified by:
copyArrayin interfaceProxyManager
-
copyCollection
Description copied from interface:ProxyManagerReturn a new collection of the same type as the given one with a copy of all contained elements.- Specified by:
copyCollectionin interfaceProxyManager
-
newCollectionProxy
Description copied from interface:ProxyManagerReturn a proxy for the given collection type. The returned collection will allow only addition of elements assignable from the given element type and will use the given comparator, if it is not null.- Specified by:
newCollectionProxyin interfaceProxyManager
-
copyMap
Description copied from interface:ProxyManagerReturn a new map of the same type as the given one with a copy of all contained key/value pairs.- Specified by:
copyMapin interfaceProxyManager
-
newMapProxy
public Proxy newMapProxy(Class type, Class keyType, Class elementType, Comparator compare, boolean autoOff) Description copied from interface:ProxyManagerReturn a proxy for the given map type. The returned map will allow only addition of keys/values assignable from the given keyType/valueType, and will use the given comparator, if it is not null.- Specified by:
newMapProxyin interfaceProxyManager
-
copyDate
Description copied from interface:ProxyManagerReturn a copy of the given date with the same information.- Specified by:
copyDatein interfaceProxyManager
-
newDateProxy
Description copied from interface:ProxyManagerReturn a new date proxy.- Specified by:
newDateProxyin interfaceProxyManager
-
copyCalendar
Description copied from interface:ProxyManagerReturn a copy of the given calendar with the same information.- Specified by:
copyCalendarin interfaceProxyManager
-
newCalendarProxy
Description copied from interface:ProxyManagerReturn a new calendar proxy.- Specified by:
newCalendarProxyin interfaceProxyManager
-
copyCustom
Description copied from interface:ProxyManagerReturn a copy of the given object with the same information, or null if this manager cannot copy the object.- Specified by:
copyCustomin interfaceProxyManager
-
newCustomProxy
Description copied from interface:ProxyManagerReturn a proxy for the given object, or null if this manager cannot proxy the object.- Specified by:
newCustomProxyin interfaceProxyManager
-
toProxyableCollectionType
Return the concrete type for proxying. -
toProxyableMapType
Return the concrete type for proxying. -
isUnproxyable
Return whether the given type is known to be unproxyable. -
loadBuildTimeProxy
Load the proxy class generated at build time for the given type, returning null if none exists. -
loadDelayedProxy
-
getProxyClassName
Return the name of the proxy class to generate for the given type. -
generateProxyDateBytecode
Generate the bytecode for a date proxy for the given type. -
generateProxyCalendarBytecode
Generate the bytecode for a calendar proxy for the given type. -
generateProxyCollectionBytecode
protected byte[] generateProxyCollectionBytecode(Class type, boolean runtime, String proxyClassName) Generate the bytecode for a collection proxy for the given type. -
generateProxyMapBytecode
Generate the bytecode for a map proxy for the given type. -
generateProxyBeanBytecode
Generate the bytecode for a bean proxy for the given type. -
allowsDuplicates
Return whether the given collection type allows duplicates. -
isOrdered
Return whether the given collection type maintains an artificial ordering. -
isSetter
Return whether the given method is a setter. -
findGetter
Return the getter corresponding to the given setter, or null. -
findCopyConstructor
Find an appropriate copy constructor for the given type, or return null if none. -
main
Usage: java org.apache.openjpa.util.proxy.ProxyManagerImpl [option]* <class name>+
Where the following options are recognized:- -utils/-u <number>: Generate proxies for the standard java.util collection, map, date, and calendar classes of the given Java version. Use 4 for Java 1.4, 5 for Java 5, etc.
- Throws:
ClassNotFoundExceptionIOException
-