Package org.apache.openjpa.util
Class ProxyManagerImpl
- java.lang.Object
-
- org.apache.openjpa.util.ProxyManagerImpl
-
- All Implemented Interfaces:
ProxyManager
public class ProxyManagerImpl extends java.lang.Object implements ProxyManager
Default implementation of theProxyManagerinterface.- Author:
- Abe White, Mark Struberg
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.xbean.asm9.TypeTYPE_OBJECT
-
Constructor Summary
Constructors Constructor Description ProxyManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanallowsDuplicates(java.lang.Class type)Return whether the given collection type allows duplicates.java.lang.ObjectcopyArray(java.lang.Object orig)Return a new array of the same component type as the given array and containing the same elements.java.util.CalendarcopyCalendar(java.util.Calendar orig)Return a copy of the given calendar with the same information.java.util.CollectioncopyCollection(java.util.Collection orig)Return a new collection of the same type as the given one with a copy of all contained elements.java.lang.ObjectcopyCustom(java.lang.Object orig)Return a copy of the given object with the same information, or null if this manager cannot copy the object.java.util.DatecopyDate(java.util.Date orig)Return a copy of the given date with the same information.java.util.MapcopyMap(java.util.Map orig)Return a new map of the same type as the given one with a copy of all contained key/value pairs.protected java.lang.reflect.ConstructorfindCopyConstructor(java.lang.Class cls)Find an appropriate copy constructor for the given type, or return null if none.protected java.lang.reflect.MethodfindGetter(java.lang.Class type, java.lang.reflect.Method setter)Return the getter corresponding to the given setter, or null.protected byte[]generateProxyBeanBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a bean proxy for the given type.protected byte[]generateProxyCalendarBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a calendar proxy for the given type.protected byte[]generateProxyCollectionBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a collection proxy for the given type.protected byte[]generateProxyDateBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a date proxy for the given type.protected byte[]generateProxyMapBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a map proxy for the given type.booleangetAssertAllowedType()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.booleangetDelayCollectionLoading()Whether loading of collections should be delayed until an operation is performed that requires them to be loaded.protected static java.lang.StringgetProxyClassName(java.lang.Class type, boolean runtime)Return the name of the proxy class to generate for the given type.booleangetTrackChanges()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.java.util.CollectiongetUnproxyable()Return a mutable view of class names we know cannot be proxied correctly by this manager.protected booleanisOrdered(java.lang.Class type)Return whether the given collection type maintains an artificial ordering.protected booleanisSetter(java.lang.reflect.Method meth)Return whether the given method is a setter.protected booleanisUnproxyable(java.lang.Class type)Return whether the given type is known to be unproxyable.protected java.lang.ClassloadBuildTimeProxy(java.lang.Class type, java.lang.ClassLoader loader)Load the proxy class generated at build time for the given type, returning null if none exists.protected java.lang.Class<?>loadDelayedProxy(java.lang.Class<?> type)static voidmain(java.lang.String[] args)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.ProxynewCalendarProxy(java.lang.Class type, java.util.TimeZone zone)Return a new calendar proxy.ProxynewCollectionProxy(java.lang.Class type, java.lang.Class elementType, java.util.Comparator compare, boolean autoOff)Return a proxy for the given collection type.ProxynewCustomProxy(java.lang.Object orig, boolean autoOff)Return a proxy for the given object, or null if this manager cannot proxy the object.ProxynewDateProxy(java.lang.Class type)Return a new date proxy.ProxynewMapProxy(java.lang.Class type, java.lang.Class keyType, java.lang.Class elementType, java.util.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(java.lang.String clsNames)Provided for auto-configuration.protected java.lang.ClasstoProxyableCollectionType(java.lang.Class type)Return the concrete type for proxying.protected java.lang.ClasstoProxyableMapType(java.lang.Class type)Return the concrete type for proxying.
-
-
-
Method Detail
-
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
public java.util.Collection getUnproxyable()
Return a mutable view of class names we know cannot be proxied correctly by this manager.
-
setUnproxyable
public void setUnproxyable(java.lang.String clsNames)
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
public java.lang.Object copyArray(java.lang.Object orig)
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
public java.util.Collection copyCollection(java.util.Collection orig)
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
public Proxy newCollectionProxy(java.lang.Class type, java.lang.Class elementType, java.util.Comparator compare, boolean autoOff)
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
public java.util.Map copyMap(java.util.Map orig)
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(java.lang.Class type, java.lang.Class keyType, java.lang.Class elementType, java.util.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
public java.util.Date copyDate(java.util.Date orig)
Description copied from interface:ProxyManagerReturn a copy of the given date with the same information.- Specified by:
copyDatein interfaceProxyManager
-
newDateProxy
public Proxy newDateProxy(java.lang.Class type)
Description copied from interface:ProxyManagerReturn a new date proxy.- Specified by:
newDateProxyin interfaceProxyManager
-
copyCalendar
public java.util.Calendar copyCalendar(java.util.Calendar orig)
Description copied from interface:ProxyManagerReturn a copy of the given calendar with the same information.- Specified by:
copyCalendarin interfaceProxyManager
-
newCalendarProxy
public Proxy newCalendarProxy(java.lang.Class type, java.util.TimeZone zone)
Description copied from interface:ProxyManagerReturn a new calendar proxy.- Specified by:
newCalendarProxyin interfaceProxyManager
-
copyCustom
public java.lang.Object copyCustom(java.lang.Object orig)
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
public Proxy newCustomProxy(java.lang.Object orig, boolean autoOff)
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
protected java.lang.Class toProxyableCollectionType(java.lang.Class type)
Return the concrete type for proxying.
-
toProxyableMapType
protected java.lang.Class toProxyableMapType(java.lang.Class type)
Return the concrete type for proxying.
-
isUnproxyable
protected boolean isUnproxyable(java.lang.Class type)
Return whether the given type is known to be unproxyable.
-
loadBuildTimeProxy
protected java.lang.Class loadBuildTimeProxy(java.lang.Class type, java.lang.ClassLoader loader)Load the proxy class generated at build time for the given type, returning null if none exists.
-
loadDelayedProxy
protected java.lang.Class<?> loadDelayedProxy(java.lang.Class<?> type)
-
getProxyClassName
protected static java.lang.String getProxyClassName(java.lang.Class type, boolean runtime)Return the name of the proxy class to generate for the given type.
-
generateProxyDateBytecode
protected byte[] generateProxyDateBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a date proxy for the given type.
-
generateProxyCalendarBytecode
protected byte[] generateProxyCalendarBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a calendar proxy for the given type.
-
generateProxyCollectionBytecode
protected byte[] generateProxyCollectionBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a collection proxy for the given type.
-
generateProxyMapBytecode
protected byte[] generateProxyMapBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a map proxy for the given type.
-
generateProxyBeanBytecode
protected byte[] generateProxyBeanBytecode(java.lang.Class type, boolean runtime, java.lang.String proxyClassName)Generate the bytecode for a bean proxy for the given type.
-
allowsDuplicates
protected boolean allowsDuplicates(java.lang.Class type)
Return whether the given collection type allows duplicates.
-
isOrdered
protected boolean isOrdered(java.lang.Class type)
Return whether the given collection type maintains an artificial ordering.
-
isSetter
protected boolean isSetter(java.lang.reflect.Method meth)
Return whether the given method is a setter.
-
findGetter
protected java.lang.reflect.Method findGetter(java.lang.Class type, java.lang.reflect.Method setter)Return the getter corresponding to the given setter, or null.
-
findCopyConstructor
protected java.lang.reflect.Constructor findCopyConstructor(java.lang.Class cls)
Find an appropriate copy constructor for the given type, or return null if none.
-
main
public static void main(java.lang.String[] args) throws java.lang.ClassNotFoundException, java.io.IOExceptionUsage: 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:
java.lang.ClassNotFoundExceptionjava.io.IOException
-
-