mirror of https://github.com/apache/openjpa.git
OPENJPA-1163:
Add configuration option that allows the elements in a persistent map to be treated as the owners of the relationship (ie updates to the hashmap can add elements without removing old ones). Submitted By : Ravi Palacherla git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@800563 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5e893b5a7
commit
5232b72794
|
@ -60,6 +60,7 @@ public class Compatibility {
|
||||||
private boolean _useJPA2DefaultOrderColumnName = true;
|
private boolean _useJPA2DefaultOrderColumnName = true;
|
||||||
private boolean _copyOnDetach = false;
|
private boolean _copyOnDetach = false;
|
||||||
private boolean _privatePersistentProperties = false;
|
private boolean _privatePersistentProperties = false;
|
||||||
|
private boolean _autoOff = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to require exact identity value types when creating object
|
* Whether to require exact identity value types when creating object
|
||||||
|
@ -77,6 +78,22 @@ public class Compatibility {
|
||||||
_strictIdValues = strictVals;
|
_strictIdValues = strictVals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to turn collection/map tracing off in case of more number of modifications.
|
||||||
|
* Defaults to true.
|
||||||
|
*/
|
||||||
|
public boolean getAutoOff() {
|
||||||
|
return _autoOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to turn collection/map tracing off in case of more number of modifications.
|
||||||
|
* Defaults to true.
|
||||||
|
*/
|
||||||
|
public void setAutoOff(boolean autoOff) {
|
||||||
|
_autoOff = autoOff;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to interpret quoted numbers in query strings as numbers.
|
* Whether to interpret quoted numbers in query strings as numbers.
|
||||||
* OpenJPA versions 0.3.1 and prior treated them as numbers; more recent
|
* OpenJPA versions 0.3.1 and prior treated them as numbers; more recent
|
||||||
|
|
|
@ -743,7 +743,9 @@ public class DetachManager
|
||||||
newVal = _proxy.newCollectionProxy(fmd.getProxyType(),
|
newVal = _proxy.newCollectionProxy(fmd.getProxyType(),
|
||||||
fmd.getElement().getDeclaredType(),
|
fmd.getElement().getDeclaredType(),
|
||||||
fmd.getInitializer() instanceof Comparator ?
|
fmd.getInitializer() instanceof Comparator ?
|
||||||
(Comparator) fmd.getInitializer() : null);
|
(Comparator) fmd.getInitializer() : null,
|
||||||
|
sm.getBroker().getConfiguration().
|
||||||
|
getCompatibilityInstance().getAutoOff());
|
||||||
((Collection) newVal).addAll((Collection) curVal);
|
((Collection) newVal).addAll((Collection) curVal);
|
||||||
} else
|
} else
|
||||||
newVal = _proxy.copyCollection((Collection) curVal);
|
newVal = _proxy.copyCollection((Collection) curVal);
|
||||||
|
@ -761,7 +763,9 @@ public class DetachManager
|
||||||
fmd.getKey().getDeclaredType(),
|
fmd.getKey().getDeclaredType(),
|
||||||
fmd.getElement().getDeclaredType(),
|
fmd.getElement().getDeclaredType(),
|
||||||
fmd.getInitializer() instanceof Comparator ?
|
fmd.getInitializer() instanceof Comparator ?
|
||||||
(Comparator) fmd.getInitializer() : null);
|
(Comparator) fmd.getInitializer() : null,
|
||||||
|
sm.getBroker().getConfiguration().
|
||||||
|
getCompatibilityInstance().getAutoOff());
|
||||||
((Map) newVal).putAll((Map) curVal);
|
((Map) newVal).putAll((Map) curVal);
|
||||||
} else
|
} else
|
||||||
newVal = _proxy.copyMap((Map) curVal);
|
newVal = _proxy.copyMap((Map) curVal);
|
||||||
|
|
|
@ -125,7 +125,9 @@ class SingleFieldManager
|
||||||
return false;
|
return false;
|
||||||
proxy = checkProxy();
|
proxy = checkProxy();
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = getProxyManager().newCustomProxy(objval);
|
proxy = getProxyManager().newCustomProxy(objval,
|
||||||
|
_sm.getBroker().getConfiguration().
|
||||||
|
getCompatibilityInstance().getAutoOff());
|
||||||
ret = proxy != null;
|
ret = proxy != null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1813,12 +1813,14 @@ public class StateManagerImpl
|
||||||
case JavaTypes.COLLECTION:
|
case JavaTypes.COLLECTION:
|
||||||
return mgr.newCollectionProxy(fmd.getProxyType(),
|
return mgr.newCollectionProxy(fmd.getProxyType(),
|
||||||
fmd.getElement().getDeclaredType(),
|
fmd.getElement().getDeclaredType(),
|
||||||
init instanceof Comparator ? (Comparator) init : null);
|
init instanceof Comparator ? (Comparator) init : null,
|
||||||
|
_broker.getConfiguration().getCompatibilityInstance().getAutoOff());
|
||||||
case JavaTypes.MAP:
|
case JavaTypes.MAP:
|
||||||
return mgr.newMapProxy(fmd.getProxyType(),
|
return mgr.newMapProxy(fmd.getProxyType(),
|
||||||
fmd.getKey().getDeclaredType(),
|
fmd.getKey().getDeclaredType(),
|
||||||
fmd.getElement().getDeclaredType(),
|
fmd.getElement().getDeclaredType(),
|
||||||
init instanceof Comparator ? (Comparator) init : null);
|
init instanceof Comparator ? (Comparator) init : null,
|
||||||
|
_broker.getConfiguration().getCompatibilityInstance().getAutoOff());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public abstract class AbstractLRSProxyCollection
|
||||||
*/
|
*/
|
||||||
public AbstractLRSProxyCollection(Class elementType, boolean ordered) {
|
public AbstractLRSProxyCollection(Class elementType, boolean ordered) {
|
||||||
_elementType = elementType;
|
_elementType = elementType;
|
||||||
_ct = new CollectionChangeTrackerImpl(this, false, ordered);
|
_ct = new CollectionChangeTrackerImpl(this, false, ordered,false);
|
||||||
_ct.setAutoOff(false);
|
_ct.setAutoOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ public abstract class AbstractLRSProxyMap<K,V>
|
||||||
public AbstractLRSProxyMap(Class<K> keyType, Class<V> valueType) {
|
public AbstractLRSProxyMap(Class<K> keyType, Class<V> valueType) {
|
||||||
_keyType = keyType;
|
_keyType = keyType;
|
||||||
_valueType = valueType;
|
_valueType = valueType;
|
||||||
_ct = new MapChangeTrackerImpl(this);
|
_ct = new MapChangeTrackerImpl(this,false);
|
||||||
_ct.setAutoOff(false);
|
_ct.setAutoOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,11 @@ public class CollectionChangeTrackerImpl
|
||||||
* @param order true if the collection is ordered, false otherwise
|
* @param order true if the collection is ordered, false otherwise
|
||||||
*/
|
*/
|
||||||
public CollectionChangeTrackerImpl(Collection coll, boolean dups,
|
public CollectionChangeTrackerImpl(Collection coll, boolean dups,
|
||||||
boolean order) {
|
boolean order,boolean autoOff) {
|
||||||
_coll = coll;
|
_coll = coll;
|
||||||
_dups = dups;
|
_dups = dups;
|
||||||
_order = order;
|
_order = order;
|
||||||
|
this.setAutoOff(autoOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,8 +36,9 @@ public class MapChangeTrackerImpl
|
||||||
/**
|
/**
|
||||||
* Constructor; supply delegate map.
|
* Constructor; supply delegate map.
|
||||||
*/
|
*/
|
||||||
public MapChangeTrackerImpl(Map map) {
|
public MapChangeTrackerImpl(Map map, boolean autoOff) {
|
||||||
_map = map;
|
_map = map;
|
||||||
|
this.setAutoOff(autoOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTrackKeys() {
|
public boolean getTrackKeys() {
|
||||||
|
|
|
@ -38,5 +38,5 @@ public interface ProxyCollection
|
||||||
* Create a new instance of this proxy type.
|
* Create a new instance of this proxy type.
|
||||||
*/
|
*/
|
||||||
public ProxyCollection newInstance(Class elementType, Comparator comp,
|
public ProxyCollection newInstance(Class elementType, Comparator comp,
|
||||||
boolean trackChanges);
|
boolean trackChanges, boolean autoOff);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public interface ProxyManager {
|
||||||
* element type and will use the given comparator, if it is not null.
|
* element type and will use the given comparator, if it is not null.
|
||||||
*/
|
*/
|
||||||
public Proxy newCollectionProxy(Class type, Class elementType,
|
public Proxy newCollectionProxy(Class type, Class elementType,
|
||||||
Comparator compare);
|
Comparator compare, boolean autoOff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new map of the same type as the given one
|
* Return a new map of the same type as the given one
|
||||||
|
@ -96,7 +96,7 @@ public interface ProxyManager {
|
||||||
* keyType/valueType, and will use the given comparator, if it is not null.
|
* keyType/valueType, and will use the given comparator, if it is not null.
|
||||||
*/
|
*/
|
||||||
public Proxy newMapProxy(Class type, Class keyType, Class valueType,
|
public Proxy newMapProxy(Class type, Class keyType, Class valueType,
|
||||||
Comparator compare);
|
Comparator compare, boolean autoOff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a copy of the given object with the same information, or null if
|
* Return a copy of the given object with the same information, or null if
|
||||||
|
@ -112,5 +112,5 @@ public interface ProxyManager {
|
||||||
*
|
*
|
||||||
* @since 0.2.5
|
* @since 0.2.5
|
||||||
*/
|
*/
|
||||||
public Proxy newCustomProxy (Object obj);
|
public Proxy newCustomProxy (Object obj, boolean autoOff);
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,11 +184,11 @@ public class ProxyManagerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proxy newCollectionProxy(Class type, Class elementType,
|
public Proxy newCollectionProxy(Class type, Class elementType,
|
||||||
Comparator compare) {
|
Comparator compare, boolean autoOff) {
|
||||||
type = toProxyableCollectionType(type);
|
type = toProxyableCollectionType(type);
|
||||||
ProxyCollection proxy = getFactoryProxyCollection(type);
|
ProxyCollection proxy = getFactoryProxyCollection(type);
|
||||||
return proxy.newInstance((_assertType) ? elementType : null, compare,
|
return proxy.newInstance((_assertType) ? elementType : null, compare,
|
||||||
_trackChanges);
|
_trackChanges, autoOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map copyMap(Map orig) {
|
public Map copyMap(Map orig) {
|
||||||
|
@ -202,11 +202,11 @@ public class ProxyManagerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proxy newMapProxy(Class type, Class keyType,
|
public Proxy newMapProxy(Class type, Class keyType,
|
||||||
Class elementType, Comparator compare) {
|
Class elementType, Comparator compare,boolean autoOff) {
|
||||||
type = toProxyableMapType(type);
|
type = toProxyableMapType(type);
|
||||||
ProxyMap proxy = getFactoryProxyMap(type);
|
ProxyMap proxy = getFactoryProxyMap(type);
|
||||||
return proxy.newInstance((_assertType) ? keyType : null,
|
return proxy.newInstance((_assertType) ? keyType : null,
|
||||||
(_assertType) ? elementType : null, compare, _trackChanges);
|
(_assertType) ? elementType : null, compare, _trackChanges, autoOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date copyDate(Date orig) {
|
public Date copyDate(Date orig) {
|
||||||
|
@ -263,7 +263,7 @@ public class ProxyManagerImpl
|
||||||
return (proxy == null) ? null : proxy.copy(orig);
|
return (proxy == null) ? null : proxy.copy(orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proxy newCustomProxy(Object orig) {
|
public Proxy newCustomProxy(Object orig, boolean autoOff) {
|
||||||
if (orig == null)
|
if (orig == null)
|
||||||
return null;
|
return null;
|
||||||
if (orig instanceof Proxy)
|
if (orig instanceof Proxy)
|
||||||
|
@ -274,14 +274,14 @@ public class ProxyManagerImpl
|
||||||
Comparator comp = (orig instanceof SortedSet)
|
Comparator comp = (orig instanceof SortedSet)
|
||||||
? ((SortedSet) orig).comparator() : null;
|
? ((SortedSet) orig).comparator() : null;
|
||||||
Collection c = (Collection) newCollectionProxy(orig.getClass(),
|
Collection c = (Collection) newCollectionProxy(orig.getClass(),
|
||||||
null, comp);
|
null, comp, autoOff);
|
||||||
c.addAll((Collection) orig);
|
c.addAll((Collection) orig);
|
||||||
return (Proxy) c;
|
return (Proxy) c;
|
||||||
}
|
}
|
||||||
if (orig instanceof Map) {
|
if (orig instanceof Map) {
|
||||||
Comparator comp = (orig instanceof SortedMap)
|
Comparator comp = (orig instanceof SortedMap)
|
||||||
? ((SortedMap) orig).comparator() : null;
|
? ((SortedMap) orig).comparator() : null;
|
||||||
Map m = (Map) newMapProxy(orig.getClass(), null, null, comp);
|
Map m = (Map) newMapProxy(orig.getClass(), null, null, comp, autoOff);
|
||||||
m.putAll((Map) orig);
|
m.putAll((Map) orig);
|
||||||
return (Proxy) m;
|
return (Proxy) m;
|
||||||
}
|
}
|
||||||
|
@ -814,7 +814,7 @@ public class ProxyManagerImpl
|
||||||
|
|
||||||
// new instance factory
|
// new instance factory
|
||||||
m = bc.declareMethod("newInstance", ProxyCollection.class,
|
m = bc.declareMethod("newInstance", ProxyCollection.class,
|
||||||
new Class[] { Class.class, Comparator.class, boolean.class });
|
new Class[] { Class.class, Comparator.class, boolean.class, boolean.class });
|
||||||
m.makePublic();
|
m.makePublic();
|
||||||
code = m.getCode(true);
|
code = m.getCode(true);
|
||||||
|
|
||||||
|
@ -842,9 +842,10 @@ public class ProxyManagerImpl
|
||||||
code.aload().setLocal(ret);
|
code.aload().setLocal(ret);
|
||||||
code.constant().setValue(allowsDuplicates(type));
|
code.constant().setValue(allowsDuplicates(type));
|
||||||
code.constant().setValue(isOrdered(type));
|
code.constant().setValue(isOrdered(type));
|
||||||
|
code.aload().setParam(3);
|
||||||
code.invokespecial().setMethod(CollectionChangeTrackerImpl.class,
|
code.invokespecial().setMethod(CollectionChangeTrackerImpl.class,
|
||||||
"<init>", void.class, new Class[] { Collection.class,
|
"<init>", void.class, new Class[] { Collection.class,
|
||||||
boolean.class, boolean.class });
|
boolean.class, boolean.class, boolean.class });
|
||||||
code.putfield().setField(changeTracker);
|
code.putfield().setField(changeTracker);
|
||||||
|
|
||||||
ifins.setTarget(code.aload().setLocal(ret));
|
ifins.setTarget(code.aload().setLocal(ret));
|
||||||
|
@ -948,7 +949,7 @@ public class ProxyManagerImpl
|
||||||
// new instance factory
|
// new instance factory
|
||||||
m = bc.declareMethod("newInstance", ProxyMap.class,
|
m = bc.declareMethod("newInstance", ProxyMap.class,
|
||||||
new Class[] { Class.class, Class.class, Comparator.class,
|
new Class[] { Class.class, Class.class, Comparator.class,
|
||||||
boolean.class });
|
boolean.class,boolean.class });
|
||||||
m.makePublic();
|
m.makePublic();
|
||||||
code = m.getCode(true);
|
code = m.getCode(true);
|
||||||
|
|
||||||
|
@ -977,8 +978,9 @@ public class ProxyManagerImpl
|
||||||
code.anew().setType(MapChangeTrackerImpl.class);
|
code.anew().setType(MapChangeTrackerImpl.class);
|
||||||
code.dup();
|
code.dup();
|
||||||
code.aload().setLocal(ret);
|
code.aload().setLocal(ret);
|
||||||
|
code.aload().setParam(4);
|
||||||
code.invokespecial().setMethod(MapChangeTrackerImpl.class,
|
code.invokespecial().setMethod(MapChangeTrackerImpl.class,
|
||||||
"<init>", void.class, new Class[] { Map.class });
|
"<init>", void.class, new Class[] { Map.class, boolean.class });
|
||||||
code.putfield().setField(changeTracker);
|
code.putfield().setField(changeTracker);
|
||||||
|
|
||||||
ifins.setTarget(code.aload().setLocal(ret));
|
ifins.setTarget(code.aload().setLocal(ret));
|
||||||
|
|
|
@ -43,5 +43,5 @@ public interface ProxyMap
|
||||||
* Create a new instance of this proxy type.
|
* Create a new instance of this proxy type.
|
||||||
*/
|
*/
|
||||||
public ProxyMap newInstance(Class keyType, Class valueType,
|
public ProxyMap newInstance(Class keyType, Class valueType,
|
||||||
Comparator compare, boolean trackChanges);
|
Comparator compare, boolean trackChanges, boolean autoOff);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,12 +173,12 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyProxyCollection() {
|
public void testCopyProxyCollection() {
|
||||||
List orig = (List) _mgr.newCollectionProxy(ArrayList.class, null, null);
|
List orig = (List) _mgr.newCollectionProxy(ArrayList.class, null, null,true);
|
||||||
populate(orig);
|
populate(orig);
|
||||||
assertListsEqual(new ArrayList(orig), (List) _mgr.copyCollection(orig));
|
assertListsEqual(new ArrayList(orig), (List) _mgr.copyCollection(orig));
|
||||||
|
|
||||||
TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null,
|
TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null,
|
||||||
new CustomComparator());
|
new CustomComparator(),true);
|
||||||
assertTrue(torig.comparator() instanceof CustomComparator);
|
assertTrue(torig.comparator() instanceof CustomComparator);
|
||||||
populate(torig);
|
populate(torig);
|
||||||
assertSortedSetsEqual(new TreeSet(torig), (SortedSet)
|
assertSortedSetsEqual(new TreeSet(torig), (SortedSet)
|
||||||
|
@ -189,7 +189,7 @@ public class TestProxyManager
|
||||||
// List doesn't support clone()
|
// List doesn't support clone()
|
||||||
|
|
||||||
TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null,
|
TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null,
|
||||||
new CustomComparator());
|
new CustomComparator(),true);
|
||||||
assertTrue(torig.comparator() instanceof CustomComparator);
|
assertTrue(torig.comparator() instanceof CustomComparator);
|
||||||
populate(torig);
|
populate(torig);
|
||||||
assertSortedSetsEquals(new TreeSet(torig), (SortedSet) torig.clone());
|
assertSortedSetsEquals(new TreeSet(torig), (SortedSet) torig.clone());
|
||||||
|
@ -197,11 +197,11 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testListMethodsProxied()
|
public void testListMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newCollectionProxy(ArrayList.class, null, null).
|
Class proxy = _mgr.newCollectionProxy(ArrayList.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertListMethodsProxied(proxy);
|
assertListMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newCollectionProxy(CustomList.class, null, null).
|
proxy = _mgr.newCollectionProxy(CustomList.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertListMethodsProxied(proxy);
|
assertListMethodsProxied(proxy);
|
||||||
}
|
}
|
||||||
|
@ -255,19 +255,19 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testSetMethodsProxied()
|
public void testSetMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newCollectionProxy(HashSet.class, null, null).
|
Class proxy = _mgr.newCollectionProxy(HashSet.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertCollectionMethodsProxied(proxy);
|
assertCollectionMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newCollectionProxy(CustomSet.class, null, null).getClass();
|
proxy = _mgr.newCollectionProxy(CustomSet.class, null, null,true).getClass();
|
||||||
assertCollectionMethodsProxied(proxy);
|
assertCollectionMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newCollectionProxy(CustomSortedSet.class, null, null).
|
proxy = _mgr.newCollectionProxy(CustomSortedSet.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertCollectionMethodsProxied(proxy);
|
assertCollectionMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newCollectionProxy(CustomComparatorSortedSet.class, null,
|
proxy = _mgr.newCollectionProxy(CustomComparatorSortedSet.class, null,
|
||||||
new CustomComparator()).getClass();
|
new CustomComparator(),true).getClass();
|
||||||
assertCollectionMethodsProxied(proxy);
|
assertCollectionMethodsProxied(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class TestProxyManager
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Class proxy = _mgr.newCollectionProxy(LinkedList.class, null, null).
|
Class proxy = _mgr.newCollectionProxy(LinkedList.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertTrue(queue.isAssignableFrom(proxy));
|
assertTrue(queue.isAssignableFrom(proxy));
|
||||||
assertCollectionMethodsProxied(proxy);
|
assertCollectionMethodsProxied(proxy);
|
||||||
|
@ -295,7 +295,7 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testLinkedListMethodsProxied()
|
public void testLinkedListMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newCollectionProxy(LinkedList.class, null, null).
|
Class proxy = _mgr.newCollectionProxy(LinkedList.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertListMethodsProxied(proxy);
|
assertListMethodsProxied(proxy);
|
||||||
assertNotNull(proxy.getDeclaredMethod("addFirst",
|
assertNotNull(proxy.getDeclaredMethod("addFirst",
|
||||||
|
@ -308,7 +308,7 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testVectorMethodsProxied()
|
public void testVectorMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newCollectionProxy(Vector.class, null, null).
|
Class proxy = _mgr.newCollectionProxy(Vector.class, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertListMethodsProxied(proxy);
|
assertListMethodsProxied(proxy);
|
||||||
assertNotNull(proxy.getDeclaredMethod("addElement",
|
assertNotNull(proxy.getDeclaredMethod("addElement",
|
||||||
|
@ -326,7 +326,7 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListChangeTracker() {
|
public void testListChangeTracker() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(ArrayList.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(ArrayList.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertNotNull(coll.getChangeTracker());
|
assertNotNull(coll.getChangeTracker());
|
||||||
assertTrue(coll.getChangeTracker()
|
assertTrue(coll.getChangeTracker()
|
||||||
|
@ -338,7 +338,7 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetChangeTracker() {
|
public void testSetChangeTracker() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(HashSet.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(HashSet.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertNotNull(coll.getChangeTracker());
|
assertNotNull(coll.getChangeTracker());
|
||||||
assertTrue(coll.getChangeTracker()
|
assertTrue(coll.getChangeTracker()
|
||||||
|
@ -350,25 +350,25 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCollectionInterfaceProxy() {
|
public void testCollectionInterfaceProxy() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(Collection.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListInterfaceProxy() {
|
public void testListInterfaceProxy() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(List.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(List.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertTrue(coll instanceof List);
|
assertTrue(coll instanceof List);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetInterfaceProxy() {
|
public void testSetInterfaceProxy() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(Set.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(Set.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertTrue(coll instanceof Set);
|
assertTrue(coll instanceof Set);
|
||||||
assertFalse(coll instanceof SortedSet);
|
assertFalse(coll instanceof SortedSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSortedSetInterfaceProxy() {
|
public void testSortedSetInterfaceProxy() {
|
||||||
Proxy coll = _mgr.newCollectionProxy(SortedSet.class, null, null);
|
Proxy coll = _mgr.newCollectionProxy(SortedSet.class, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertTrue(coll instanceof SortedSet);
|
assertTrue(coll instanceof SortedSet);
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ public class TestProxyManager
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Proxy coll = _mgr.newCollectionProxy(queue, null, null);
|
Proxy coll = _mgr.newCollectionProxy(queue, null, null,true);
|
||||||
assertNotNull(coll);
|
assertNotNull(coll);
|
||||||
assertTrue(queue.isInstance(coll));
|
assertTrue(queue.isInstance(coll));
|
||||||
}
|
}
|
||||||
|
@ -479,12 +479,12 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyProxyMap() {
|
public void testCopyProxyMap() {
|
||||||
Map orig = (Map) _mgr.newMapProxy(HashMap.class, null, null, null);
|
Map orig = (Map) _mgr.newMapProxy(HashMap.class, null, null, null,true);
|
||||||
populate(orig);
|
populate(orig);
|
||||||
assertMapsEqual(new HashMap(orig), (Map) _mgr.copyMap(orig));
|
assertMapsEqual(new HashMap(orig), (Map) _mgr.copyMap(orig));
|
||||||
|
|
||||||
TreeMap torig = (TreeMap) _mgr.newMapProxy(TreeMap.class, null, null,
|
TreeMap torig = (TreeMap) _mgr.newMapProxy(TreeMap.class, null, null,
|
||||||
new CustomComparator());
|
new CustomComparator(),true);
|
||||||
assertTrue(torig.comparator() instanceof CustomComparator);
|
assertTrue(torig.comparator() instanceof CustomComparator);
|
||||||
populate(torig);
|
populate(torig);
|
||||||
assertSortedMapsEqual(new TreeMap(torig), (SortedMap)
|
assertSortedMapsEqual(new TreeMap(torig), (SortedMap)
|
||||||
|
@ -495,7 +495,7 @@ public class TestProxyManager
|
||||||
// Map does not support clone()
|
// Map does not support clone()
|
||||||
|
|
||||||
TreeMap torig = (TreeMap) _mgr.newMapProxy(TreeMap.class, null, null,
|
TreeMap torig = (TreeMap) _mgr.newMapProxy(TreeMap.class, null, null,
|
||||||
new CustomComparator());
|
new CustomComparator(),true);
|
||||||
assertTrue(torig.comparator() instanceof CustomComparator);
|
assertTrue(torig.comparator() instanceof CustomComparator);
|
||||||
populate(torig);
|
populate(torig);
|
||||||
assertSortedMapsEquals(new TreeMap(torig), (SortedMap) torig.clone());
|
assertSortedMapsEquals(new TreeMap(torig), (SortedMap) torig.clone());
|
||||||
|
@ -503,26 +503,26 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testMapMethodsProxied()
|
public void testMapMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newMapProxy(HashMap.class, null, null, null).
|
Class proxy = _mgr.newMapProxy(HashMap.class, null, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newMapProxy(TreeMap.class, null, null, null).getClass();
|
proxy = _mgr.newMapProxy(TreeMap.class, null, null, null,true).getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newMapProxy(TreeMap.class, null, null,
|
proxy = _mgr.newMapProxy(TreeMap.class, null, null,
|
||||||
new CustomComparator()).getClass();
|
new CustomComparator(),true).getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newMapProxy(CustomMap.class, null, null, null).getClass();
|
proxy = _mgr.newMapProxy(CustomMap.class, null, null, null,true).getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newMapProxy(CustomSortedMap.class, null, null, null).
|
proxy = _mgr.newMapProxy(CustomSortedMap.class, null, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newMapProxy(CustomComparatorSortedMap.class, null, null,
|
proxy = _mgr.newMapProxy(CustomComparatorSortedMap.class, null, null,
|
||||||
new CustomComparator()).getClass();
|
new CustomComparator(),true).getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testPropertiesMethodsProxied()
|
public void testPropertiesMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newMapProxy(Properties.class, null, null, null).
|
Class proxy = _mgr.newMapProxy(Properties.class, null, null, null,true).
|
||||||
getClass();
|
getClass();
|
||||||
assertMapMethodsProxied(proxy);
|
assertMapMethodsProxied(proxy);
|
||||||
assertNotNull(proxy.getDeclaredMethod("setProperty",
|
assertNotNull(proxy.getDeclaredMethod("setProperty",
|
||||||
|
@ -797,7 +797,7 @@ public class TestProxyManager
|
||||||
NonproxyableBean orig = new NonproxyableBean(1);
|
NonproxyableBean orig = new NonproxyableBean(1);
|
||||||
populate(orig);
|
populate(orig);
|
||||||
assertNull(_mgr.copyCustom(orig));
|
assertNull(_mgr.copyCustom(orig));
|
||||||
assertNull(_mgr.newCustomProxy(orig));
|
assertNull(_mgr.newCustomProxy(orig,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ public class TestProxyManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyProxyBean() {
|
public void testCopyProxyBean() {
|
||||||
CustomBean orig = (CustomBean) _mgr.newCustomProxy(new CustomBean());
|
CustomBean orig = (CustomBean) _mgr.newCustomProxy(new CustomBean(),true);
|
||||||
populate(orig);
|
populate(orig);
|
||||||
CustomBean comp = new CustomBean();
|
CustomBean comp = new CustomBean();
|
||||||
populate(comp);
|
populate(comp);
|
||||||
|
@ -824,11 +824,11 @@ public class TestProxyManager
|
||||||
|
|
||||||
public void testBeanMethodsProxied()
|
public void testBeanMethodsProxied()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Class proxy = _mgr.newCustomProxy(new CustomBean()).getClass();
|
Class proxy = _mgr.newCustomProxy(new CustomBean(),true).getClass();
|
||||||
assertBeanMethodsProxied(proxy);
|
assertBeanMethodsProxied(proxy);
|
||||||
|
|
||||||
proxy = _mgr.newCustomProxy(new CustomCopyConstructorBean
|
proxy = _mgr.newCustomProxy(new CustomCopyConstructorBean
|
||||||
(new CustomBean())).getClass();
|
(new CustomBean()),true).getClass();
|
||||||
assertBeanMethodsProxied(proxy);
|
assertBeanMethodsProxied(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue