openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r819771 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache...
Date Mon, 28 Sep 2009 23:51:35 GMT
Author: ppoddar
Date: Mon Sep 28 23:51:33 2009
New Revision: 819771

URL: http://svn.apache.org/viewvc?rev=819771&view=rev
Log:
OPENJPA-1050: Use generics for DataCache

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryResult.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/AbstractWriteBehindCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCallback.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindCache.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindStoreManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/writebehind/CustomWriteBehindCache.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java Mon Sep 28 23:51:33 2009
@@ -117,9 +117,9 @@
             putAllInternal(existingUpdates);
 
         if (log.isTraceEnabled()) {
-            Collection addIds = new ArrayList(additions.size());
-            Collection upIds = new ArrayList(newUpdates.size());
-            Collection exIds = new ArrayList(existingUpdates.size());
+            Collection<Object> addIds = new ArrayList<Object>(additions.size());
+            Collection<Object> upIds = new ArrayList<Object>(newUpdates.size());
+            Collection<Object> exIds = new ArrayList<Object>(existingUpdates.size());
 
             for (Iterator iter = additions.iterator(); iter.hasNext();)
                 addIds.add(((DataCachePCData) iter.next()).getId());

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCache.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCache.java Mon Sep 28 23:51:33 2009
@@ -97,8 +97,8 @@
      * @param deletes A collection of object IDs that have been deleted
      * and must therefore be dropped from the cache.
      */
-    public void commit(Collection additions, Collection newUpdates,
-        Collection existingUpdates, Collection deletes);
+    public void commit(Collection<DataCachePCData> additions, Collection<DataCachePCData> newUpdates,
+        Collection<DataCachePCData> existingUpdates, Collection<Object> deletes);
 
     /**
      * Returns <code>true</code> if this cache contains data
@@ -110,7 +110,7 @@
     /**
      * Returns the indexes of the oids in this cache.
      */
-    public BitSet containsAll(Collection oids);
+    public BitSet containsAll(Collection<Object> oids);
 
     /**
      * Return the cached object for the given oid. Modifying the returned
@@ -165,7 +165,7 @@
      * @return the indexes of the removed oids
      * @see #remove
      */
-    public BitSet removeAll(Collection oids);
+    public BitSet removeAll(Collection<Object> oids);
 
     /**
      * Evict all values of a specified type.
@@ -197,7 +197,7 @@
      * @return the indexes of the pinned oids
      * @see #pin
      */
-    public BitSet pinAll(Collection oids);
+    public BitSet pinAll(Collection<Object> oids);
 
     /**
      * Pin all oids for the given type.
@@ -223,7 +223,7 @@
      * @return the indexes of the unpinned oids
      * @see #unpin
      */
-    public BitSet unpinAll(Collection oids);
+    public BitSet unpinAll(Collection<Object> oids);
 
     /**
      * Unpin all oids associaed with the given type from the cache.
@@ -261,9 +261,13 @@
 	public void close ();
     
     /**
-	 * returns objects from the caches for a given list of keys
+	 * Gets objects from the caches for a given list of keys.
+	 * The returned map has the same keys as the given keys.
+	 * If the cache does not contain data for a specific key,
+	 * the returned map still contains the key with a null value.  
+	 * 
      */
-    public Map getAll(List keys);
+    public Map<Object,DataCachePCData> getAll(List<Object> keys);
     
     /**
      * Returns number of read/write request and cache hit ratio data.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java Mon Sep 28 23:51:33 2009
@@ -77,8 +77,7 @@
 
     public void setContext(StoreContext ctx) {
         _ctx = ctx;
-        _gen = ctx.getConfiguration().getDataCacheManagerInstance().
-            getPCDataGenerator();
+        _gen = ctx.getConfiguration().getDataCacheManagerInstance().getPCDataGenerator();
         super.setContext(ctx);
     }
 
@@ -110,7 +109,7 @@
     /**
      * Evict all members of the given classes.
      */
-    private void evictTypes(Collection classes) {
+    private void evictTypes(Collection<Class<?>> classes) {
         if (classes.isEmpty())
             return;
 
@@ -118,10 +117,8 @@
             getMetaDataRepositoryInstance();
         ClassLoader loader = _ctx.getClassLoader();
 
-        Class cls;
         DataCache cache;
-        for (Iterator itr = classes.iterator(); itr.hasNext();) {
-            cls = (Class) itr.next();
+        for (Class<?> cls : classes) {
             cache = mdr.getMetaData(cls, loader, false).getDataCache();
             if (cache != null)
                 cache.removeAll(cls, false);
@@ -134,20 +131,20 @@
     private void updateCaches() {
         if(_ctx.getCacheStoreMode() != DataCacheStoreMode.BYPASS ) { 
             // map each data cache to the modifications we need to perform
-            Map modMap = null;
+            Map<DataCache,Modifications> modMap = null;
+            if ((_ctx.getPopulateDataCache() && _inserts != null) || _updates != null || _deletes != null)
+                modMap = new HashMap<DataCache,Modifications>();
             Modifications mods;
             DataCachePCData data;
             DataCache cache;
 
             // create pc datas for inserts
             if (_ctx.getPopulateDataCache() && _inserts != null) {
-                for(OpenJPAStateManager sm : _inserts) {
+                for (OpenJPAStateManager sm : _inserts) {
                     cache = sm.getMetaData().getDataCache();
                     if (cache == null)
                         continue;
 
-                    if (modMap == null)
-                        modMap = new HashMap();
                     mods = getModifications(modMap, cache);
                     data = newPCData(sm);
                     data.store(sm);
@@ -159,7 +156,7 @@
             if (_updates != null) {
                 BitSet fields;
                 OpenJPAStateManager sm;
-                for(Map.Entry<OpenJPAStateManager, BitSet> entry : _updates.entrySet()) { 
+                for (Map.Entry<OpenJPAStateManager, BitSet> entry : _updates.entrySet()) { 
                     sm = entry.getKey();
                     fields = entry.getValue();
 
@@ -173,8 +170,6 @@
                     // to the underlying cache are valid. If the commit had not
                     // already succeeded, then we'd want to clone the retrieved
                     // object.
-                    if (modMap == null)
-                        modMap = new HashMap();
                     data = cache.get(sm.getObjectId());
                     mods = getModifications(modMap, cache);
 
@@ -194,13 +189,11 @@
 
             // remove pcdatas for deletes
             if (_deletes != null) {
-                for(OpenJPAStateManager sm : _deletes) { 
+                for (OpenJPAStateManager sm : _deletes) { 
                     cache = sm.getMetaData().getDataCache();
                     if (cache == null)
                         continue;
 
-                    if (modMap == null)
-                        modMap = new HashMap();
                     mods = getModifications(modMap, cache);
                     mods.deletes.add(sm.getObjectId());
                 }
@@ -208,19 +201,18 @@
 
             // notify the caches of the changes
             if (modMap != null) {
-                for (Iterator itr = modMap.entrySet().iterator(); itr.hasNext();) {
-                    Map.Entry entry = (Map.Entry) itr.next();
-                    cache = (DataCache) entry.getKey();
-                    mods = (Modifications) entry.getValue();
+                for (Map.Entry<DataCache,Modifications> entry : modMap.entrySet()) {
+                    cache = entry.getKey();
+                    mods = entry.getValue();
 
                     // make sure we're not caching old versions
                     cache.writeLock();
                     try {
-                        transformToVersionSafePCDatas(cache, mods.additions);
-                        transformToVersionSafePCDatas(cache, mods.newUpdates);
-                        transformToVersionSafePCDatas(cache, mods.existingUpdates);
-                        cache.commit(mods.additions, mods.newUpdates,
-                            mods.existingUpdates, mods.deletes);
+                        cache.commit(
+                                transformToVersionSafePCDatas(cache, mods.additions), 
+                                transformToVersionSafePCDatas(cache, mods.newUpdates), 
+                                transformToVersionSafePCDatas(cache, mods.existingUpdates), 
+                                mods.deletes);
                     } finally {
                         cache.writeUnlock();
                     }
@@ -239,12 +231,12 @@
             QueryCache queryCache = _ctx.getConfiguration().
             getDataCacheManagerInstance().getSystemQueryCache();
             if (queryCache != null) {
-                Collection pers = _ctx.getPersistedTypes();
-                Collection del = _ctx.getDeletedTypes();
-                Collection up = _ctx.getUpdatedTypes();
+                Collection<Class<?>> pers = _ctx.getPersistedTypes();
+                Collection<Class<?>> del = _ctx.getDeletedTypes();
+                Collection<Class<?>> up = _ctx.getUpdatedTypes();
                 int size = pers.size() + del.size() + up.size();
                 if (size > 0) {
-                    Collection types = new ArrayList(size);
+                    Collection<Class<?>> types = new ArrayList<Class<?>>(size);
                     types.addAll(pers);
                     types.addAll(del);
                     types.addAll(up);
@@ -258,33 +250,29 @@
      * Transforms a collection of {@link PCDataHolder}s that might contain
      * stale instances into a collection of up-to-date {@link DataCachePCData}s.
      */
-    private void transformToVersionSafePCDatas(DataCache cache,
-        List holders) {
-
+    private List<DataCachePCData> transformToVersionSafePCDatas(DataCache cache, List<PCDataHolder> holders) {
+        List<DataCachePCData> transformed = new ArrayList<DataCachePCData>(holders.size());
         Map<Object,Integer> ids = new HashMap<Object,Integer>(holders.size());
         // this list could be removed if DataCache.getAll() took a Collection
-        List idList = new ArrayList(holders.size());
+        List<Object> idList = new ArrayList<Object>(holders.size());
         int i = 0;
-        for (PCDataHolder holder : (List<PCDataHolder>) holders) {
+        for (PCDataHolder holder : holders) {
             ids.put(holder.sm.getObjectId(), i++);
             idList.add(holder.sm.getObjectId());
         }
 
-        List<PCDataHolder> removes = new ArrayList<PCDataHolder>();
         Map<Object,DataCachePCData> pcdatas = cache.getAll(idList);
         for (Entry<Object,DataCachePCData> entry : pcdatas.entrySet()) {
             Integer index = ids.get(entry.getKey());
             DataCachePCData oldpc = entry.getValue();
-            PCDataHolder holder = (PCDataHolder) holders.get(index);
+            PCDataHolder holder = holders.get(index);
             if (oldpc != null && compareVersion(holder.sm,
                 holder.sm.getVersion(), oldpc.getVersion()) == VERSION_EARLIER)
-                removes.add(holder);
+                continue;
             else
-                holders.set(index, holder.pcdata);
+                transformed.add(holder.pcdata);
         }
-
-        for (PCDataHolder holder : removes)
-            holders.remove(holder);
+        return transformed;
     }
 
     /**
@@ -292,7 +280,7 @@
      * to the given cache, creating and caching the instance if it does
      * not already exist in the given map.
      */
-    private static Modifications getModifications(Map modMap, DataCache cache) {
+    private static Modifications getModifications(Map<DataCache,Modifications> modMap, DataCache cache) {
         Modifications mods = (Modifications) modMap.get(cache);
         if (mods == null) {
             mods = new Modifications();
@@ -334,16 +322,15 @@
     }
 
     public boolean initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch, Object edata) {
-        boolean rval; 
+        boolean fromDatabase; 
         DataCache cache = sm.getMetaData().getDataCache();
+        DataCachePCData data = null;
         boolean updateCache = _ctx.getCacheStoreMode() != DataCacheStoreMode.BYPASS && _ctx.getPopulateDataCache();
         if (cache == null || sm.isEmbedded() || _ctx.getCacheRetrieveMode() == DataCacheRetrieveMode.BYPASS
             || _ctx.getCacheStoreMode() == DataCacheStoreMode.REFRESH) {
-            rval = super.initialize(sm, state, fetch, edata);
-        }
-
-        else {
-            DataCachePCData data = cache.get(sm.getObjectId());
+            fromDatabase = super.initialize(sm, state, fetch, edata);
+        } else {
+            data = cache.get(sm.getObjectId());
             if (data != null && !isLocking(fetch)) {                
                 //### the 'data.type' access here probably needs to be
                 //### addressed for bug 511
@@ -351,28 +338,27 @@
                 data.load(sm, fetch, edata);
                 // no need to update the cache. 
                 updateCache = false;
-                rval = true;
+                fromDatabase = true;
             } else {
                 // initialize from store manager
-                rval = super.initialize(sm, state, fetch, edata);
+                fromDatabase = super.initialize(sm, state, fetch, edata);
             }
         }
 
-        if (cache != null && (rval && updateCache)) {
+        if (cache != null && (fromDatabase && updateCache)) {
             // update cache if the result came from the database and configured to store or refresh the cache.
-            cacheStateManager(cache, sm);
+            cacheStateManager(cache, sm, data);
         }
-        return rval;
+        return fromDatabase;
     }
     
-    private void cacheStateManager(DataCache cache, OpenJPAStateManager sm) {
+    private void cacheStateManager(DataCache cache, OpenJPAStateManager sm, DataCachePCData data) {
         if(sm.isFlushed()) { 
             return;
         }
         // make sure that we're not trying to cache an old version
         cache.writeLock();
         try {
-            DataCachePCData data = cache.get(sm.getObjectId());
             if (data != null && compareVersion(sm, sm.getVersion(), data.getVersion()) == VERSION_EARLIER) {
                 return;
             }
@@ -385,10 +371,9 @@
                 data = newPCData(sm);
             }
             data.store(sm);
-            if(isNew) { 
+            if (isNew) { 
                 cache.put(data);
-            }
-            else {
+            } else {
                 cache.update(data);
             }
         } finally {
@@ -403,8 +388,7 @@
             return super.load(sm, fields, fetch, lockLevel, edata);
 
         DataCachePCData data = cache.get(sm.getObjectId());
-        if (lockLevel == LockLevels.LOCK_NONE && !isLocking(fetch)
-            && data != null)
+        if (lockLevel == LockLevels.LOCK_NONE && !isLocking(fetch) && data != null)
             data.load(sm, fields, fetch, edata);
         if (fields.length() == 0)
             return true;
@@ -414,13 +398,13 @@
         if (!super.load(sm, (BitSet) fields.clone(), fetch, lockLevel, edata))
             return false;
         if (_ctx.getPopulateDataCache()) {
-            cacheStateManager(cache, sm);
+            cacheStateManager(cache, sm, data);
         }
         return true;
 
     }
 
-    public Collection loadAll(Collection sms, PCState state, int load,
+    public Collection<Object> loadAll(Collection<OpenJPAStateManager> sms, PCState state, int load,
     		FetchConfiguration fetch, Object edata) {
     	if (isLocking(fetch) || 
     	   (!isLocking(fetch) &&
@@ -430,15 +414,13 @@
     	}
 
         Map<OpenJPAStateManager, BitSet> unloaded = null;
-        List smList = null;
-        Map caches = new HashMap();
-        OpenJPAStateManager sm;
+        List<OpenJPAStateManager> smList = null;
+        Map<DataCache,List<OpenJPAStateManager>> caches = new HashMap<DataCache,List<OpenJPAStateManager>>();
         DataCache cache;
         DataCachePCData data;
         BitSet fields;
 
-        for (Iterator itr = sms.iterator(); itr.hasNext();) {
-            sm = (OpenJPAStateManager) itr.next();
+        for (OpenJPAStateManager sm : sms) {
             cache = sm.getMetaData().getDataCache();
             if (cache == null || sm.isEmbedded()) {
                 unloaded = addUnloaded(sm, null, unloaded);
@@ -448,9 +430,9 @@
             if (sm.getManagedInstance() == null
                 || load != FORCE_LOAD_NONE
                 || sm.getPCState() == PCState.HOLLOW) {
-                smList = (List) caches.get(cache);
+                smList = caches.get(cache);
                 if (smList == null) {
-                    smList = new ArrayList();
+                    smList = new ArrayList<OpenJPAStateManager>();
                     caches.put(cache, smList);
                 }
                 smList.add(sm);
@@ -458,22 +440,19 @@
                 unloaded = addUnloaded(sm, null, unloaded);
         }
         
-        for (Iterator itr = caches.keySet().iterator(); itr.hasNext();) {
-            cache = (DataCache) itr.next();
-            smList = (List) caches.get(cache);
-            List oidList = new ArrayList(smList.size());
+        for (Iterator<DataCache> itr = caches.keySet().iterator(); itr.hasNext();) {
+            cache = itr.next();
+            smList = caches.get(cache);
+            List<Object> oidList = new ArrayList<Object>(smList.size());
 
-            for (itr=smList.iterator();itr.hasNext();) {
-                sm = (OpenJPAStateManager) itr.next();
+            for (OpenJPAStateManager sm : smList) {
                 oidList.add((OpenJPAId) sm.getObjectId());
             }
             
-            Map dataMap = cache.getAll(oidList);
+            Map<Object,DataCachePCData> dataMap = cache.getAll(oidList);
 
-            for (itr=smList.iterator();itr.hasNext();) {
-                sm = (OpenJPAStateManager) itr.next();
-                data = (DataCachePCData) dataMap.get(
-                        (OpenJPAId) sm.getObjectId());
+            for (OpenJPAStateManager sm : smList) {
+                data = dataMap.get(sm.getObjectId());
 
                 if (sm.getManagedInstance() == null) {
                     if (data != null) {
@@ -481,8 +460,9 @@
                         //### to be addressed for bug 511
                         sm.initialize(data.getType(), state);
                         data.load(sm, fetch, edata);
-                    } else
+                    } else {
                         unloaded = addUnloaded(sm, null, unloaded);
+                    }
                 } else if (load != FORCE_LOAD_NONE
                         || sm.getPCState() == PCState.HOLLOW) {
                     data = cache.get(sm.getObjectId());
@@ -499,11 +479,10 @@
         }
 
         if (unloaded == null)
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
 
         // load with delegate
-        Collection failed = super.loadAll(unloaded.keySet(), state, load,
-            fetch, edata);
+        Collection<Object> failed = super.loadAll(unloaded.keySet(), state, load, fetch, edata);
         if (!_ctx.getPopulateDataCache())
             return failed;
 
@@ -512,7 +491,7 @@
         boolean isNew;
 
         for(Map.Entry<OpenJPAStateManager, BitSet> entry : unloaded.entrySet()) { 
-            sm = entry.getKey();
+            OpenJPAStateManager sm = entry.getKey();
             fields = entry.getValue();
 
             cache = sm.getMetaData().getDataCache();
@@ -557,13 +536,12 @@
         return unloaded;
     }
 
-    public Collection flush(Collection states) {
-        Collection exceps = super.flush(states);
+    public Collection<Exception> flush(Collection<OpenJPAStateManager> states) {
+        Collection<Exception> exceps = super.flush(states);
 
         // if there were errors evict bad instances and don't record changes
         if (!exceps.isEmpty()) {
-            for (Iterator iter = exceps.iterator(); iter.hasNext(); ) {
-                Exception e = (Exception) iter.next();
+            for (Exception e : exceps) {
                 if (e instanceof OptimisticException)
                     notifyOptimisticLockFailure((OptimisticException) e);
             }
@@ -574,10 +552,7 @@
         if (_ctx.isTrackChangesByType())
             return exceps;
 
-        OpenJPAStateManager sm;
-        for (Iterator itr = states.iterator(); itr.hasNext();) {
-            sm = (OpenJPAStateManager) itr.next();
-
+        for (OpenJPAStateManager sm : states) {
             if (sm.getPCState() == PCState.PNEW && !sm.isFlushed()) {
                 if (_inserts == null) {
                     _inserts = new ArrayList<OpenJPAStateManager>();
@@ -605,7 +580,7 @@
                 _deletes.add(sm);
             }
         }
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     /**
@@ -708,8 +683,7 @@
     private DataCachePCData newPCData(OpenJPAStateManager sm) {
         ClassMetaData meta = sm.getMetaData();
         if (_gen != null)
-            return (DataCachePCData) _gen.generatePCData
-                (sm.getObjectId(), meta);
+            return (DataCachePCData) _gen.generatePCData(sm.getObjectId(), meta);
         return new DataCachePCDataImpl(sm.fetchObjectId(), meta);
     }
 
@@ -727,19 +701,22 @@
      */
     private static class Modifications {
 
-        public final List additions = new ArrayList();
-        public final List newUpdates = new ArrayList();
-        public final List existingUpdates = new ArrayList();
-        public final List deletes = new ArrayList();
+        public final List<PCDataHolder> additions = new ArrayList<PCDataHolder>();
+        public final List<PCDataHolder> newUpdates = new ArrayList<PCDataHolder>();
+        public final List<PCDataHolder> existingUpdates = new ArrayList<PCDataHolder>();
+        public final List<Object> deletes = new ArrayList<Object>();
     }
 
+    /**
+     * Utility structure holds the tuple of cacheable instance and its corresponding state manager. 
+     *
+     */
     private static class PCDataHolder {
 
         public final DataCachePCData pcdata;
         public final OpenJPAStateManager sm;
 
-        public PCDataHolder(DataCachePCData pcdata,
-            OpenJPAStateManager sm) {
+        public PCDataHolder(DataCachePCData pcdata, OpenJPAStateManager sm) {
             this.pcdata = pcdata;
             this.sm = sm;
 		}

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java Mon Sep 28 23:51:33 2009
@@ -111,7 +111,7 @@
      * READ_SERIALIZABLE -- to do so, we'd just return false when in
      * a transaction.
      */
-    private List checkCache(QueryKey qk) {
+    private List<Object> checkCache(QueryKey qk) {
         if (qk == null)
             return null;
         FetchConfiguration fetch = getContext().getFetchConfiguration();
@@ -125,7 +125,7 @@
         if (res == null)
             return null;        
         if (res.isEmpty())
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
 
         // this if block is invoked if the evictOnTimestamp is set to true
         if (_cache instanceof AbstractQueryCache) {
@@ -323,7 +323,7 @@
         implements Executor {
 
         private final Executor _ex;
-        private final Class _candidate;
+        private final Class<?> _candidate;
         private final boolean _subs;
         private final FetchConfiguration _fc;
 
@@ -341,7 +341,7 @@
             QueryKey key = QueryKey.newInstance(cq.getContext(),
                 _ex.isPacking(q), params, _candidate, _subs, range.start, 
                 range.end);
-            List cached = cq.checkCache(key);
+            List<Object> cached = cq.checkCache(key);
             if (cached != null)
                 return new ListResultObjectProvider(cached);
 
@@ -371,7 +371,7 @@
             if (cmd == null || cmd.length == 0)
                 return;
 
-            List classes = new ArrayList(cmd.length);
+            List<Class<?>> classes = new ArrayList<Class<?>>(cmd.length);
             for (int i = 0; i < cmd.length; i++)
                 classes.add(cmd[i].getDescribedType());
 
@@ -435,7 +435,7 @@
             return _ex.getAlias(unwrap(q));
         }
 
-        public Class getResultClass(StoreQuery q) {
+        public Class<?> getResultClass(StoreQuery q) {
             return _ex.getResultClass(unwrap(q));
         }
 
@@ -447,7 +447,7 @@
             return _ex.getProjectionAliases(unwrap(q));
         }
 
-        public Class[] getProjectionTypes(StoreQuery q) {
+        public Class<?>[] getProjectionTypes(StoreQuery q) {
             return _ex.getProjectionTypes(unwrap(q));
         }
 
@@ -488,8 +488,7 @@
      * Result list implementation for a cached query result. Package-protected
      * for testing.
      */
-    public static class CachedList
-        extends AbstractList
+    public static class CachedList extends AbstractList<Object>
         implements Serializable {
 
         private final QueryResult _res;
@@ -521,7 +520,7 @@
 
         public Object writeReplace()
             throws ObjectStreamException {
-            return new ArrayList(this);
+            return new ArrayList<Object>(this);
         }
     }
 
@@ -537,7 +536,7 @@
         private final ResultObjectProvider _rop;
         private final boolean _proj;
         private final QueryKey _qk;
-        private final TreeMap _data = new TreeMap();
+        private final TreeMap<Integer,Object> _data = new TreeMap<Integer,Object>();
         private boolean _maintainCache = true;
         private int _pos = -1;
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryResult.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryResult.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryResult.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryResult.java Mon Sep 28 23:51:33 2009
@@ -26,8 +26,9 @@
  *
  * @author Abe White
  */
+@SuppressWarnings("serial")
 public class QueryResult
-    extends ArrayList {
+    extends ArrayList<Object> {
 
     private final long _ex;
 
@@ -35,7 +36,7 @@
     /**
      * Constructor; supply corresponding query key and result data.
      */
-    public QueryResult(QueryKey key, Collection data) {
+    public QueryResult(QueryKey key, Collection<Object> data) {
         super(data);
 
         if (key.getTimeout() == -1)
@@ -47,7 +48,7 @@
     /**
      * Constructor to set internal data from a serializer.
      */
-    public QueryResult(Collection data, long ex) {
+    public QueryResult(Collection<Object> data, long ex) {
         super(data);
         _ex = ex;
     }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java Mon Sep 28 23:51:33 2009
@@ -49,7 +49,7 @@
 import serp.bytecode.LookupSwitchInstruction;
 
 /**
- * Generates {@link PCData} instances which avoid primitve wrappers
+ * Generates {@link PCData} instances which avoid primitive wrappers
  * to optimize memory use and performance at the cost of slightly higher
  * startup time.
  *
@@ -65,7 +65,7 @@
 
     protected static final String POSTFIX = "$openjpapcdata";
 
-    private final Map _generated = new ConcurrentHashMap();
+    private final Map<Class<?>, DynamicStorage> _generated = new ConcurrentHashMap<Class<?>, DynamicStorage>();
     private final OpenJPAConfiguration _conf;
     private final Log _log;
 
@@ -87,8 +87,8 @@
     public PCData generatePCData(Object oid, ClassMetaData meta) {
         if (meta == null)
             return null;
-        Class type = meta.getDescribedType();
-        DynamicStorage storage = (DynamicStorage) _generated.get(type);
+        Class<?> type = meta.getDescribedType();
+        DynamicStorage storage = _generated.get(type);
         if (storage == null) {
             storage = generateStorage(meta);
             _generated.put(type, storage);
@@ -142,7 +142,7 @@
     /**
      * Creates a unique name for the given type's pcdata implementation.
      */
-    protected String getUniqueName(Class type) {
+    protected String getUniqueName(Class<?> type) {
         return type.getName() + "$" + System.identityHashCode(type) + POSTFIX;
     }
 
@@ -218,7 +218,7 @@
         // }
         code.getstatic().setField(type);
 
-        Collection jumps = new LinkedList();
+        Collection<Instruction> jumps = new LinkedList<Instruction>();
         jumps.add(code.ifnonnull());
         ExceptionHandler handler = code.addExceptionHandler();
 
@@ -528,8 +528,8 @@
         // 		Object context)
         Code code = addLoadMethod(bc, false);
         FieldMetaData[] fmds = meta.getFields();
-        Collection jumps = new LinkedList();
-        Collection jumps2;
+        Collection<Instruction> jumps = new LinkedList<Instruction>();
+        Collection<Instruction> jumps2;
 		
         int local = code.getNextLocalsIndex();
         code.constant().setNull();
@@ -541,7 +541,7 @@
         int objectCount = 0;
         boolean intermediate;
         for (int i = 0; i < fmds.length; i++) {
-            jumps2 = new LinkedList();
+            jumps2 = new LinkedList<Instruction>();
             intermediate = usesIntermediate(fmds[i]);
             setTarget(code.aload().setThis(), jumps);
             // if (loaded.get(i)) or (!loaded.get(i)) depending on inter resp
@@ -583,8 +583,8 @@
         // public void load(OpenJPAStateManager sm, BitSet fields,
         // 		FetchConfiguration fetch, Object conn)
         FieldMetaData[] fmds = meta.getFields();
-        Collection jumps = new LinkedList();
-        Collection jumps2;
+        Collection<Instruction> jumps = new LinkedList<Instruction>();
+        Collection<Instruction> jumps2;
         int objectCount = 0;
         boolean intermediate;
         int local = code.getNextLocalsIndex();
@@ -595,7 +595,7 @@
         code.astore().setLocal(inter);
 
         for (int i = 0; i < fmds.length; i++) {
-            jumps2 = new LinkedList();
+            jumps2 = new LinkedList<Instruction>();
             intermediate = usesIntermediate(fmds[i]);
             // if (fields.get(i))
             // {
@@ -650,7 +650,7 @@
      * Declare and start the base load method.
      */
     private Code addLoadMethod(BCClass bc, boolean fields) {
-        Class[] args = null;
+        Class<?>[] args = null;
         if (fields)
             args = new Class[]{ OpenJPAStateManager.class, BitSet.class,
                 FetchConfiguration.class, Object.class };
@@ -684,7 +684,7 @@
         Instruction first;
         if (typeCode < JavaTypes.OBJECT) {
             // sm.store<type>(i, field<i>)
-            Class type = forType(fmd.getTypeCode());
+            Class<?> type = forType(fmd.getTypeCode());
             first = code.aload().setParam(0);
             code.constant().setValue(index);
             code.aload().setThis();
@@ -730,7 +730,7 @@
      * Load intermediate data if possible.
      */
     private Instruction addLoadIntermediate(Code code, int index,
-        int objectCount, Collection jumps2, int inter) {
+        int objectCount, Collection<Instruction> jumps2, int inter) {
         // {
         // 		Object inter = objects[objectCount];
         Instruction first = code.aload().setThis();
@@ -794,7 +794,7 @@
             new Class[]{ OpenJPAStateManager.class });
 
         FieldMetaData[] fmds = meta.getFields();
-        Collection jumps = new LinkedList();
+        Collection<Instruction> jumps = new LinkedList<Instruction>();
         int objectCount = 0;
         for (int i = 0; i < fmds.length; i++) {
             if (fields) {
@@ -857,7 +857,7 @@
         int typeCode = replaceType(fmd);
         int index = fmd.getIndex();
         if (typeCode < JavaTypes.OBJECT) {
-            Class type = forType(typeCode);
+            Class<?> type = forType(typeCode);
             // field<i> = sm.fetch<Type>(index)
             code.aload().setThis();
             code.aload().setParam(0);
@@ -1027,8 +1027,8 @@
     /**
      * Add method which defers to AbstractPCData.
      */
-    protected void callAbstractPCData(BCClass bc, String name, Class retType,
-        Class[] args) {
+    protected void callAbstractPCData(BCClass bc, String name, Class<?> retType,
+        Class<?>[] args) {
         BCMethod meth = bc.declareMethod(name, retType, args);
         Code code = meth.getCode(true);
         code.aload().setThis();
@@ -1046,8 +1046,8 @@
      * Set the collection of {@link JumpInstruction}s to the given instruction,
      * clearing the collection in the process.
      */
-    protected void setTarget(Instruction ins, Collection jumps) {
-        for (Iterator it = jumps.iterator(); it.hasNext();)
+    protected void setTarget(Instruction ins, Collection<Instruction> jumps) {
+        for (Iterator<Instruction> it = jumps.iterator(); it.hasNext();)
             ((JumpInstruction) it.next()).setTarget(ins);
         jumps.clear();
     }
@@ -1055,7 +1055,7 @@
     /**
      * Transform the given array of classes to strings.
      */
-    private static String[] toStrings(Class[] cls) {
+    private static String[] toStrings(Class<?>[] cls) {
         String[] strings = new String[cls.length];
         for (int i = 0; i < strings.length; i++)
             strings[i] = cls[i].getName();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java Mon Sep 28 23:51:33 2009
@@ -116,7 +116,7 @@
         return _store.load(sm, fields, fetch, lockLevel, context);
     }
 
-    public Collection loadAll(Collection sms, PCState state, int load,
+    public Collection<Object> loadAll(Collection<OpenJPAStateManager> sms, PCState state, int load,
         FetchConfiguration fetch, Object context) {
         return _store.loadAll(sms, state, load, fetch, context);
     }
@@ -126,7 +126,7 @@
         _store.beforeStateChange(sm, fromState, toState);
     }
 
-    public Collection flush(Collection sms) {
+    public Collection<Exception> flush(Collection<OpenJPAStateManager> sms) {
         return _store.flush(sms);
     }
 
@@ -139,11 +139,11 @@
         return _store.assignField(sm, field, preFlush);
     }
 
-    public Class getManagedType(Object oid) {
+    public Class<?> getManagedType(Object oid) {
         return _store.getManagedType(oid);
     }
 
-    public Class getDataStoreIdType(ClassMetaData meta) {
+    public Class<?> getDataStoreIdType(ClassMetaData meta) {
         return _store.getDataStoreIdType(meta);
     }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java Mon Sep 28 23:51:33 2009
@@ -142,7 +142,7 @@
      * parameter
      * @see #find(Object,boolean,FindCallbacks)
      */
-    public Object[] findAll(Collection oids, boolean validate,
+    public Object[] findAll(Collection<Object> oids, boolean validate,
         FindCallbacks call);
 
     /**
@@ -150,7 +150,7 @@
      * cached instance will be returned. Otherwise, the instance will be
      * initialized through the store as usual; however, in this case
      * the store will be passed the given execution data, and the
-     * system will load the object according to the given fetch configuratiion
+     * system will load the object according to the given fetch configuration
      * (or the context's configuration, if the given one is null).
      * Fields can optionally be excluded from required loading using the
      * <code>exclude</code> mask. By default this method does not find new
@@ -166,7 +166,7 @@
      *
      * @see #find(Object,FetchConfiguration,BitSet,Object,int)
      */
-    public Object[] findAll(Collection oids, FetchConfiguration fetch,
+    public Object[] findAll(Collection<Object> oids, FetchConfiguration fetch,
         BitSet exclude, Object edata, int flags);
 
     /**
@@ -175,7 +175,7 @@
      * when no longer needed. This method delegates to 
      * {@link StoreManager#executeExtent}.
      */
-    public Iterator extentIterator(Class cls, boolean subs,
+    public Iterator<Object> extentIterator(Class<?> cls, boolean subs,
         FetchConfiguration fetch, boolean ignoreChanges);
 
     /**
@@ -198,7 +198,7 @@
      * @param fgOnly indicator as to whether to retrieve only fields
      * @see #retrieve
      */
-    public void retrieveAll(Collection objs, boolean fgOnly, OpCallbacks call);
+    public void retrieveAll(Collection<Object> objs, boolean fgOnly, OpCallbacks call);
 
     /**
      * Make the given instance embedded.
@@ -217,16 +217,16 @@
      * Return the application or datastore identity class the given persistent
      * class uses for object ids.
      */
-    public Class getObjectIdType(Class cls);
+    public Class<?> getObjectIdType(Class<?> cls);
 
     /**
      * Create a new object id instance from the given value.
      *
-     * @param cls the persitent class that uses this identity value
+     * @param cls the persistent class that uses this identity value
      * @param val an object id instance, stringified object id, or primary
      * key value
      */
-    public Object newObjectId(Class cls, Object val);
+    public Object newObjectId(Class<?> cls, Object val);
 
     /**
      * Return the set of classes that have been made persistent in the current
@@ -234,7 +234,7 @@
      *
      * @since 0.3.4
      */
-    public Collection getPersistedTypes();
+    public Collection<Class<?>> getPersistedTypes();
 
     /**
      * Return the set of classes that have been deleted in the current
@@ -242,7 +242,7 @@
      *
      * @since 0.3.4
      */
-    public Collection getDeletedTypes();
+    public Collection<Class<?>> getDeletedTypes();
 
     /**
      * Return the set of classes for objects that have been modified
@@ -250,28 +250,28 @@
      *
      * @since 0.3.4
      */
-    public Collection getUpdatedTypes();
+    public Collection<Class<?>> getUpdatedTypes();
 
     /**
      * Return a list of all managed instances.
      */
-    public Collection getManagedObjects();
+    public Collection<Object> getManagedObjects();
 
     /**
      * Return a list of current transaction instances.
      */
-    public Collection getTransactionalObjects();
+    public Collection<Object> getTransactionalObjects();
 
     /**
      * Return a list of instances which will become transactional upon
      * the next transaction.
      */
-    public Collection getPendingTransactionalObjects();
+    public Collection<Object> getPendingTransactionalObjects();
 
     /**
      * Return a list of current dirty instances.
      */
-    public Collection getDirtyObjects();
+    public Collection<Object> getDirtyObjects();
 
     /**
      * Whether to maintain the order in which objects are dirtied for
@@ -319,8 +319,7 @@
      * @param updateVersion if true, the instance's version will be
      * incremented at the next flush
      */
-    public void transactional(Object pc, boolean updateVersion,
-        OpCallbacks call);
+    public void transactional(Object pc, boolean updateVersion, OpCallbacks call);
 
     /**
      * Make the given objects transactional.
@@ -329,18 +328,17 @@
      * @param updateVersion if true, the instance's version will be
      * incremented at the next flush
      */
-    public void transactionalAll(Collection objs, boolean updateVersion,
-        OpCallbacks call);
+    public void transactionalAll(Collection<Object> objs, boolean updateVersion, OpCallbacks call);
 
     /**
-     * Make the given object nontransactional.
+     * Make the given object non-transactional.
      */
     public void nontransactional(Object pc, OpCallbacks call);
 
     /**
      * Make the given objects nontransactional.
      */
-    public void nontransactionalAll(Collection objs, OpCallbacks call);
+    public void nontransactionalAll(Collection<Object> objs, OpCallbacks call);
 
     /**
      * Return whether the given object is persistent.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java Mon Sep 28 23:51:33 2009
@@ -213,7 +213,7 @@
      * which no data store record exists
      * @see org.apache.openjpa.util.ImplHelper#loadAll
      */
-    public Collection loadAll(Collection sms, PCState state, int load,
+    public Collection<Object> loadAll(Collection<OpenJPAStateManager> sms, PCState state, int load,
         FetchConfiguration fetch, Object edata);
 
     /**
@@ -244,7 +244,7 @@
      *
      * @see org.apache.openjpa.util.ApplicationIds#assign()
      */
-    public Collection flush(Collection sms);
+    public Collection<Exception> flush(Collection<OpenJPAStateManager> sms);
 
     /**
      * Assign an object id to the given new instance. Return false if the
@@ -288,7 +288,7 @@
      *
      * @since 0.3.0
      */
-    public Class getManagedType(Object oid);
+    public Class<?> getManagedType(Object oid);
 
     /**
      * Return the class used by this StoreManager for datastore identity
@@ -296,7 +296,7 @@
      * value should the common datastore identity class for all classes, or
      * null if this store manager does not use a common identity class.
      */
-    public Class getDataStoreIdType(ClassMetaData meta);
+    public Class<?> getDataStoreIdType(ClassMetaData meta);
 
     /**
      * Copy the given object id value. Use the described type of the given

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/AbstractWriteBehindCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/AbstractWriteBehindCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/AbstractWriteBehindCache.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/AbstractWriteBehindCache.java Mon Sep 28 23:51:33 2009
@@ -20,11 +20,9 @@
 
 public abstract class AbstractWriteBehindCache implements WriteBehindCache {
     public String getName() {
-        // TODO Auto-generated method stub
         return null;
     }
     
     public void setName(String name) {
-        // TODO Auto-generated method stub
     }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCache.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCache.java Mon Sep 28 23:51:33 2009
@@ -25,16 +25,18 @@
 import java.util.Map;
 
 import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.StateManagerImpl;
 import org.apache.openjpa.meta.ClassMetaData;
 
 public class SimpleWriteBehindCache extends AbstractWriteBehindCache {
 
-    private Map<WriteBehindCacheKey, StateManagerImpl> _cache = new HashMap<WriteBehindCacheKey, StateManagerImpl>();
+    private Map<WriteBehindCacheKey, OpenJPAStateManager> _cache = 
+        new HashMap<WriteBehindCacheKey, OpenJPAStateManager>();
 
-    public List<Exception> add(Collection<StateManagerImpl> sms) {
+    public List<Exception> add(Collection<OpenJPAStateManager> sms) {
         List<Exception> exceptions = new ArrayList<Exception>();
-        for (StateManagerImpl sm : sms) {
+        for (OpenJPAStateManager sm : sms) {
             try {
                 add(sm);
             } catch (WriteBehindException wbe) {
@@ -44,7 +46,7 @@
         return exceptions;
     }
 
-    protected void add(StateManagerImpl sm) {
+    protected void add(OpenJPAStateManager sm) {
         WriteBehindCacheKey key = getKey(sm);
         synchronized (_cache) {
             if (_cache.containsKey(key) && _cache.get(key) != sm) {
@@ -65,14 +67,13 @@
         return rval;
     }
 
-    public WriteBehindCacheKey getKey(StateManagerImpl sm) {
+    public WriteBehindCacheKey getKey(OpenJPAStateManager sm) {
         ClassMetaData md = sm.getMetaData();
         Class<?> cls = md.getDescribedType();
         String className = cls.getCanonicalName();
         Object id = sm.getId();
         
-        SimpleWriteBehindCacheKey key =
-            new SimpleWriteBehindCacheKey(className, id);
+        SimpleWriteBehindCacheKey key = new SimpleWriteBehindCacheKey(className, id);
         return key;
     }
 
@@ -80,8 +81,8 @@
         return _cache.size();
     }
 
-    public Collection<StateManagerImpl> getStateManagers() {
-        return new ArrayList<StateManagerImpl>(_cache.values());
+    public Collection<OpenJPAStateManager> getStateManagers() {
+        return new ArrayList<OpenJPAStateManager>(_cache.values());
     }
 
     public void initialize(WriteBehindCacheManager manager) {
@@ -109,8 +110,7 @@
     }
     
     // Might be better in smImpl. 
-    protected StateManagerImpl merge(StateManagerImpl from,
-        StateManagerImpl into) {
+    protected OpenJPAStateManager merge(OpenJPAStateManager from, OpenJPAStateManager into) {
         for (int i = 0; i < into.getMetaData().getFields().length; i++) {
             if (from.getDirty().get(i)) {
                 into.dirty(i);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCallback.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCallback.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCallback.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/SimpleWriteBehindCallback.java Mon Sep 28 23:51:33 2009
@@ -21,6 +21,7 @@
 import java.util.Collection;
 
 import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.StateManagerImpl;
 import org.apache.openjpa.kernel.StoreManager;
 
@@ -42,7 +43,7 @@
         // skip past any delegating store managers.
         StoreManager storeManager =
             _broker.getStoreManager().getInnermostDelegate();
-        Collection<StateManagerImpl> sms = null;
+        Collection<OpenJPAStateManager> sms = null;
         if (_cache != null && !_cache.isEmpty()) {
             // TODO lock or switch the cache
             sms = _cache.getStateManagers();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindCache.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindCache.java Mon Sep 28 23:51:33 2009
@@ -21,6 +21,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.StateManagerImpl;
 
 /**
@@ -69,14 +70,14 @@
      *         StateManager to the cache. If no exceptions occur the collection
      *         will be empty.
      */
-    public List<Exception> add(Collection<StateManagerImpl> sms);
+    public List<Exception> add(Collection<OpenJPAStateManager> sms);
 
     /**
      * Obtain the StateManagers currently in the cache.
      * 
      * @return collection of state managers.
      */
-    public Collection<StateManagerImpl> getStateManagers();
+    public Collection<OpenJPAStateManager> getStateManagers();
 
     /**
      * Initialize any resources associated with the given
@@ -92,7 +93,7 @@
      *            A StateManager
      * @return A key that may be used to cache the StateManager.
      */
-    public WriteBehindCacheKey getKey(StateManagerImpl sm);
+    public WriteBehindCacheKey getKey(OpenJPAStateManager sm);
 
     /**
      * Determine whether the cache is empty.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindStoreManager.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindStoreManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/writebehind/WriteBehindStoreManager.java Mon Sep 28 23:51:33 2009
@@ -24,6 +24,7 @@
 import java.util.Set;
 
 import org.apache.openjpa.kernel.DelegatingStoreManager;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.PCState;
 import org.apache.openjpa.kernel.StateManagerImpl;
 import org.apache.openjpa.kernel.StoreManager;
@@ -42,7 +43,7 @@
     public static final int OP_UPDATE = 3; 
 
     WriteBehindCache _cache;
-    Collection<StateManagerImpl> inFlightSMs = new ArrayList<StateManagerImpl>();
+    Collection<OpenJPAStateManager> inFlightSMs = new ArrayList<OpenJPAStateManager>();
 
     public WriteBehindStoreManager(StoreManager store) {
         this(store, null);
@@ -54,30 +55,27 @@
         _cache = wbCache;
     }
 
-    public Collection flush(Collection sms) {
-        LinkedHashSet<StateManagerImpl> passingThrough = null;
-        for (Object o : sms) {
-            if(cacheAble((StateManagerImpl)o)) {
-                StateManagerImpl sm = (StateManagerImpl) o;
+    public Collection<Exception> flush(Collection<OpenJPAStateManager> sms) {
+        LinkedHashSet<OpenJPAStateManager> passingThrough = null;
+        for (OpenJPAStateManager sm : sms) {
+            if (cacheAble(sm)) {
                 PCState newState = sm.getPCState();
-                if(newState == PCState.PDELETEDFLUSHED) { 
+                if (newState == PCState.PDELETEDFLUSHED) { 
                     newState = PCState.PDELETED; // effectively reset the flush
                 }
-                inFlightSMs.add(new StateManagerImpl(sm, newState));
-            }
-            else {
-                if(passingThrough == null) { 
-                    passingThrough = new LinkedHashSet<StateManagerImpl>();
+                inFlightSMs.add(new StateManagerImpl((StateManagerImpl)sm, newState));
+            } else {
+                if (passingThrough == null) { 
+                    passingThrough = new LinkedHashSet<OpenJPAStateManager>();
                 }
-                passingThrough.add((StateManagerImpl)o);
+                passingThrough.add(sm);
             }
         }
         
-        Collection rval;
-        if(passingThrough != null) { 
+        Collection<Exception> rval;
+        if (passingThrough != null) { 
             rval = getDelegate().flush(passingThrough);
-        }
-        else { 
+        } else { 
             rval = new ArrayList<Exception>();
         }
         return rval;
@@ -100,11 +98,11 @@
         }
     }
 
-    public Collection<Exception> flushBehind(Collection<StateManagerImpl> sms) {
+    public Collection<Exception> flushBehind(Collection<OpenJPAStateManager> sms) {
         return super.flush(sms);
     }
 
-    public boolean cacheAble(StateManagerImpl sm) {
+    public boolean cacheAble(OpenJPAStateManager sm) {
         boolean rval = false;
         switch (getOperation(sm)) {
         case OP_INSERT:
@@ -135,7 +133,7 @@
         return rval;
     }
     
-    protected int getOperation(StateManagerImpl sm) {
+    protected int getOperation(OpenJPAStateManager sm) {
         int rval = -1; // TODO define me
         if (sm.isDirty()) {
             if (sm.isNew()) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/writebehind/CustomWriteBehindCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/writebehind/CustomWriteBehindCache.java?rev=819771&r1=819770&r2=819771&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/writebehind/CustomWriteBehindCache.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/writebehind/CustomWriteBehindCache.java Mon Sep 28 23:51:33 2009
@@ -33,7 +33,7 @@
  */
 public class CustomWriteBehindCache extends AbstractWriteBehindCache {
 
-    public List<Exception> add(Collection<StateManagerImpl> sms) {
+    public List<Exception> add(Collection<OpenJPAStateManager> sms) {
         List<Exception> exceptions = new ArrayList<Exception>(); 
         return exceptions;
     }
@@ -48,7 +48,7 @@
     public void flush() {
     }
 
-    public WriteBehindCacheKey getKey(StateManagerImpl sm) {
+    public WriteBehindCacheKey getKey(OpenJPAStateManager sm) {
         return null;
     }
 
@@ -64,7 +64,7 @@
         return 0;
     }
 
-    public Collection<StateManagerImpl> getStateManagers() {
+    public Collection<OpenJPAStateManager> getStateManagers() {
         return null;
     }
 



Mime
View raw message