openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r484693 [1/3] - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-kernel/src/ma...
Date Fri, 08 Dec 2006 18:32:10 GMT
Author: awhite
Date: Fri Dec  8 10:32:07 2006
New Revision: 484693

URL: http://svn.apache.org/viewvc?view=rev&rev=484693
Log:
Move to dynamically-created bytecode proxies for second class objects, rather
than checked-in proxy classes.  This allows us to proxy custom collection,
map, and bean types.


Added:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyBean.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollections.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMaps.java
    incubator/openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/util/
    incubator/openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/util/TestProxyManager.java
Removed:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyArrayList.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyGregorianCalendar.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyHashMap.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyHashSet.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyHashtable.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyLinkedList.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyProperties.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxySQLDate.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyTime.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyTimestamp.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyTreeMap.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyTreeSet.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyUtilDate.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyVector.java
Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractChangeTracker.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyCollection.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyMap.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CollectionChangeTrackerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/MapChangeTrackerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxy.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollection.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyDate.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyMap.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/util/localizer.properties

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java Fri Dec  8 10:32:07 2006
@@ -19,7 +19,6 @@
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
@@ -50,10 +49,9 @@
 
     private final LRSCollectionFieldStrategy _strat;
 
-    public LRSProxyCollection(LRSCollectionFieldStrategy strat,
-        OpenJPAConfiguration conf) {
+    public LRSProxyCollection(LRSCollectionFieldStrategy strat) {
         super(strat.getFieldMapping().getElement().getDeclaredType(),
-            strat.getFieldMapping().getOrderColumn() != null, conf);
+            strat.getFieldMapping().getOrderColumn() != null);
         _strat = strat;
     }
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java Fri Dec  8 10:32:07 2006
@@ -23,7 +23,6 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
@@ -53,9 +52,9 @@
 
     private final LRSMapFieldStrategy _strat;
 
-    public LRSProxyMap(LRSMapFieldStrategy strat, OpenJPAConfiguration conf) {
+    public LRSProxyMap(LRSMapFieldStrategy strat) {
         super(strat.getFieldMapping().getKey().getDeclaredType(),
-            strat.getFieldMapping().getElement().getDeclaredType(), conf);
+            strat.getFieldMapping().getElement().getDeclaredType());
         _strat = strat;
     }
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -116,8 +116,7 @@
         JDBCFetchConfiguration fetch)
         throws SQLException {
         if (field.isLRS()) {
-            sm.storeObjectField(field.getIndex(), new LRSProxyMap(this,
-                store.getConfiguration()));
+            sm.storeObjectField(field.getIndex(), new LRSProxyMap(this));
             return;
         }
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -81,8 +81,8 @@
         return super.joinElementRelation(joins, elem);
     }
 
-    protected Proxy newLRSProxy(OpenJPAConfiguration conf) {
-        return new LRSProxyCollection(this, conf);
+    protected Proxy newLRSProxy() {
+        return new LRSProxyCollection(this);
     }
 
     public void map(boolean adapt) {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -80,8 +80,8 @@
         return super.joinElementRelation(joins, elem);
     }
 
-    protected Proxy newLRSProxy(OpenJPAConfiguration conf) {
-        return new LRSProxyCollection(this, conf);
+    protected Proxy newLRSProxy() {
+        return new LRSProxyCollection(this);
     }
 
     public void map(boolean adapt) {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -140,8 +140,8 @@
         return joinElementRelation(joins, val);
     }
 
-    protected Proxy newLRSProxy(OpenJPAConfiguration conf) {
-        return new LRSProxyMap(this, conf);
+    protected Proxy newLRSProxy() {
+        return new LRSProxyMap(this);
     }
 
     protected void add(JDBCStore store, Object coll, Object obj) {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -140,8 +140,8 @@
         return joinElementRelation(joins, val);
     }
 
-    protected Proxy newLRSProxy(OpenJPAConfiguration conf) {
-        return new LRSProxyMap(this, conf);
+    protected Proxy newLRSProxy() {
+        return new LRSProxyMap(this);
     }
 
     protected void add(JDBCStore store, Object coll, Object obj) {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java Fri Dec  8 10:32:07 2006
@@ -96,7 +96,7 @@
     /**
      * Return a large result set proxy for this field.
      */
-    protected abstract Proxy newLRSProxy(OpenJPAConfiguration conf);
+    protected abstract Proxy newLRSProxy();
 
     /**
      * Convert the field value to a collection. Handles collections and
@@ -409,7 +409,7 @@
         final JDBCFetchConfiguration fetch)
         throws SQLException {
         if (field.isLRS()) {
-            Proxy coll = newLRSProxy(store.getConfiguration());
+            Proxy coll = newLRSProxy();
 
             // if this is ordered we need to know the next seq to use in case
             // objects are added to the collection

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java Fri Dec  8 10:32:07 2006
@@ -123,6 +123,7 @@
                     proxy = getProxyManager().newCustomProxy(objval);
                     ret = proxy != null;
                 }
+                break;
         }
 
         if (proxy != null) {

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractChangeTracker.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractChangeTracker.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractChangeTracker.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractChangeTracker.java Fri Dec  8 10:32:07 2006
@@ -18,9 +18,9 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.IdentityHashMap;
 import java.util.Set;
 
-import org.apache.commons.collections.map.IdentityMap;
 import org.apache.commons.collections.set.MapBackedSet;
 
 /**
@@ -184,7 +184,7 @@
      */
     protected Set newSet() {
         if (_identity == Boolean.TRUE)
-            return MapBackedSet.decorate(new IdentityMap());
+            return MapBackedSet.decorate(new IdentityHashMap());
         return new HashSet();
     }
 
@@ -218,14 +218,14 @@
         if (identity && cur instanceof HashSet) {
             if (cur.isEmpty())
                 return null;
-            Set replace = MapBackedSet.decorate(new IdentityMap());
+            Set replace = MapBackedSet.decorate(new IdentityHashMap());
             replace.addAll(cur);
             return replace;
         }
         if (!identity && !(cur instanceof HashSet) && cur instanceof Set) {
             if (cur.isEmpty())
                 return null;
-            return new HashSet (cur);
+            return new HashSet(cur);
 		}
 		return cur;
 	}

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyCollection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyCollection.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyCollection.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyCollection.java Fri Dec  8 10:32:07 2006
@@ -26,7 +26,6 @@
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.collections.iterators.FilterIterator;
 import org.apache.commons.collections.iterators.IteratorChain;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.lib.util.Closeable;
 import org.apache.openjpa.lib.util.Localizer;
@@ -65,10 +64,9 @@
      * restrictions
      * @param ordered true if this collection is ordered
      */
-    public AbstractLRSProxyCollection(Class elementType, boolean ordered,
-        OpenJPAConfiguration conf) {
+    public AbstractLRSProxyCollection(Class elementType, boolean ordered) {
         _elementType = elementType;
-        _ct = new CollectionChangeTrackerImpl(this, false, ordered, conf);
+        _ct = new CollectionChangeTrackerImpl(this, false, ordered);
         _ct.setAutoOff(false);
     }
 
@@ -109,13 +107,13 @@
 
     public boolean add(Object o) {
         Proxies.assertAllowedType(o, _elementType);
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         _ct.added(o);
         return true;
     }
 
     public boolean addAll(Collection all) {
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         boolean added = false;
         Object add;
         for (Iterator itr = all.iterator(); itr.hasNext();) {
@@ -130,14 +128,14 @@
     public boolean remove(Object o) {
         if (!contains(o))
             return false;
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         Proxies.removed(this, o, false);
         _ct.removed(o);
         return true;
     }
 
     public boolean removeAll(Collection all) {
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         boolean removed = false;
         Object rem;
         for (Iterator itr = all.iterator(); itr.hasNext();) {
@@ -157,7 +155,7 @@
             return true;
         }
 
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         Itr itr = (Itr) iterator();
         try {
             boolean removed = false;
@@ -177,7 +175,7 @@
     }
 
     public void clear() {
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         Itr itr = (Itr) iterator();
         try {
             Object rem;
@@ -394,7 +392,7 @@
         public void remove() {
             if (_state == CLOSED || _last == null)
                 throw new NoSuchElementException();
-            Proxies.dirty(AbstractLRSProxyCollection.this);
+            Proxies.dirty(AbstractLRSProxyCollection.this, false);
             _ct.removed(_last);
             Proxies.removed(AbstractLRSProxyCollection.this, _last, false);
             _last = null;

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyMap.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyMap.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyMap.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/AbstractLRSProxyMap.java Fri Dec  8 10:32:07 2006
@@ -68,11 +68,10 @@
     private int _count = -1;
     private boolean _iterated = false;
 
-    public AbstractLRSProxyMap(Class keyType, Class valueType,
-        OpenJPAConfiguration conf) {
+    public AbstractLRSProxyMap(Class keyType, Class valueType) {
         _keyType = keyType;
         _valueType = valueType;
-        _ct = new MapChangeTrackerImpl(this, conf);
+        _ct = new MapChangeTrackerImpl(this);
         _ct.setAutoOff(false);
     }
 
@@ -196,7 +195,7 @@
     public Object put(Object key, Object value) {
         Proxies.assertAllowedType(key, _keyType);
         Proxies.assertAllowedType(value, _valueType);
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         if (_map == null)
             _map = new HashMap();
         Object old = _map.put(key, value);
@@ -220,7 +219,7 @@
     }
 
     public Object remove(Object key) {
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         Object old = (_map == null) ? null : _map.remove(key);
         if (old == null && (!_ct.getTrackKeys()
             || !_ct.getRemoved().contains(key)))
@@ -234,7 +233,7 @@
     }
 
     public void clear() {
-        Proxies.dirty(this);
+        Proxies.dirty(this, false);
         Itr itr = iterator(MODE_ENTRY);
         try {
             Map.Entry entry;
@@ -482,7 +481,7 @@
             if (_state == CLOSED || _last == null)
                 throw new NoSuchElementException();
 
-            Proxies.dirty(AbstractLRSProxyMap.this);
+            Proxies.dirty(AbstractLRSProxyMap.this, false);
             Proxies.removed(AbstractLRSProxyMap.this, _last.getKey(), true);
             Proxies.removed(AbstractLRSProxyMap.this, _last.getValue(), false);
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CollectionChangeTrackerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CollectionChangeTrackerImpl.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CollectionChangeTrackerImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CollectionChangeTrackerImpl.java Fri Dec  8 10:32:07 2006
@@ -18,8 +18,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-
 /**
  * Default {@link CollectionChangeTracker}.
  *
@@ -42,11 +40,25 @@
      * @param order true if the collection is ordered, false otherwise
      */
     public CollectionChangeTrackerImpl(Collection coll, boolean dups,
-        boolean order, OpenJPAConfiguration conf) {
+        boolean order) {
         _coll = coll;
         _dups = dups;
         _order = order;
     }
+
+    /**
+     * Whether the underlying collection allows duplicates.
+     */
+    public boolean allowsDuplicates() {
+        return _dups;
+    }
+
+    /**
+     * Whether the underlying collection is ordered.
+     */
+    public boolean isOrdered() {
+        return _order;
+    } 
 
     public void added(Object elem) {
         super.added(elem);

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/MapChangeTrackerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/MapChangeTrackerImpl.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/MapChangeTrackerImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/MapChangeTrackerImpl.java Fri Dec  8 10:32:07 2006
@@ -17,8 +17,6 @@
 
 import java.util.Map;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-
 /**
  * Default {@link MapChangeTracker}.
  *
@@ -35,7 +33,7 @@
     /**
      * Constructor; supply delegate map.
      */
-    public MapChangeTrackerImpl(Map map, OpenJPAConfiguration conf) {
+    public MapChangeTrackerImpl(Map map) {
         _map = map;
     }
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java Fri Dec  8 10:32:07 2006
@@ -32,10 +32,6 @@
  */
 public class Proxies {
 
-    public static final int MODE_ENTRY = 0;
-    public static final int MODE_KEY = 1;
-    public static final int MODE_VALUE = 2;
-
     private static final Localizer _loc = Localizer.forPackage(Proxies.class);
 
     /**
@@ -64,14 +60,15 @@
     /**
      * Used by proxy types to dirty their owner.
      */
-    public static void dirty(Proxy proxy) {
+    public static void dirty(Proxy proxy, boolean stopTracking) {
         if (proxy.getOwner() != null)
             proxy.getOwner().dirty(proxy.getOwnerField());
+        if (stopTracking && proxy.getChangeTracker() != null)
+            proxy.getChangeTracker().stopTracking();
     }
 
     /**
-     * Used by proxy types to notify their owner that an element has been
-     * removed.
+     * Used by proxy types to notify collection owner on element removal.
      */
     public static void removed(Proxy proxy, Object removed, boolean key) {
         if (proxy.getOwner() != null && removed != null)
@@ -79,172 +76,13 @@
     }
 
     /**
-     * Return an iterator that dirties its owner on calls to remove. This
-     * iterator assumes that the given proxy collection uses a
-     * {@link CollectionChangeTracker}.
+     * Used by proxy types to serialize non-proxy versions.
      */
-    public static Iterator iterator(final ProxyCollection proxy,
-        final Iterator itr) {
-        return new Iterator() {
-            private Object _last = null;
-
-            public boolean hasNext() {
-                return itr.hasNext();
-            }
-
-            public Object next() {
-                _last = itr.next();
-                return _last;
-            }
-
-            public void remove() {
-                dirty(proxy);
-                itr.remove();
-                if (proxy.getChangeTracker() != null)
-                    ((CollectionChangeTracker) proxy.getChangeTracker()).
-                        removed(_last);
-                removed(proxy, _last, false);
-            }
-        };
+    public static Object writeReplace(Proxy proxy) {
+        if (proxy == null || proxy.getOwner() == null 
+            || proxy.getOwner().isDetached())
+            return proxy;
+        return proxy.copy(proxy);
     }
-
-    /**
-     * Return a proxy iterator that dirties its owner on remove, set, and
-     * add. This iterator assumes that the given proxy collection uses a
-     * {@link CollectionChangeTracker}.
-     */
-    public static ListIterator listIterator(final ProxyCollection proxy,
-        final ListIterator itr, final Class allowed) {
-        return new ListIterator() {
-            private Object _last = null;
-
-            public boolean hasNext() {
-                return itr.hasNext();
-            }
-
-            public int nextIndex() {
-                return itr.nextIndex();
-            }
-
-            public Object next() {
-                _last = itr.next();
-                return _last;
-            }
-
-            public boolean hasPrevious() {
-                return itr.hasPrevious();
-            }
-
-            public int previousIndex() {
-                return itr.previousIndex();
-            }
-
-            public Object previous() {
-                _last = itr.previous();
-                return _last;
-            }
-
-            public void set(Object o) {
-                assertAllowedType(o, allowed);
-                dirty(proxy);
-                itr.set(o);
-                if (proxy.getChangeTracker() != null)
-                    proxy.getChangeTracker().stopTracking();
-                removed(proxy, _last, false);
-                _last = o;
-            }
-
-            public void add(Object o) {
-                assertAllowedType(o, allowed);
-                dirty(proxy);
-                itr.add(o);
-                if (proxy.getChangeTracker() != null) {
-                    if (hasNext())
-                        proxy.getChangeTracker().stopTracking();
-                    else
-                        ((CollectionChangeTracker) proxy.getChangeTracker()).
-                            added(o);
-                }
-                _last = o;
-            }
-
-            public void remove() {
-                dirty(proxy);
-                itr.remove();
-                if (proxy.getChangeTracker() != null)
-                    ((CollectionChangeTracker) proxy.getChangeTracker()).
-                        removed(_last);
-                removed(proxy, _last, false);
-            }
-        };
-    }
-
-    /**
-     * Return a proxy for the given map key or entry set.
-     */
-    public static Set entrySet(final ProxyMap proxy, final Set set,
-        final int mode) {
-        return new AbstractSet() {
-            public int size() {
-                return set.size();
-            }
-
-            public boolean remove(Object o) {
-                if (mode != MODE_KEY)
-                    throw new UnsupportedOperationException();
-
-                Map map = (Map) proxy;
-                if (!map.containsKey(o))
-                    return false;
-                map.remove(o);
-                return true;
-            }
-
-            public Iterator iterator() {
-                final Iterator itr = set.iterator();
-                return new Iterator() {
-                    private Map.Entry _last = null;
-
-                    public boolean hasNext() {
-                        return itr.hasNext();
-                    }
-
-                    public Object next() {
-                        _last = (Map.Entry) itr.next();
-                        switch (mode) {
-                            case MODE_KEY:
-                                return _last.getKey();
-                            case MODE_VALUE:
-                                return _last.getValue();
-                            default:
-                                return _last;
-                        }
-                    }
-
-                    public void remove() {
-                        dirty(proxy);
-                        itr.remove();
-                        if (proxy.getChangeTracker() != null)
-                            ((MapChangeTracker) proxy.getChangeTracker()).
-                                removed(_last.getKey(), _last.getValue());
-                        removed(proxy, _last.getKey(), true);
-                        removed(proxy, _last.getValue(), false);
-                    }
-                };
-            }
-
-            protected Object writeReplace()
-                throws ObjectStreamException {
-                switch (mode) {
-                    case MODE_KEY:
-                        return ((Map) proxy).keySet();
-                    case MODE_VALUE:
-                        return ((Map) proxy).values();
-                    default:
-                        return ((Map) proxy).entrySet();
-                }
-			}
-		};
-	}
 }
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxy.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxy.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxy.java Fri Dec  8 10:32:07 2006
@@ -20,7 +20,7 @@
 /**
  * Interface implemented by all proxy types to allow setting and nulling
  * of their owning instance.
- *  All concrete proxy classes should be public and have publc no-args
+ * All concrete proxy classes should be public and have publc no-args
  * constructors so that tools that work via reflection on persistent instances
  * can manipulate them.
  *

Added: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyBean.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyBean.java?view=auto&rev=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyBean.java (added)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyBean.java Fri Dec  8 10:32:07 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.util;
+
+/**
+ * Interface implemented by all generated custom types, which use JavaBean
+ * conventions for copying state.
+ *
+ * @author Abe White
+ */
+public interface ProxyBean 
+    extends Proxy {
+
+    /**
+     * Create a new instance of this proxy type with the same state as the
+     * given instance.
+     */
+    public ProxyBean newInstance(Object orig);
+}

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java Fri Dec  8 10:32:07 2006
@@ -18,8 +18,8 @@
 import java.util.TimeZone;
 
 /**
- * Interface implemented by all built-in proxies on
- * {@link java.util.Calendar} types.
+ * Interface implemented by all generated proxies on {@link java.util.Calendar}
+ * types.
  *
  * @author Marc Prud'hommeaux
  */
@@ -29,6 +29,5 @@
     /**
      * Return a new instance of this calendar type.
      */
-    public ProxyCalendar newInstance(TimeZone timeZone);
+    public ProxyCalendar newInstance();
 }
-

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollection.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollection.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollection.java Fri Dec  8 10:32:07 2006
@@ -18,23 +18,22 @@
 import java.util.Collection;
 import java.util.Comparator;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-
 /**
- * Interface implemented by all built-in proxies on {@link Collection} types.
+ * Interface implemented by all proxy collection types.
  *
  * @author Abe White
  */
-public interface ProxyCollection
-    extends Proxy {
+public interface ProxyCollection 
+    extends Proxy, Collection {
+
+    /**
+     * The collection element type.
+     */
+    public Class getElementType();
 
     /**
-     * This method should return a new proxy of the same concrete type as the
-     * implementing class. Used by the {@link ProxyManager} factories: one
-     * template instance of each type is created for the purpose of producing
-     * new instances via this method. Overcomes the performance penalties of
-     * reflection.
+     * Create a new instance of this proxy type.
      */
-    public ProxyCollection newInstance(Class elementType, Comparator compare,
-        boolean trackChanges, OpenJPAConfiguration conf);
+    public ProxyCollection newInstance(Class elementType, Comparator comp,
+        boolean trackChanges);
 }

Added: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollections.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollections.java?view=auto&rev=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollections.java (added)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCollections.java Fri Dec  8 10:32:07 2006
@@ -0,0 +1,468 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.util;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Utility methods used by collection proxies.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
+public class ProxyCollections 
+    extends Proxies {
+
+    /**
+     * Call before invoking {@link List#add(int,Object)} on super.
+     */
+    public static void beforeAdd(ProxyCollection coll, int index, Object value){
+        assertAllowedType(value, coll.getElementType());
+        dirty(coll, true);
+    }
+
+    /**
+     * Call before invoking {@link Vector#insertElementAt(Object,int)} on super.
+     */
+    public static void beforeInsertElementAt(ProxyCollection coll, Object value,
+        int index) {
+        beforeAdd(coll, index, value);
+    }
+
+    /**
+     * Call before invoking {@link Collection#add(Object)} on super.
+     */
+    public static void beforeAdd(ProxyCollection coll, Object value) {
+        assertAllowedType(value, coll.getElementType());
+        dirty(coll, false);
+    }
+
+    /**
+     * Call after invoking {@link Collection#add(Object)} on super.
+     *
+     * @param added whether the object was added
+     * @return <code>added</code>, for convenience
+     */
+    public static boolean afterAdd(ProxyCollection coll, Object value, 
+        boolean added) {
+        if (added && coll.getChangeTracker() != null)
+            ((CollectionChangeTracker) coll.getChangeTracker()).added(value);
+        return added;
+    }
+
+    /**
+     * Call before invoking {@link Vector#addElement(Object)} on super.
+     */
+    public static void beforeAddElement(ProxyCollection coll, Object value) {
+        beforeAdd(coll, value);
+    }
+
+    /**
+     * Call after invoking {@link Vector#addElement(Object)} on super.
+     */
+    public static void afterAddElement(ProxyCollection coll, Object value) {
+        afterAdd(coll, value, true);
+    }
+
+    /**
+     * Call before invoking {@link LinkedList#addFirst(Object)} on super.
+     */
+    public static void beforeAddFirst(ProxyCollection coll, Object value) {
+        beforeAdd(coll, 0, value);
+    }
+
+    /**
+     * Call before invoking {@link LinkedList#addLast(Object)} on super.
+     */
+    public static void beforeAddLast(ProxyCollection coll, Object value) {
+        beforeAdd(coll, value);
+    }
+
+    /**
+     * Call after invoking {@link LinkedList#addLast(Object)} on super.
+     */
+    public static void afterAddLast(ProxyCollection coll, Object value) {
+        afterAdd(coll, value, true);
+    }
+
+    /**
+     * Call before invoking {@link Queue#offer(Object)} on super.
+     */
+    public static void beforeOffer(ProxyCollection coll, Object value) {
+        beforeAdd(coll, value);
+    }
+
+    /**
+     * Call after invoking {@link Queue#offer(Object)} on super.
+     *
+     * @param added whether the object was added
+     * @return <code>added</code>, for convenience
+     */
+    public static boolean afterOffer(ProxyCollection coll, Object value, 
+        boolean added) {
+        return afterAdd(coll, value, added);
+    }
+
+    /**
+     * Override for {@link List#addAll(int, Collection)}.
+     */
+    public static boolean addAll(ProxyCollection coll, int index, 
+        Collection values) {
+        List list = (List) coll;
+        for (Iterator itr = values.iterator(); itr.hasNext(); index++)
+            list.add(index, itr.next());
+        return values.size() > 0;
+    }
+
+    /**
+     * Override for {@link Collection#addAll}.
+     */
+    public static boolean addAll(ProxyCollection coll, Collection values) {
+        boolean added = false;
+        for (Iterator itr = values.iterator(); itr.hasNext();)
+            added |= coll.add(itr.next());
+        return added;
+    }
+
+    /**
+     * Call before clearing collection.
+     */
+    public static void beforeClear(ProxyCollection coll) {
+        dirty(coll, true);
+        for (Iterator itr = coll.iterator(); itr.hasNext();)
+            removed(coll, itr.next(), false);
+    }
+
+    /**
+     * Call before clearing vector.
+     */
+    public static void beforeRemoveAllElements(ProxyCollection coll) {
+        beforeClear(coll);
+    }
+
+    /**
+     * Wrap given iterator in a proxy.
+     */
+    public static Iterator afterIterator(final ProxyCollection coll, 
+        final Iterator itr) {
+        // check for proxied; some coll impls delegate iterator methods
+        if (itr instanceof ProxyIterator)
+            return itr;
+        return new ProxyIterator() {
+            private Object _last = null;
+
+            public boolean hasNext() {
+                return itr.hasNext();
+            }
+
+            public Object next() {
+                _last = itr.next();
+                return _last;
+            }
+
+            public void remove() {
+                dirty(coll, false);
+                itr.remove();
+                if (coll.getChangeTracker() != null)
+                    ((CollectionChangeTracker) coll.getChangeTracker()).
+                        removed(_last);
+                Proxies.removed(coll, _last, false);
+            }
+        };
+    }
+
+    /**
+     * Wrap given iterator in a proxy.
+     */
+    public static ListIterator afterListIterator(final ProxyCollection coll, 
+        int idx, final ListIterator itr) {
+        return afterListIterator(coll, itr);
+    }
+
+    /**
+     * Wrap given iterator in a proxy.
+     */
+    public static ListIterator afterListIterator(final ProxyCollection coll, 
+        final ListIterator itr) {
+        // check for proxied; some coll impls delegate iterator methods
+        if (itr instanceof ProxyListIterator)
+            return itr;
+        return new ProxyListIterator() {
+            private Object _last = null;
+
+            public boolean hasNext() {
+                return itr.hasNext();
+            }
+
+            public int nextIndex() {
+                return itr.nextIndex();
+            }
+
+            public Object next() {
+                _last = itr.next();
+                return _last;
+            }
+
+            public boolean hasPrevious() {
+                return itr.hasPrevious();
+            }
+
+            public int previousIndex() {
+                return itr.previousIndex();
+            }
+
+            public Object previous() {
+                _last = itr.previous();
+                return _last;
+            }
+
+            public void set(Object o) {
+                assertAllowedType(o, coll.getElementType());
+                dirty(coll, false);
+                itr.set(o);
+                if (coll.getChangeTracker() != null)
+                    coll.getChangeTracker().stopTracking();
+                Proxies.removed(coll, _last, false);
+                _last = o;
+            }
+
+            public void add(Object o) {
+                assertAllowedType(o, coll.getElementType());
+                dirty(coll, false);
+                itr.add(o);
+                if (coll.getChangeTracker() != null) {
+                    if (hasNext())
+                        coll.getChangeTracker().stopTracking();
+                    else
+                        ((CollectionChangeTracker) coll.getChangeTracker()).
+                            added(o);
+                }
+                _last = o;
+            }
+
+            public void remove() {
+                dirty(coll, false);
+                itr.remove();
+                if (coll.getChangeTracker() != null)
+                    ((CollectionChangeTracker) coll.getChangeTracker()).
+                        removed(_last);
+                Proxies.removed(coll, _last, false);
+            }
+        };
+    }
+
+    /**
+     * Call before invoking {@link List#remove(int)} on super.
+     */ 
+    public static void beforeRemove(ProxyCollection coll, int index) {
+        dirty(coll, false);
+    }
+
+    /**
+     * Call after invoking {@link List#remove(int)} on super.
+     *
+     * @param removed the removed object
+     * @return the removed object, for convenience
+     */ 
+    public static Object afterRemove(ProxyCollection coll, int index, 
+        Object removed) {
+        if (coll.getChangeTracker() != null)
+            ((CollectionChangeTracker)coll.getChangeTracker()).removed(removed);
+        removed(coll, removed, false);
+        return removed;
+    }
+
+    /**
+     * Call before invoking {@link Vector#removeElementAt(int)} on super.
+     */ 
+    public static void beforeRemoveElementAt(ProxyCollection coll, int index) {
+        beforeRemove(coll, index);
+    }
+
+    /**
+     * Call before invoking {@link Collection#remove} on super.
+     */
+    public static void beforeRemove(ProxyCollection coll, Object o) {
+        dirty(coll, false);
+    }
+
+    /**
+     * Call after invoking {@link Collection#remove} on super.
+     *
+     * @param removed whether the object was removed
+     * @return whether the object was removed, for convenience
+     */ 
+    public static boolean afterRemove(ProxyCollection coll, Object o, 
+        boolean removed){
+        if (!removed)
+            return false;
+        if (coll.getChangeTracker() != null)
+            ((CollectionChangeTracker) coll.getChangeTracker()).removed(o);
+        removed(coll, o, false);
+        return true;
+    }
+
+    /**
+     * Call before invoking {@link Vector#removeElement} on super.
+     */
+    public static void beforeRemoveElement(ProxyCollection coll, Object o) {
+        beforeRemove(coll, o);
+    }
+
+    /**
+     * Call after invoking {@link Vector#removeElement} on super.
+     */ 
+    public static boolean afterRemoveElement(ProxyCollection coll, Object o, 
+        boolean removed) {
+        return afterRemove(coll, o, removed);
+    }
+
+    /**
+     * Call before invoking {@link LinkedList#removeFirst} on super.
+     */
+    public static void beforeRemoveFirst(ProxyCollection coll) {
+        beforeRemove(coll, 0);
+    }
+
+    /**
+     * Call after invoking {@link LinkedList#removeFirst} on super.
+     */
+    public static Object afterRemoveFirst(ProxyCollection coll, Object removed){
+        return afterRemove(coll, 0, removed);
+    }
+
+    /**
+     * Call after invoking {@link LinkedList#removeLast} on super.
+     */
+    public static void beforeRemoveLast(ProxyCollection coll) {
+        beforeRemove(coll, coll.size() - 1);
+    }
+
+    /**
+     * Call after invoking {@link LinkedList#removeLast} on super.
+     */
+    public static Object afterRemoveLast(ProxyCollection coll, Object removed) {
+        return afterRemove(coll, coll.size(), removed);
+    }
+
+    /**
+     * Call before invoking {@link Queue#remove} on super.
+     */
+    public static void beforeRemove(ProxyCollection coll) {
+        beforeRemove(coll, 0);
+    }
+
+    /**
+     * Call after invoking {@link Queue#remove} on super.
+     */
+    public static Object afterRemove(ProxyCollection coll, Object removed){
+        return afterRemove(coll, 0, removed);
+    }
+
+    /**
+     * Call before invoking {@link Queue#poll} on super.
+     */
+    public static void beforePoll(ProxyCollection coll) {
+        if (!coll.isEmpty())
+            beforeRemove(coll, 0);
+    }
+
+    /**
+     * Call after invoking {@link Queue#poll} on super.
+     */
+    public static Object afterPoll(ProxyCollection coll, Object removed) {
+        if (removed != null)
+            afterRemove(coll, 0, removed);
+        return removed;
+    }
+
+    /**
+     * Override for {@link Collection#removeAll}.
+     */
+    public static boolean removeAll(ProxyCollection coll, Collection vals) {
+        boolean removed = false;
+        for (Iterator itr = vals.iterator(); itr.hasNext();)
+            removed |= coll.remove(itr.next());
+        return removed;
+    }
+
+    /**
+     * Override for {@link Collection#retainAll}.
+     */
+    public static boolean retainAll(ProxyCollection coll, Collection vals) {
+        int size = coll.size();
+        for (Iterator itr = coll.iterator(); itr.hasNext();)
+            if (!vals.contains(itr.next()))
+                itr.remove();
+        return coll.size() < size;
+    }
+
+    /**
+     * Call before invoking {@link List#set} on super.
+     */
+    public static void beforeSet(ProxyCollection coll, int index, 
+        Object element) {
+        assertAllowedType(element, coll.getElementType());
+        dirty(coll, true);
+    }
+
+    /**
+     * Call after invoking {@link List#set} on super.
+     *
+     * @param replaced the replaced object
+     * @return the replaced object, for convenience
+     */
+    public static Object afterSet(ProxyCollection coll, int index, 
+        Object element, Object replaced) {
+        if (replaced != element)
+            removed(coll, replaced, false);
+        return replaced;
+    }
+
+    /**
+     * Call before invoking {@link Vector#setElementAt} on super.
+     */
+    public static void beforeSetElementAt(ProxyCollection coll, Object element,
+        int index) {
+        beforeSet(coll, index, element);
+    }
+
+    /**
+     * Call after invoking {@link Vector#setElementAt} on super.
+     */
+    public static Object afterSetElementAt(ProxyCollection coll, Object element,
+        int index, Object replaced) {
+        return afterSet(coll, index, element, replaced);
+    }
+
+    /**
+     * Marker interface for a proxied iterator. 
+     */
+    public static interface ProxyIterator 
+        extends Iterator {
+    }
+
+    /**
+     * Marker interface for a proxied list iterator. 
+     */
+    public static interface ProxyListIterator 
+        extends ProxyIterator, ListIterator {
+    }
+}

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyDate.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyDate.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyDate.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyDate.java Fri Dec  8 10:32:07 2006
@@ -16,7 +16,7 @@
 package org.apache.openjpa.util;
 
 /**
- * Interface implemented by all built-in proxies on {@link java.util.Date}
+ * Interface implemented by all generated proxies on {@link java.util.Date}
  * types.
  *
  * @author Abe White

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManager.java?view=diff&rev=484693&r1=484692&r2=484693
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManager.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManager.java Fri Dec  8 10:32:07 2006
@@ -41,32 +41,6 @@
 public interface ProxyManager {
 
     /**
-     * Return a copy of the given date with the same information.
-     */
-    public Date copyDate(Date orig);
-
-    /**
-     * Return a copy of the given Calendar with the same information.
-     */
-    public Calendar copyCalendar(Calendar orig);
-
-    /**
-     * Return a new collection of the same type as the given one
-     * with a copy of all contained elements.
-     * If the given owner is non-null, the returned value should be a proxy
-     * for the given owner, otherwise it should not be a proxy.
-     */
-    public Collection copyCollection(Collection orig);
-
-    /**
-     * Return a new map of the same type as the given one
-     * with a copy of all contained key/value pairs.
-     * If the given owner is non-null, the returned value should be a proxy
-     * for the given owner, otherwise it should not be a proxy.
-     */
-    public Map copyMap(Map orig);
-
-    /**
      * Return 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.
@@ -74,14 +48,9 @@
     public Object copyArray(Object orig);
 
     /**
-     * Return a copy of the given object with the same
-     * information. If this manager cannot proxy the given type, return null.
-     * If the given owner is non-null, the returned value should be a proxy
-     * for the given owner, otherwise it should not be a proxy.
-     *
-     * @since 0.2.5
+     * Return a copy of the given date with the same information.
      */
-    public Object copyCustom(Object orig);
+    public Date copyDate(Date orig);
 
     /**
      * Return a new date proxy.
@@ -89,11 +58,22 @@
     public Proxy newDateProxy(Class type);
 
     /**
+     * Return a copy of the given calendar with the same information.
+     */
+    public Calendar copyCalendar(Calendar orig);
+
+    /**
      * Return a new calendar proxy.
      */
     public Proxy newCalendarProxy(Class type, TimeZone timeZone);
 
     /**
+     * Return a new collection of the same type as the given one
+     * with a copy of all contained elements.
+     */
+    public Collection copyCollection(Collection orig);
+
+    /**
      * Return 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.
@@ -102,12 +82,26 @@
         Comparator compare);
 
     /**
+     * Return a new map of the same type as the given one
+     * with a copy of all contained key/value pairs.
+     */
+    public Map copyMap(Map orig);
+
+    /**
      * Return 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.
      */
     public Proxy newMapProxy(Class type, Class keyType, Class valueType,
         Comparator compare);
+
+    /**
+     * Return a copy of the given object with the same information, or null if
+     * this manager cannot copy the object.
+     *
+     * @since 0.2.5
+     */
+    public Object copyCustom(Object orig);
 
     /**
      * Return a proxy for the given object, or null if this manager cannot



Mime
View raw message