openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r440714 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Wed, 06 Sep 2006 13:52:36 GMT
Author: ppoddar
Date: Wed Sep  6 06:52:35 2006
New Revision: 440714

URL: http://svn.apache.org/viewvc?view=rev&rev=440714
Log:
Refatoring user facing classes (FetchPlan, Generator, Extent, StoreCache) into interfaces.
Adding hooks for extended EntityManagerFactory and ConfigurationProvider.

Added:
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java
Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java Wed Sep  6 06:52:35 2006
@@ -49,6 +49,27 @@
         }    
         return (Class) _impls.get(facadeType);
     }
+    
+    /**
+     * Return the implementation for the given facade and store. If no 
+     * registered implementation is found then returns the given default type
+     * provided it the facade type is assignable from the deafult type.
+     *
+     * @param facadeType the facade interface
+     * @param storeType the store's 
+     * {@link org.apache.openjpa.kernel.StoreManager} type, or null for generic
+     * @param implType the registered implementor
+     * @param defaultType class if no registered implementation is available.
+     */
+    public Class getImplementation(Class facadeType, Class storeType, 
+    	Class defaultType) {
+    	Class result = getImplementation(facadeType, storeType);
+    	if (result == null)
+    		result = defaultType;
+    	if (facadeType == null || !facadeType.isAssignableFrom(result))
+    		throw new InternalException();
+    	return result;
+    }
 
     /**
      * Lookup key for facade+store hash.

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlan.java Wed Sep  6 06:52:35 2006
@@ -28,82 +28,35 @@
 /**
  * JDBC extensions to the fetch plan.
  *
- * @since 0.4.0
+ * @since 0.4.1
  * @author Abe White
+ * @author Pinaki Poddar
  * @published
  */
-public class JDBCFetchPlan
-    extends FetchPlan
-    implements EagerFetchModes, LRSSizes, JoinSyntaxes {
-
-    private DelegatingJDBCFetchConfiguration _fetch;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public JDBCFetchPlan(FetchConfiguration fetch) {
-        super(fetch);
-    }
-
-    @Override
-    protected DelegatingFetchConfiguration newDelegatingFetchConfiguration
-        (FetchConfiguration fetch) {
-        _fetch = new DelegatingJDBCFetchConfiguration((JDBCFetchConfiguration)
-            fetch, PersistenceExceptions.TRANSLATOR);
-        return _fetch;
-    }
-
-    public int getEagerFetchMode() {
-        return _fetch.getEagerFetchMode();
-    }
-
-    public JDBCFetchPlan setEagerFetchMode(int mode) {
-        _fetch.setEagerFetchMode(mode);
-        return this;
-    }
-
-    public int getSubclassFetchMode() {
-        return _fetch.getSubclassFetchMode();
-    }
-
-    public JDBCFetchPlan setSubclassFetchMode(int mode) {
-        _fetch.setSubclassFetchMode(mode);
-        return this;
-    }
-
-    public int getResultSetType() {
-        return _fetch.getResultSetType();
-    }
-
-    public JDBCFetchPlan setResultSetType(int type) {
-        _fetch.setResultSetType(type);
-        return this;
-    }
-
-    public int getFetchDirection() {
-        return _fetch.getFetchDirection();
-    }
-
-    public JDBCFetchPlan setFetchDirection(int direction) {
-        _fetch.setFetchDirection(direction);
-        return this;
-    }
-
-    public int getLRSSize() {
-        return _fetch.getLRSSize();
-    }
-
-    public JDBCFetchPlan setLRSSize(int lrsSize) {
-        _fetch.setLRSSize(lrsSize);
-        return this;
-    }
-
-    public int getJoinSyntax() {
-        return _fetch.getJoinSyntax();
-    }
-
-    public JDBCFetchPlan setJoinSyntax(int syntax) {
-        _fetch.setJoinSyntax(syntax);
-        return this;
-    }
+public interface JDBCFetchPlan
+    extends FetchPlan, EagerFetchModes, LRSSizes, JoinSyntaxes {
+
+    public int getEagerFetchMode();
+
+    public JDBCFetchPlan setEagerFetchMode(int mode);
+
+    public int getSubclassFetchMode();
+
+    public JDBCFetchPlan setSubclassFetchMode(int mode);
+
+    public int getResultSetType();
+
+    public JDBCFetchPlan setResultSetType(int type);
+
+    public int getFetchDirection();
+
+    public JDBCFetchPlan setFetchDirection(int direction);
+
+    public int getLRSSize();
+
+    public JDBCFetchPlan setLRSSize(int lrsSize);
+
+    public int getJoinSyntax();
+
+    public JDBCFetchPlan setJoinSyntax(int syntax);
 }

Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCFetchPlanImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.persistence.jdbc;
+
+import org.apache.openjpa.jdbc.kernel.DelegatingJDBCFetchConfiguration;
+import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
+import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
+import org.apache.openjpa.jdbc.kernel.LRSSizes;
+import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
+import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
+import org.apache.openjpa.kernel.FetchConfiguration;
+import org.apache.openjpa.persistence.FetchPlan;
+import org.apache.openjpa.persistence.FetchPlanImpl;
+import org.apache.openjpa.persistence.PersistenceExceptions;
+
+/**
+ * JDBC extensions to the fetch plan.
+ *
+ * @since 0.4.0
+ * @author Abe White
+ * @published
+ */
+public class JDBCFetchPlanImpl
+    extends FetchPlanImpl
+    implements JDBCFetchPlan {
+
+    private DelegatingJDBCFetchConfiguration _fetch;
+
+    /**
+     * Constructor; supply delegate.
+     */
+    public JDBCFetchPlanImpl(FetchConfiguration fetch) {
+        super(fetch);
+    }
+
+    @Override
+    protected DelegatingFetchConfiguration newDelegatingFetchConfiguration
+        (FetchConfiguration fetch) {
+        _fetch = new DelegatingJDBCFetchConfiguration((JDBCFetchConfiguration)
+            fetch, PersistenceExceptions.TRANSLATOR);
+        return _fetch;
+    }
+
+    public int getEagerFetchMode() {
+        return _fetch.getEagerFetchMode();
+    }
+
+    public JDBCFetchPlanImpl setEagerFetchMode(int mode) {
+        _fetch.setEagerFetchMode(mode);
+        return this;
+    }
+
+    public int getSubclassFetchMode() {
+        return _fetch.getSubclassFetchMode();
+    }
+
+    public JDBCFetchPlanImpl setSubclassFetchMode(int mode) {
+        _fetch.setSubclassFetchMode(mode);
+        return this;
+    }
+
+    public int getResultSetType() {
+        return _fetch.getResultSetType();
+    }
+
+    public JDBCFetchPlanImpl setResultSetType(int type) {
+        _fetch.setResultSetType(type);
+        return this;
+    }
+
+    public int getFetchDirection() {
+        return _fetch.getFetchDirection();
+    }
+
+    public JDBCFetchPlanImpl setFetchDirection(int direction) {
+        _fetch.setFetchDirection(direction);
+        return this;
+    }
+
+    public int getLRSSize() {
+        return _fetch.getLRSSize();
+    }
+
+    public JDBCFetchPlanImpl setLRSSize(int lrsSize) {
+        _fetch.setLRSSize(lrsSize);
+        return this;
+    }
+
+    public int getJoinSyntax() {
+        return _fetch.getJoinSyntax();
+    }
+
+    public JDBCFetchPlanImpl setJoinSyntax(int syntax) {
+        _fetch.setJoinSyntax(syntax);
+        return this;
+    }
+}

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java Wed Sep  6 06:52:35 2006
@@ -41,7 +41,7 @@
 
     public void beforeConfigurationLoad(OpenJPAConfiguration c) {
         c.getStoreFacadeTypeRegistry().registerImplementation(FetchPlan.class, 
-            JDBCStoreManager.class, JDBCFetchPlan.class);
+            JDBCStoreManager.class, JDBCFetchPlanImpl.class);
         if (!(c instanceof JDBCConfigurationImpl))
             return;
 

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ConfigurationProviderImpl.java Wed Sep  6 06:52:35 2006
@@ -93,9 +93,9 @@
             return false;
         String providerName = pinfo.getPersistenceProviderClassName();
         if (!StringUtils.isEmpty(providerName)
-            && !PersistenceProviderImpl.class.getName().equals(providerName))
+            && !getPersistenceProviderName().equals(providerName))
             return false;
-
+        
         addProperties(PersistenceUnitInfoImpl.toOpenJPAProperties(pinfo));
         if (m != null)
             addProperties(m);
@@ -168,7 +168,7 @@
      * @return {@link Boolean#TRUE} if the resource was loaded, null if it
      * does not exist, or {@link Boolean#FALSE} if it is not for OpenJPA
      */
-    private Boolean load(String rsrc, String name, Map m, ClassLoader loader,
+    protected Boolean load(String rsrc, String name, Map m, ClassLoader loader,
         boolean explicit)
         throws IOException {
         if (loader == null)
@@ -227,7 +227,7 @@
             }
 
             if (StringUtils.isEmpty(pinfo.getPersistenceProviderClassName())
-                || PersistenceProviderImpl.class.getName().equals(pinfo.
+                || getPersistenceProviderName().equals(pinfo.
                     getPersistenceProviderClassName())) {
                 // if no name given and found unnamed unit, return it.  
                 // otherwise record as default unit unless we find a 
@@ -276,6 +276,21 @@
             log.trace(_loc.get("conf-load", _source, getProperties()));
     }
 
+    /**
+     * Gets the concrete class used as Persistence Provider. 
+     * Used to detect whether this receiver should load the configuration.
+     * This receiver will load only if the provider name in the resource
+     * matches the provider name returned by this method. 
+     * <B>Note</B>: This is a tentative hook for backward-compatibility work
+     * and would be replaced/removed once ProductDerivation-based extension
+     * framework is available.
+     *  
+     * @return
+     */
+    protected String getPersistenceProviderName() {
+    	return PersistenceProviderImpl.class.getName();
+    }
+    
     /**
      * SAX handler capable of parsing an JPA persistence.xml file.
      * Package-protected for testing.

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java Wed Sep  6 06:52:35 2006
@@ -94,7 +94,7 @@
         try {
             if (_cache == null) {
                 OpenJPAConfiguration conf = _factory.getConfiguration();
-                _cache = new StoreCache(this,
+                _cache = new StoreCacheImpl(this,
                     conf.getDataCacheManagerInstance().getSystemDataCache());
             }
             return _cache;
@@ -104,7 +104,7 @@
     }
 
     public StoreCache getStoreCache(String cacheName) {
-        return new StoreCache(this, _factory.getConfiguration().
+        return new StoreCacheImpl(this, _factory.getConfiguration().
             getDataCacheManagerInstance().getDataCache(cacheName));
     }
 
@@ -112,7 +112,7 @@
         _factory.lock();
         try {
             if (_queryCache == null)
-                _queryCache = new QueryResultCache(_factory.getConfiguration().
+                _queryCache = new QueryResultCacheImpl(_factory.getConfiguration().
                     getDataCacheManagerInstance().getSystemQueryCache());
             return _queryCache;
         } finally {
@@ -274,9 +274,8 @@
                     getStoreManager().getInnermostDelegate().getClass();
                 Class cls = _factory.getConfiguration().
                     getStoreFacadeTypeRegistry().
-                    getImplementation(FetchPlan.class, storeType);
-                if (cls == null)
-                    cls = FetchPlan.class;
+                    getImplementation(FetchPlan.class, storeType, 
+                    		FetchPlanImpl.class);
                 _plan = cls.getConstructor(FetchConfiguration.class);
             }
             return _plan.newInstance(fetch);

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java Wed Sep  6 06:52:35 2006
@@ -614,7 +614,7 @@
                 getMetaDataRepositoryInstance().getSequenceMetaData(name,
                 _broker.getClassLoader(), true);
             Seq seq = meta.getInstance(_broker.getClassLoader());
-            return new Generator(seq, name, _broker, null);
+            return new GeneratorImpl(seq, name, _broker, null);
         } catch (RuntimeException re) {
             throw PersistenceExceptions.toPersistenceException(re);
         }
@@ -626,7 +626,7 @@
                 getMetaDataRepositoryInstance().getMetaData(forClass,
                 _broker.getClassLoader(), true);
             Seq seq = _broker.getIdentitySequence(meta);
-            return (seq == null) ? null : new Generator(seq, null, _broker,
+            return (seq == null) ? null : new GeneratorImpl(seq, null, _broker,
                 meta);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
@@ -644,7 +644,7 @@
                     forClass, fieldName), null, null, false);
 
             Seq seq = _broker.getValueSequence(fmd);
-            return (seq == null) ? null : new Generator(seq, null, _broker,
+            return (seq == null) ? null : new GeneratorImpl(seq, null, _broker,
                 meta);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
@@ -652,7 +652,7 @@
     }
 
     public <T> Extent<T> createExtent(Class<T> cls, boolean subclasses) {
-        return new Extent<T>(this, _broker.newExtent(cls, subclasses));
+        return new ExtentImpl<T>(this, _broker.newExtent(cls, subclasses));
     }
 
     public OpenJPAQuery createQuery(String query) {

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Extent.java Wed Sep  6 06:52:35 2006
@@ -24,113 +24,56 @@
  * An extent is a logical view of all instances of a class.
  *
  * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.0
  * @published
  */
-public class Extent<T>
-    implements Iterable {
+public interface Extent<T>
+    extends Iterable<T> {
 
-    private final EntityManagerImpl _em;
-    private final DelegatingExtent _extent;
-    private FetchPlan _fetch = null;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public Extent(EntityManagerImpl em,
-        org.apache.openjpa.kernel.Extent extent) {
-        _em = em;
-        _extent = new DelegatingExtent(extent,
-            PersistenceExceptions.getRollbackTranslator(em));
-    }
 
     /**
      * Delegate.
      */
-    public org.apache.openjpa.kernel.Extent getDelegate() {
-        return _extent.getDelegate();
-    }
+    public org.apache.openjpa.kernel.Extent getDelegate();
 
     /**
      * The extent's element type.
      */
-    public Class<T> getElementClass() {
-        return _extent.getElementType();
-    }
+    public Class<T> getElementClass();
 
     /**
      * Whether the extent includes subclasses.
      */
-    public boolean hasSubclasses() {
-        return _extent.hasSubclasses();
-    }
+    public boolean hasSubclasses();
 
     /**
      * The owning entity manager.
      */
-    public OpenJPAEntityManager getEntityManager() {
-        return _em;
-    }
+    public OpenJPAEntityManager getEntityManager();
 
     /**
      * Fetch configuration for controlling how iterated objects are loaded.
      */
-    public FetchPlan getFetchPlan() {
-        _extent.lock();
-        try {
-            if (_fetch == null)
-                _fetch = ((EntityManagerFactoryImpl) _em.
-                    getEntityManagerFactory()).toFetchPlan(_extent.getBroker(),
-                    _extent.getFetchConfiguration());
-            return _fetch;
-        } finally {
-            _extent.unlock();
-        }
-    }
+    public FetchPlan getFetchPlan();
 
     /**
      * Whether the extent sees inserts and deletes in the current transaction.
      */
-    public boolean getIgnoreChanges() {
-        return _extent.getIgnoreChanges();
-    }
+    public boolean getIgnoreChanges();
 
     /**
      * Whether the extent sees inserts and deletes in the current transaction.
      */
-    public void setIgnoreChanges(boolean ignoreChanges) {
-        _extent.setIgnoreChanges(ignoreChanges);
-    }
+    public void setIgnoreChanges(boolean ignoreChanges);
 
     /**
      * List the extent contents.
      */
-    public List<T> list() {
-        return _extent.list();
-    }
-
-    /**
-     * Iterator over contents.
-     */
-    public Iterator<T> iterator() {
-        return _extent.iterator();
-    }
+    public List<T> list();
 
     /**
      * Close all open iterators that are consuming database resources.
      */
-    public void closeAll() {
-        _extent.closeAll();
-    }
-
-    public int hashCode() {
-        return _extent.hashCode();
-    }
-
-    public boolean equals(Object other) {
-        if (other == this)
-            return true;
-        if (!(other instanceof Extent))
-            return false;
-        return _extent.equals(((Extent) other)._extent);
-	}
+    public void closeAll();
 }

Added: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,109 @@
+/*
+ * 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.persistence;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openjpa.kernel.DelegatingExtent;
+
+/**
+ * An extent is a logical view of all instances of a class.
+ *
+ * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.1
+ * @nojavadoc
+ */
+public class ExtentImpl<T>
+    implements Extent<T> {
+
+    private final EntityManagerImpl _em;
+    private final DelegatingExtent _extent;
+    private FetchPlan _fetch = null;
+
+
+    /**
+     * Constructor; supply delegate.
+     */
+    public ExtentImpl(EntityManagerImpl em,
+        org.apache.openjpa.kernel.Extent extent) {
+        _em = em;
+        _extent = new DelegatingExtent(extent,
+            PersistenceExceptions.getRollbackTranslator(em));
+    }
+
+    public org.apache.openjpa.kernel.Extent getDelegate() {
+        return _extent.getDelegate();
+    }
+
+    public Class<T> getElementClass() {
+        return _extent.getElementType();
+    }
+
+    public boolean hasSubclasses() {
+        return _extent.hasSubclasses();
+    }
+
+    public OpenJPAEntityManager getEntityManager() {
+        return _em;
+    }
+
+    public FetchPlan getFetchPlan() {
+        _extent.lock();
+        try {
+            if (_fetch == null)
+                _fetch = ((EntityManagerFactoryImpl) _em.
+                    getEntityManagerFactory()).toFetchPlan(_extent.getBroker(),
+                    _extent.getFetchConfiguration());
+            return _fetch;
+        } finally {
+            _extent.unlock();
+        }
+    }
+
+    public boolean getIgnoreChanges() {
+        return _extent.getIgnoreChanges();
+    }
+
+    public void setIgnoreChanges(boolean ignoreChanges) {
+        _extent.setIgnoreChanges(ignoreChanges);
+    }
+
+    public List<T> list() {
+        return _extent.list();
+    }
+
+    public Iterator<T> iterator() {
+        return _extent.iterator();
+    }
+
+    public void closeAll() {
+        _extent.closeAll();
+    }
+
+    public int hashCode() {
+        return _extent.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof ExtentImpl))
+            return false;
+        return _extent.equals(((ExtentImpl) other)._extent);
+	}
+}

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java Wed Sep  6 06:52:35 2006
@@ -30,10 +30,11 @@
  * configuration and other aspects of data loading.
  *
  * @author Abe White
- * @since 0.4.0
+ * @author Pinaki Poddar
+ * @since 0.4.1
  * @published
  */
-public class FetchPlan {
+public interface FetchPlan {
 
     /**
      * Fetch group representing all fields.
@@ -55,64 +56,35 @@
      */
     public static final int DEFAULT = FetchConfiguration.DEFAULT;
 
-    private final DelegatingFetchConfiguration _fetch;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public FetchPlan(FetchConfiguration fetch) {
-        _fetch = newDelegatingFetchConfiguration(fetch);
-    }
-
-    /**
-     * Create a new exception-translating delegating fetch configuration.
-     */
-    protected DelegatingFetchConfiguration newDelegatingFetchConfiguration
-        (FetchConfiguration fetch) {
-        return new DelegatingFetchConfiguration(fetch,
-            PersistenceExceptions.TRANSLATOR);
-    }
 
     /**
      * Delegate.
      */
-    public FetchConfiguration getDelegate() {
-        return _fetch.getDelegate();
-    }
+    public FetchConfiguration getDelegate();
 
     /**
      * The maximum fetch depth when loading an object.
      */
-    public int getMaxFetchDepth() {
-        return _fetch.getMaxFetchDepth();
-    }
+    public int getMaxFetchDepth();
 
     /**
      * The maximum fetch depth when loading an object.
      */
-    public FetchPlan setMaxFetchDepth(int depth) {
-        _fetch.setMaxFetchDepth(depth);
-        return this;
-    }
+    public FetchPlan setMaxFetchDepth(int depth);
 
     /**
      * Return the fetch batch size for large result set support.
      * Defaults to the	<code>openjpa.FetchBatchSize</code> setting. Note
      * that this property will be ignored under some data stores.
      */
-    public int getFetchBatchSize() {
-        return _fetch.getFetchBatchSize();
-    }
+    public int getFetchBatchSize();
 
     /**
      * Set the fetch batch size for large result set support.
      * Defaults to the	<code>openjpa.FetchBatchSize</code> setting. Note
      * that this property will be ignored under some data stores.
      */
-    public FetchPlan setFetchBatchSize(int fetchBatchSize) {
-        _fetch.setFetchBatchSize(fetchBatchSize);
-        return this;
-    }
+    public FetchPlan setFetchBatchSize(int fetchBatchSize);
 
     /**
      * Return whether or not query caching is enabled. If this returns
@@ -121,79 +93,55 @@
      * returns <code>false</code>, query caching will not be used
      * even if the datacache plugin is installed.
      */
-    public boolean getQueryResultCache() {
-        return _fetch.getQueryCache();
-    }
+    public boolean getQueryResultCache();
 
     /**
      * Control whether or not query caching is enabled. This has no effect
      * if the datacache plugin is not installed, or if the query cache size
      * is set to zero.
      */
-    public FetchPlan setQueryResultCache(boolean cache) {
-        _fetch.setQueryCache(cache);
-        return this;
-    }
+    public FetchPlan setQueryResultCache(boolean cache);
 
     /**
      * Returns the names of the fetch groups that this component will use
      * when loading objects. Defaults to the
      * <code>org.apache.openjpa.FetchGroups</code> setting.
      */
-    public Collection<String> getFetchGroups() {
-        return _fetch.getFetchGroups();
-    }
+    public Collection<String> getFetchGroups();
 
     /**
      * Adds <code>group</code> to the set of fetch group to
      * use when loading objects.
      */
-    public FetchPlan addFetchGroup(String group) {
-        _fetch.addFetchGroup(group);
-        return this;
-    }
+    public FetchPlan addFetchGroup(String group);
 
     /**
      * Adds <code>groups</code> to the set of fetch group names to
      * use when loading objects.
      */
-    public FetchPlan addFetchGroups(String... groups) {
-        return addFetchGroups(Arrays.asList(groups));
-    }
-
+    public FetchPlan addFetchGroups(String... groups);
     /**
      * Adds <code>groups</code> to the set of fetch group names to
      * use when loading objects.
      */
-    public FetchPlan addFetchGroups(Collection groups) {
-        _fetch.addFetchGroups(groups);
-        return this;
-    }
+    public FetchPlan addFetchGroups(Collection groups);
 
     /**
      * Remove the given fetch group.
      */
-    public FetchPlan removeFetchGroup(String group) {
-        _fetch.removeFetchGroup(group);
-        return this;
-    }
+    public FetchPlan removeFetchGroup(String group);
 
     /**
      * Removes <code>groups</code> from the set of fetch group names
      * to use when loading objects.
      */
-    public FetchPlan removeFetchGroups(String... groups) {
-        return removeFetchGroups(Arrays.asList(groups));
-    }
+    public FetchPlan removeFetchGroups(String... groups);
 
     /**
      * Removes <code>groups</code> from the set of fetch group names
      * to use when loading objects.
      */
-    public FetchPlan removeFetchGroups(Collection groups) {
-        _fetch.removeFetchGroups(groups);
-        return this;
-    }
+    public FetchPlan removeFetchGroups(Collection groups);
 
     /**
      * Clears the set of fetch group names to use wen loading
@@ -201,224 +149,135 @@
      * the default fetch group (and any requested field) will be
      * loaded when loading an object.
      */
-    public FetchPlan clearFetchGroups() {
-        _fetch.clearFetchGroups();
-        return this;
-    }
+    public FetchPlan clearFetchGroups();
 
     /**
      * Resets the set of fetch groups to the list in the global configuration.
      */
-    public FetchPlan resetFetchGroups() {
-        _fetch.resetFetchGroups();
-        return this;
-    }
+    public FetchPlan resetFetchGroups();
 
     /**
      * Returns the fully qualified names of the fields that this component
      * will use when loading objects. Defaults to the empty set.
      */
-    public Collection<String> getFields() {
-        return (Collection<String>) _fetch.getFields();
-    }
+    public Collection<String> getFields();
 
     /**
      * Return true if the given field has been added.
      */
-    public boolean hasField(String field) {
-        return _fetch.hasField(field);
-    }
+    public boolean hasField(String field);
 
     /**
      * Return true if the given field has been added.
      */
-    public boolean hasField(Class cls, String field) {
-        return hasField(toFieldName(cls, field));
-    }
+    public boolean hasField(Class cls, String field);
 
     /**
      * Adds <code>field</code> to the set of fully-qualified field names to
      * use when loading objects.
      */
-    public FetchPlan addField(String field) {
-        _fetch.addField(field);
-        return this;
-    }
+    public FetchPlan addField(String field);
 
     /**
      * Adds <code>field</code> to the set of field names to
      * use when loading objects.
      */
-    public FetchPlan addField(Class cls, String field) {
-        return addField(toFieldName(cls, field));
-    }
+    public FetchPlan addField(Class cls, String field);
 
     /**
      * Adds <code>fields</code> to the set of fully-qualified field names to
      * use when loading objects.
      */
-    public FetchPlan addFields(String... fields) {
-        return addFields(Arrays.asList(fields));
-    }
+    public FetchPlan addFields(String... fields);
 
     /**
      * Adds <code>fields</code> to the set of field names to
      * use when loading objects.
      */
-    public FetchPlan addFields(Class cls, String... fields) {
-        return addFields(cls, Arrays.asList(fields));
-    }
+    public FetchPlan addFields(Class cls, String... fields);
 
     /**
      * Adds <code>fields</code> to the set of fully-qualified field names to
      * use when loading objects.
      */
-    public FetchPlan addFields(Collection fields) {
-        _fetch.addFields(fields);
-        return this;
-    }
+    public FetchPlan addFields(Collection fields);
 
     /**
      * Adds <code>fields</code> to the set of field names to
      * use when loading objects.
      */
-    public FetchPlan addFields(Class cls, Collection fields) {
-        return addFields(toFieldNames(cls, fields));
-    }
+    public FetchPlan addFields(Class cls, Collection fields);
 
     /**
      * Remove the given fully-qualified field.
      */
-    public FetchPlan removeField(String field) {
-        _fetch.removeField(field);
-        return this;
-    }
+    public FetchPlan removeField(String field);
 
     /**
      * Remove the given field.
      */
-    public FetchPlan removeField(Class cls, String field) {
-        return removeField(toFieldName(cls, field));
-    }
+    public FetchPlan removeField(Class cls, String field);
 
     /**
      * Removes <code>fields</code> from the set of fully-qualified field names
      * to use when loading objects.
      */
-    public FetchPlan removeFields(String... fields) {
-        return removeFields(Arrays.asList(fields));
-    }
+    public FetchPlan removeFields(String... fields);
 
     /**
      * Removes <code>fields</code> from the set of field names
      * to use when loading objects.
      */
-    public FetchPlan removeFields(Class cls, String... fields) {
-        return removeFields(cls, Arrays.asList(fields));
-    }
+    public FetchPlan removeFields(Class cls, String... fields);
 
     /**
      * Removes <code>fields</code> from the set of fully-qualified field names
      * to use when loading objects.
      */
-    public FetchPlan removeFields(Collection fields) {
-        _fetch.removeFields(fields);
-        return this;
-    }
+    public FetchPlan removeFields(Collection fields);
 
     /**
      * Removes <code>fields</code> from the set of field names
      * to use when loading objects.
      */
-    public FetchPlan removeFields(Class cls, Collection fields) {
-        return removeFields(toFieldNames(cls, fields));
-    }
+    public FetchPlan removeFields(Class cls, Collection fields);
 
     /**
      * Clears the set of field names to use wen loading
      * data. After this operation is invoked, only those fields in
      * the configured fetch groups will be loaded when loading an object.
      */
-    public FetchPlan clearFields() {
-        _fetch.clearFields();
-        return this;
-    }
-
-    /**
-     * Combine the class and field to a fully-qualified field name.
-     */
-    private static String toFieldName(Class cls, String field) {
-        return cls.getName() + "." + field;
-    }
-
-    /**
-     * Combine the class and fields to fully-qualified field names.
-     */
-    private static Collection toFieldNames(Class cls, Collection fields) {
-        if (fields.isEmpty())
-            return fields;
-        Collection names = new ArrayList(fields);
-        for (Iterator itr = fields.iterator(); itr.hasNext();)
-            names.add(toFieldName(cls, (String) itr.next()));
-        return names;
-    }
+    public FetchPlan clearFields();
 
     /**
      * The number of milliseconds to wait for an object lock, or -1 for no
      * limit.
      */
-    public int getLockTimeout() {
-        return _fetch.getLockTimeout();
-    }
+    public int getLockTimeout();
 
     /**
      * The number of milliseconds to wait for an object lock, or -1 for no
      * limit.
      */
-    public FetchPlan setLockTimeout(int timeout) {
-        _fetch.setLockTimeout(timeout);
-        return this;
-    }
+    public FetchPlan setLockTimeout(int timeout);
 
     /**
      * The lock level to use for locking loaded objects.
      */
-    public LockModeType getReadLockMode() {
-        return EntityManagerImpl.fromLockLevel(_fetch.getReadLockLevel());
-    }
+    public LockModeType getReadLockMode();
 
     /**
      * The lock level to use for locking loaded objects.
      */
-    public FetchPlan setReadLockMode(LockModeType mode) {
-        _fetch.setReadLockLevel(EntityManagerImpl.toLockLevel(mode));
-        return this;
-    }
+    public FetchPlan setReadLockMode(LockModeType mode);
 
     /**
      * The lock level to use for locking dirtied objects.
      */
-    public LockModeType getWriteLockMode() {
-        return EntityManagerImpl.fromLockLevel(_fetch.getWriteLockLevel());
-    }
+    public LockModeType getWriteLockMode();
 
     /**
      * The lock level to use for locking dirtied objects.
      */
-    public FetchPlan setWriteLockMode(LockModeType mode) {
-        _fetch.setWriteLockLevel(EntityManagerImpl.toLockLevel(mode));
-        return this;
-    }
-
-    public int hashCode() {
-        return _fetch.hashCode();
-    }
-
-    public boolean equals(Object other) {
-        if (other == this)
-            return true;
-        if (!(other instanceof FetchPlan))
-            return false;
-        return _fetch.equals(((FetchPlan) other)._fetch);
-    }
+    public FetchPlan setWriteLockMode(LockModeType mode);
 }

Added: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,406 @@
+/*
+ * 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.persistence;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import javax.persistence.LockModeType;
+
+import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
+import org.apache.openjpa.kernel.FetchConfiguration;
+import org.apache.openjpa.meta.FetchGroup;
+
+/**
+ * Implements FetchPlan via delegation to FetchConfiguration.
+ *
+ * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.1
+ * @nojavadoc
+ */
+public class FetchPlanImpl
+	implements FetchPlan {
+
+    private final DelegatingFetchConfiguration _fetch;
+
+    
+    /**
+     * Constructor; supply delegate.
+     */
+    public FetchPlanImpl(FetchConfiguration fetch) {
+        _fetch = newDelegatingFetchConfiguration(fetch);
+    }
+
+    /**
+     * Create a new exception-translating delegating fetch configuration.
+     */
+    protected DelegatingFetchConfiguration newDelegatingFetchConfiguration
+        (FetchConfiguration fetch) {
+        return new DelegatingFetchConfiguration(fetch,
+            PersistenceExceptions.TRANSLATOR);
+    }
+
+    /**
+     * Delegate.
+     */
+    public FetchConfiguration getDelegate() {
+        return _fetch.getDelegate();
+    }
+
+    /**
+     * The maximum fetch depth when loading an object.
+     */
+    public int getMaxFetchDepth() {
+        return _fetch.getMaxFetchDepth();
+    }
+
+    /**
+     * The maximum fetch depth when loading an object.
+     */
+    public FetchPlan setMaxFetchDepth(int depth) {
+        _fetch.setMaxFetchDepth(depth);
+        return this;
+    }
+
+    /**
+     * Return the fetch batch size for large result set support.
+     * Defaults to the	<code>openjpa.FetchBatchSize</code> setting. Note
+     * that this property will be ignored under some data stores.
+     */
+    public int getFetchBatchSize() {
+        return _fetch.getFetchBatchSize();
+    }
+
+    /**
+     * Set the fetch batch size for large result set support.
+     * Defaults to the	<code>openjpa.FetchBatchSize</code> setting. Note
+     * that this property will be ignored under some data stores.
+     */
+    public FetchPlan setFetchBatchSize(int fetchBatchSize) {
+        _fetch.setFetchBatchSize(fetchBatchSize);
+        return this;
+    }
+
+    /**
+     * Return whether or not query caching is enabled. If this returns
+     * <code>true</code> but the datacache plugin is not installed, caching
+     * will not be enabled. If this
+     * returns <code>false</code>, query caching will not be used
+     * even if the datacache plugin is installed.
+     */
+    public boolean getQueryResultCache() {
+        return _fetch.getQueryCache();
+    }
+
+    /**
+     * Control whether or not query caching is enabled. This has no effect
+     * if the datacache plugin is not installed, or if the query cache size
+     * is set to zero.
+     */
+    public FetchPlan setQueryResultCache(boolean cache) {
+        _fetch.setQueryCache(cache);
+        return this;
+    }
+
+    /**
+     * Returns the names of the fetch groups that this component will use
+     * when loading objects. Defaults to the
+     * <code>org.apache.openjpa.FetchGroups</code> setting.
+     */
+    public Collection<String> getFetchGroups() {
+        return _fetch.getFetchGroups();
+    }
+
+    /**
+     * Adds <code>group</code> to the set of fetch group to
+     * use when loading objects.
+     */
+    public FetchPlan addFetchGroup(String group) {
+        _fetch.addFetchGroup(group);
+        return this;
+    }
+
+    /**
+     * Adds <code>groups</code> to the set of fetch group names to
+     * use when loading objects.
+     */
+    public FetchPlan addFetchGroups(String... groups) {
+        return addFetchGroups(Arrays.asList(groups));
+    }
+
+    /**
+     * Adds <code>groups</code> to the set of fetch group names to
+     * use when loading objects.
+     */
+    public FetchPlan addFetchGroups(Collection groups) {
+        _fetch.addFetchGroups(groups);
+        return this;
+    }
+
+    /**
+     * Remove the given fetch group.
+     */
+    public FetchPlan removeFetchGroup(String group) {
+        _fetch.removeFetchGroup(group);
+        return this;
+    }
+
+    /**
+     * Removes <code>groups</code> from the set of fetch group names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFetchGroups(String... groups) {
+        return removeFetchGroups(Arrays.asList(groups));
+    }
+
+    /**
+     * Removes <code>groups</code> from the set of fetch group names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFetchGroups(Collection groups) {
+        _fetch.removeFetchGroups(groups);
+        return this;
+    }
+
+    /**
+     * Clears the set of fetch group names to use wen loading
+     * data. After this operation is invoked, only those fields in
+     * the default fetch group (and any requested field) will be
+     * loaded when loading an object.
+     */
+    public FetchPlan clearFetchGroups() {
+        _fetch.clearFetchGroups();
+        return this;
+    }
+
+    /**
+     * Resets the set of fetch groups to the list in the global configuration.
+     */
+    public FetchPlan resetFetchGroups() {
+        _fetch.resetFetchGroups();
+        return this;
+    }
+
+    /**
+     * Returns the fully qualified names of the fields that this component
+     * will use when loading objects. Defaults to the empty set.
+     */
+    public Collection<String> getFields() {
+        return (Collection<String>) _fetch.getFields();
+    }
+
+    /**
+     * Return true if the given field has been added.
+     */
+    public boolean hasField(String field) {
+        return _fetch.hasField(field);
+    }
+
+    /**
+     * Return true if the given field has been added.
+     */
+    public boolean hasField(Class cls, String field) {
+        return hasField(toFieldName(cls, field));
+    }
+
+    /**
+     * Adds <code>field</code> to the set of fully-qualified field names to
+     * use when loading objects.
+     */
+    public FetchPlan addField(String field) {
+        _fetch.addField(field);
+        return this;
+    }
+
+    /**
+     * Adds <code>field</code> to the set of field names to
+     * use when loading objects.
+     */
+    public FetchPlan addField(Class cls, String field) {
+        return addField(toFieldName(cls, field));
+    }
+
+    /**
+     * Adds <code>fields</code> to the set of fully-qualified field names to
+     * use when loading objects.
+     */
+    public FetchPlan addFields(String... fields) {
+        return addFields(Arrays.asList(fields));
+    }
+
+    /**
+     * Adds <code>fields</code> to the set of field names to
+     * use when loading objects.
+     */
+    public FetchPlan addFields(Class cls, String... fields) {
+        return addFields(cls, Arrays.asList(fields));
+    }
+
+    /**
+     * Adds <code>fields</code> to the set of fully-qualified field names to
+     * use when loading objects.
+     */
+    public FetchPlan addFields(Collection fields) {
+        _fetch.addFields(fields);
+        return this;
+    }
+
+    /**
+     * Adds <code>fields</code> to the set of field names to
+     * use when loading objects.
+     */
+    public FetchPlan addFields(Class cls, Collection fields) {
+        return addFields(toFieldNames(cls, fields));
+    }
+
+    /**
+     * Remove the given fully-qualified field.
+     */
+    public FetchPlan removeField(String field) {
+        _fetch.removeField(field);
+        return this;
+    }
+
+    /**
+     * Remove the given field.
+     */
+    public FetchPlan removeField(Class cls, String field) {
+        return removeField(toFieldName(cls, field));
+    }
+
+    /**
+     * Removes <code>fields</code> from the set of fully-qualified field names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFields(String... fields) {
+        return removeFields(Arrays.asList(fields));
+    }
+
+    /**
+     * Removes <code>fields</code> from the set of field names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFields(Class cls, String... fields) {
+        return removeFields(cls, Arrays.asList(fields));
+    }
+
+    /**
+     * Removes <code>fields</code> from the set of fully-qualified field names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFields(Collection fields) {
+        _fetch.removeFields(fields);
+        return this;
+    }
+
+    /**
+     * Removes <code>fields</code> from the set of field names
+     * to use when loading objects.
+     */
+    public FetchPlan removeFields(Class cls, Collection fields) {
+        return removeFields(toFieldNames(cls, fields));
+    }
+
+    /**
+     * Clears the set of field names to use wen loading
+     * data. After this operation is invoked, only those fields in
+     * the configured fetch groups will be loaded when loading an object.
+     */
+    public FetchPlan clearFields() {
+        _fetch.clearFields();
+        return this;
+    }
+
+    /**
+     * Combine the class and field to a fully-qualified field name.
+     */
+    private static String toFieldName(Class cls, String field) {
+        return cls.getName() + "." + field;
+    }
+
+    /**
+     * Combine the class and fields to fully-qualified field names.
+     */
+    private static Collection toFieldNames(Class cls, Collection fields) {
+        if (fields.isEmpty())
+            return fields;
+        Collection names = new ArrayList(fields);
+        for (Iterator itr = fields.iterator(); itr.hasNext();)
+            names.add(toFieldName(cls, (String) itr.next()));
+        return names;
+    }
+
+    /**
+     * The number of milliseconds to wait for an object lock, or -1 for no
+     * limit.
+     */
+    public int getLockTimeout() {
+        return _fetch.getLockTimeout();
+    }
+
+    /**
+     * The number of milliseconds to wait for an object lock, or -1 for no
+     * limit.
+     */
+    public FetchPlan setLockTimeout(int timeout) {
+        _fetch.setLockTimeout(timeout);
+        return this;
+    }
+
+    /**
+     * The lock level to use for locking loaded objects.
+     */
+    public LockModeType getReadLockMode() {
+        return EntityManagerImpl.fromLockLevel(_fetch.getReadLockLevel());
+    }
+
+    /**
+     * The lock level to use for locking loaded objects.
+     */
+    public FetchPlan setReadLockMode(LockModeType mode) {
+        _fetch.setReadLockLevel(EntityManagerImpl.toLockLevel(mode));
+        return this;
+    }
+
+    /**
+     * The lock level to use for locking dirtied objects.
+     */
+    public LockModeType getWriteLockMode() {
+        return EntityManagerImpl.fromLockLevel(_fetch.getWriteLockLevel());
+    }
+
+    /**
+     * The lock level to use for locking dirtied objects.
+     */
+    public FetchPlan setWriteLockMode(LockModeType mode) {
+        _fetch.setWriteLockLevel(EntityManagerImpl.toLockLevel(mode));
+        return this;
+    }
+
+    public int hashCode() {
+        return _fetch.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof FetchPlanImpl))
+            return false;
+        return _fetch.equals(((FetchPlanImpl) other)._fetch);
+    }
+}

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/Generator.java Wed Sep  6 06:52:35 2006
@@ -24,76 +24,39 @@
  * Represents a store sequence.
  *
  * @author Abe White
- * @since 0.4.0
+ * @author Pinaki Poddar
+ * @since 0.4.1
  * @published
  */
-public class Generator {
+public interface Generator {
 
     public static final String UUID_HEX = "uuid-hex";
     public static final String UUID_STRING = "uuid-string";
 
-    private final DelegatingSeq _seq;
-    private final String _name;
-    private final StoreContext _ctx;
-    private final ClassMetaData _meta;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public Generator(Seq seq, String name, StoreContext ctx,
-        ClassMetaData meta) {
-        _seq = new DelegatingSeq(seq, PersistenceExceptions.TRANSLATOR);
-        _name = name;
-        _ctx = ctx;
-        _meta = meta;
-    }
-
     /**
      * Delegate.
      */
-    public Seq getDelegate() {
-        return _seq.getDelegate();
-    }
+    public Seq getDelegate();
 
     /**
      * The sequence name.
      */
-    public String getName() {
-        return _name;
-    }
+    public String getName();
 
     /**
      * The next sequence value.
      */
-    public Object next() {
-        return _seq.next(_ctx, _meta);
-    }
+    public Object next();
 
     /**
      * The current sequence value, or null if the sequence does not
      * support current values.
      */
-    public Object current() {
-        return _seq.current(_ctx, _meta);
-    }
+    public Object current();
 
     /**
      * Hint to the sequence to allocate additional values up-front for
      * efficiency.
      */
-    public void allocate(int additional) {
-        _seq.allocate(additional, _ctx, _meta);
-    }
-
-    public int hashCode() {
-        return _seq.hashCode();
-    }
-
-    public boolean equals(Object other) {
-        if (other == this)
-            return true;
-        if (!(other instanceof Generator))
-            return false;
-        return _seq.equals(((Generator) other)._seq);
-	}
+    public void allocate(int additional);
 }

Added: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/GeneratorImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,81 @@
+/*
+ * 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.persistence;
+
+import org.apache.openjpa.kernel.DelegatingSeq;
+import org.apache.openjpa.kernel.Seq;
+import org.apache.openjpa.kernel.StoreContext;
+import org.apache.openjpa.meta.ClassMetaData;
+
+/**
+ * Represents a store sequence.
+ *
+ * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.1
+ * @nojavadoc
+ */
+public class GeneratorImpl
+	implements Generator {
+
+    private final DelegatingSeq _seq;
+    private final String _name;
+    private final StoreContext _ctx;
+    private final ClassMetaData _meta;
+
+    /**
+     * Constructor; supply delegate.
+     */
+    public GeneratorImpl(Seq seq, String name, StoreContext ctx,
+        ClassMetaData meta) {
+        _seq = new DelegatingSeq(seq, PersistenceExceptions.TRANSLATOR);
+        _name = name;
+        _ctx = ctx;
+        _meta = meta;
+    }
+
+    public Seq getDelegate() {
+        return _seq.getDelegate();
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public Object next() {
+        return _seq.next(_ctx, _meta);
+    }
+
+    public Object current() {
+        return _seq.current(_ctx, _meta);
+    }
+
+    public void allocate(int additional) {
+        _seq.allocate(additional, _ctx, _meta);
+    }
+
+    public int hashCode() {
+        return _seq.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof GeneratorImpl))
+            return false;
+        return _seq.equals(((GeneratorImpl) other)._seq);
+	}
+}

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java Wed Sep  6 06:52:35 2006
@@ -79,7 +79,7 @@
             OpenJPAEntityManagerFactory emf = (OpenJPAEntityManagerFactory)
                 factory.getUserObject(EMF_KEY);
             if (emf == null) {
-                emf = new EntityManagerFactoryImpl(factory);
+                emf = newEntityManagerFactory(factory);
                 factory.putUserObject(EMF_KEY, emf);
             }
             return emf;
@@ -90,6 +90,10 @@
         }
     }
 
+    protected static OpenJPAEntityManagerFactory newEntityManagerFactory(BrokerFactory factory) {
+		return new EntityManagerFactoryImpl(factory);
+	}
+    
     /**
      * Return the underlying broker factory for the given persistence manager
      * factory facade.
@@ -125,6 +129,8 @@
             broker.unlock();
         }
     }
+    
+     
 
     /**
      * Return the underlying broker for the given entity manager facade.

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java Wed Sep  6 06:52:35 2006
@@ -17,6 +17,7 @@
 
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.IllegalClassFormatException;
+import java.lang.reflect.Method;
 import java.security.ProtectionDomain;
 import java.util.Map;
 import java.util.Properties;
@@ -31,6 +32,8 @@
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.enhance.PCClassFileTransformer;
 import org.apache.openjpa.kernel.Bootstrap;
+import org.apache.openjpa.kernel.BrokerFactory;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.meta.MetaDataModes;
 import org.apache.openjpa.meta.MetaDataRepository;
@@ -43,7 +46,7 @@
  * @see Persistence#createEntityManagerFactory(String,Map)
  */
 public class PersistenceProviderImpl
-    implements PersistenceProvider {
+    implements PersistenceProvider, PersistenceProviderExtension {
 
     static final String CLASS_TRANSFORMER_OPTIONS =
         "openjpa.ClassTransformerOptions";
@@ -60,13 +63,13 @@
      */
     public EntityManagerFactory createEntityManagerFactory(String name,
         String resource, Map m) {
-        ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
+        ConfigurationProviderImpl cp = newConfigurationProviderImpl();
         try {
             if (cp.load(resource, name, m))
-                return OpenJPAPersistence.toEntityManagerFactory(
-                    Bootstrap.newBrokerFactory(cp, cp.getClassLoader()));
+            	return toEntityManagerFactory(
+            		Bootstrap.newBrokerFactory(cp, cp.getClassLoader()));
             else
-                return null;
+                 return null;
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
         }
@@ -78,11 +81,10 @@
 
     public EntityManagerFactory createContainerEntityManagerFactory(
         PersistenceUnitInfo pui, Map map) {
-        ConfigurationProviderImpl cp = new ConfigurationProviderImpl();
+        ConfigurationProviderImpl cp = newConfigurationProviderImpl();
         try {
             if (cp.load(pui, map)) {
-                OpenJPAEntityManagerFactory emf =
-                    OpenJPAPersistence.toEntityManagerFactory(
+                OpenJPAEntityManagerFactory emf = toEntityManagerFactory(
                         Bootstrap.newBrokerFactory(cp, cp.getClassLoader()));
                 Properties p = pui.getProperties();
                 String ctOpts = null;
@@ -98,7 +100,15 @@
             throw PersistenceExceptions.toPersistenceException(e);
         }
     }
-
+    
+    public ConfigurationProviderImpl newConfigurationProviderImpl() {
+    	return new ConfigurationProviderImpl();
+    }
+    
+    public OpenJPAEntityManagerFactory toEntityManagerFactory(BrokerFactory factory) {
+    	return OpenJPAPersistence.toEntityManagerFactory(factory);
+    }
+    
     /**
      * Java EE 5 class transformer.
      */

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCache.java Wed Sep  6 06:52:35 2006
@@ -27,88 +27,38 @@
  * Query result cache.
  *
  * @author Abe White
- * @since 0.4.0
+ * @since 0.4.1
  * @published
  */
-public class QueryResultCache {
-
-    private final DelegatingQueryCache _cache;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public QueryResultCache(QueryCache cache) {
-        _cache = new DelegatingQueryCache(cache,
-            PersistenceExceptions.TRANSLATOR);
-    }
+public interface QueryResultCache {
 
     /**
      * Delegate.
      */
-    public QueryCache getDelegate() {
-        return _cache.getDelegate();
-    }
+    public QueryCache getDelegate();
 
     /**
      * Pin the given query's result to the cache.
      */
-    public void pin(Query q) {
-        if (_cache.getDelegate() != null)
-            _cache.pin(toQueryKey(q));
-    }
+    public void pin(Query q);
 
     /**
      * Unpin a previously-pinned query result.
      */
-    public void unpin(Query q) {
-        if (_cache.getDelegate() != null)
-            _cache.unpin(toQueryKey(q));
-    }
+    public void unpin(Query q);
 
     /**
      * Evict a query result from the cache.
      */
-    public void evict(Query q) {
-        if (_cache.getDelegate() != null)
-            _cache.remove(toQueryKey(q));
-    }
+    public void evict(Query q);
 
     /**
      * Clear the cache.
      */
-    public void evictAll() {
-        _cache.clear();
-    }
+    public void evictAll();
 
     /**
      * Evict all result for queries involving the given class.
      */
-    public void evictAll(Class cls) {
-        _cache.onTypesChanged(new TypesChangedEvent(this,
-            Collections.singleton(cls)));
-    }
-
-    /**
-     * Return a cache key for the given query.
-     */
-    private QueryKey toQueryKey(Query q) {
-        QueryImpl impl = (QueryImpl) q;
-        if (impl.hasPositionalParameters())
-            return QueryKey.newInstance(impl.getDelegate(),
-                impl.getPositionalParameters());
-        return QueryKey.newInstance(impl.getDelegate(),
-            impl.getNamedParameters());
-    }
-
-    public int hashCode() {
-        return _cache.hashCode();
-    }
-
-    public boolean equals(Object other) {
-        if (other == this)
-            return true;
-        if (!(other instanceof QueryResultCache))
-            return false;
-        return _cache.equals(((QueryResultCache) other)._cache);
-	}
+    public void evictAll(Class cls);
 }

Added: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryResultCacheImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,116 @@
+/*
+ * 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.persistence;
+
+import java.util.Collections;
+import javax.persistence.Query;
+
+import org.apache.openjpa.datacache.DelegatingQueryCache;
+import org.apache.openjpa.datacache.QueryCache;
+import org.apache.openjpa.datacache.QueryKey;
+import org.apache.openjpa.datacache.TypesChangedEvent;
+
+/**
+ * Implements Query result cache via delegation to QueryCache.
+ *
+ * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.1
+ * @nojavadoc
+ */
+public class QueryResultCacheImpl
+	implements QueryResultCache {
+
+    private final DelegatingQueryCache _cache;
+
+    /**
+     * Constructor; supply delegate.
+     */
+    public QueryResultCacheImpl(QueryCache cache) {
+        _cache = new DelegatingQueryCache(cache,
+            PersistenceExceptions.TRANSLATOR);
+    }
+
+    /**
+     * Delegate.
+     */
+    public QueryCache getDelegate() {
+        return _cache.getDelegate();
+    }
+
+    /**
+     * Pin the given query's result to the cache.
+     */
+    public void pin(Query q) {
+        if (_cache.getDelegate() != null)
+            _cache.pin(toQueryKey(q));
+    }
+
+    /**
+     * Unpin a previously-pinned query result.
+     */
+    public void unpin(Query q) {
+        if (_cache.getDelegate() != null)
+            _cache.unpin(toQueryKey(q));
+    }
+
+    /**
+     * Evict a query result from the cache.
+     */
+    public void evict(Query q) {
+        if (_cache.getDelegate() != null)
+            _cache.remove(toQueryKey(q));
+    }
+
+    /**
+     * Clear the cache.
+     */
+    public void evictAll() {
+        _cache.clear();
+    }
+
+    /**
+     * Evict all result for queries involving the given class.
+     */
+    public void evictAll(Class cls) {
+        _cache.onTypesChanged(new TypesChangedEvent(this,
+            Collections.singleton(cls)));
+    }
+
+    /**
+     * Return a cache key for the given query.
+     */
+    private QueryKey toQueryKey(Query q) {
+        QueryImpl impl = (QueryImpl) q;
+        if (impl.hasPositionalParameters())
+            return QueryKey.newInstance(impl.getDelegate(),
+                impl.getPositionalParameters());
+        return QueryKey.newInstance(impl.getDelegate(),
+            impl.getNamedParameters());
+    }
+
+    public int hashCode() {
+        return _cache.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof QueryResultCacheImpl))
+            return false;
+        return _cache.equals(((QueryResultCacheImpl) other)._cache);
+	}
+}

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java?view=diff&rev=440714&r1=440713&r2=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCache.java Wed Sep  6 06:52:35 2006
@@ -28,169 +28,80 @@
  * Represents the L2 cache over the data store.
  *
  * @author Abe White
- * @since 0.4.0
+ * @author Pinaki Poddar
+ * @since 0.4.1
  * @published
  */
-public class StoreCache {
+public interface StoreCache {
 
     public static final String NAME_DEFAULT = DataCache.NAME_DEFAULT;
 
-    private final MetaDataRepository _repos;
-    private final DelegatingDataCache _cache;
-
-    /**
-     * Constructor; supply delegate.
-     */
-    public StoreCache(EntityManagerFactoryImpl emf, DataCache cache) {
-        _repos = emf.getConfiguration().getMetaDataRepositoryInstance();
-        _cache = new DelegatingDataCache(cache,
-            PersistenceExceptions.TRANSLATOR);
-    }
-
     /**
      * Delegate.
      */
-    public DataCache getDelegate() {
-        return _cache.getDelegate();
-    }
+    public DataCache getDelegate();
 
     /**
      * Whether the cache contains data for the given oid.
      */
-    public boolean contains(Class cls, Object oid) {
-        return _cache.getDelegate() != null
-            && _cache.contains(OpenJPAPersistence.toOpenJPAObjectId
-            (getMetaData(cls), oid));
-    }
+    public boolean contains(Class cls, Object oid);
 
     /**
      * Whether the cache contains data for the given oids.
      */
-    public boolean containsAll(Class cls, Object... oids) {
-        return containsAll(cls, Arrays.asList(oids));
-    }
+    public boolean containsAll(Class cls, Object... oids);
 
     /**
      * Whether the cache contains data for the given oids.
      */
-    public boolean containsAll(Class cls, Collection oids) {
-        if (_cache.getDelegate() == null)
-            return oids.isEmpty();
-
-        BitSet set = _cache.containsAll(OpenJPAPersistence.toOpenJPAObjectIds
-            (getMetaData(cls), oids));
-        for (int i = 0; i < oids.size(); i++)
-            if (!set.get(i))
-                return false;
-        return true;
-    }
+    public boolean containsAll(Class cls, Collection oids);
 
     /**
      * Pin the data for the given oid to the cache.
      */
-    public void pin(Class cls, Object oid) {
-        if (_cache.getDelegate() != null)
-            _cache.pin(
-                OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), oid));
-    }
+    public void pin(Class cls, Object oid);
 
     /**
      * Pin the data for the given oids to the cache.
      */
-    public void pinAll(Class cls, Object... oids) {
-        pinAll(cls, Arrays.asList(oids));
-    }
+    public void pinAll(Class cls, Object... oids);
 
     /**
      * Pin the data for the given oids to the cache.
      */
-    public void pinAll(Class cls, Collection oids) {
-        if (_cache.getDelegate() != null)
-            _cache
-                .pinAll(OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
-                    oids));
-    }
+    public void pinAll(Class cls, Collection oids);
 
     /**
      * Unpin the data for the given oid from the cache.
      */
-    public void unpin(Class cls, Object oid) {
-        if (_cache.getDelegate() != null)
-            _cache.unpin(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls),
-                oid));
-    }
+    public void unpin(Class cls, Object oid);
 
     /**
      * Unpin the data for the given oids from the cache.
      */
-    public void unpinAll(Class cls, Object... oids) {
-        unpinAll(cls, Arrays.asList(oids));
-    }
+    public void unpinAll(Class cls, Object... oids);
 
     /**
      * Unpin the data for the given oids from the cache.
      */
-    public void unpinAll(Class cls, Collection oids) {
-        if (_cache.getDelegate() != null)
-            _cache.unpinAll(
-                OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
-                    oids));
-    }
+    public void unpinAll(Class cls, Collection oids);
 
     /**
      * Remove data for the given oid from the cache.
      */
-    public void evict(Class cls, Object oid) {
-        if (_cache.getDelegate() != null)
-            _cache.remove(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls),
-                oid));
-    }
-
+    public void evict(Class cls, Object oid);
     /**
      * Remove data for the given oids from the cache.
      */
-    public void evictAll(Class cls, Object... oids) {
-        evictAll(cls, Arrays.asList(oids));
-    }
+    public void evictAll(Class cls, Object... oids);
 
     /**
      * Remove data for the given oids from the cache.
      */
-    public void evictAll(Class cls, Collection oids) {
-        if (_cache.getDelegate() != null)
-            _cache.removeAll(
-                OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
-                    oids));
-    }
+    public void evictAll(Class cls, Collection oids);
 
     /**
      * Clear the cache.
      */
-    public void evictAll() {
-        _cache.clear();
-    }
-
-    /**
-     * Return metadata for the given class, throwing the proper exception
-     * if not persistent.
-     */
-    private ClassMetaData getMetaData(Class cls) {
-        try {
-            return _repos.getMetaData(cls, null, true);
-        } catch (RuntimeException re) {
-            throw PersistenceExceptions.toPersistenceException(re);
-        }
-    }
-
-    public int hashCode() {
-        return _cache.hashCode();
-    }
-
-    public boolean equals(Object other) {
-        if (other == this)
-            return true;
-        if (!(other instanceof StoreCache))
-            return false;
-        return _cache.equals (((StoreCache) other)._cache);
-	}
+    public void evictAll();
 }

Added: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java?view=auto&rev=440714
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java (added)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java Wed Sep  6 06:52:35 2006
@@ -0,0 +1,156 @@
+/*
+ * 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.persistence;
+
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+
+import org.apache.openjpa.datacache.DataCache;
+import org.apache.openjpa.datacache.DelegatingDataCache;
+import org.apache.openjpa.kernel.StoreContext;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.MetaDataRepository;
+
+/**
+ * Implements the L2 cache over the data store via delegation to DataCache.
+ *
+ * @author Abe White
+ * @author Pinaki Poddar
+ * @since 0.4.1
+ * @nojavadoc
+ */
+public class StoreCacheImpl 
+	implements StoreCache {
+
+    private final MetaDataRepository _repos;
+    private final DelegatingDataCache _cache;
+
+    
+    /**
+     * Constructor; supply delegate.
+     */
+    public StoreCacheImpl(EntityManagerFactoryImpl emf, DataCache cache) {
+        _repos = emf.getConfiguration().getMetaDataRepositoryInstance();
+        _cache = new DelegatingDataCache(cache,
+            PersistenceExceptions.TRANSLATOR);
+    }
+
+    public DataCache getDelegate() {
+        return _cache.getDelegate();
+    }
+
+    public boolean contains(Class cls, Object oid) {
+        return _cache.getDelegate() != null
+            && _cache.contains(OpenJPAPersistence.toOpenJPAObjectId
+            (getMetaData(cls), oid));
+    }
+
+    public boolean containsAll(Class cls, Object... oids) {
+        return containsAll(cls, Arrays.asList(oids));
+    }
+
+    public boolean containsAll(Class cls, Collection oids) {
+        if (_cache.getDelegate() == null)
+            return oids.isEmpty();
+
+        BitSet set = _cache.containsAll(OpenJPAPersistence.toOpenJPAObjectIds
+            (getMetaData(cls), oids));
+        for (int i = 0; i < oids.size(); i++)
+            if (!set.get(i))
+                return false;
+        return true;
+    }
+
+    public void pin(Class cls, Object oid) {
+        if (_cache.getDelegate() != null)
+            _cache.pin(
+                OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls), oid));
+    }
+
+    public void pinAll(Class cls, Object... oids) {
+        pinAll(cls, Arrays.asList(oids));
+    }
+
+    public void pinAll(Class cls, Collection oids) {
+        if (_cache.getDelegate() != null)
+            _cache
+                .pinAll(OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
+                    oids));
+    }
+
+    public void unpin(Class cls, Object oid) {
+        if (_cache.getDelegate() != null)
+            _cache.unpin(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls),
+                oid));
+    }
+
+    public void unpinAll(Class cls, Object... oids) {
+        unpinAll(cls, Arrays.asList(oids));
+    }
+
+    public void unpinAll(Class cls, Collection oids) {
+        if (_cache.getDelegate() != null)
+            _cache.unpinAll(
+                OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
+                    oids));
+    }
+
+    public void evict(Class cls, Object oid) {
+        if (_cache.getDelegate() != null)
+            _cache.remove(OpenJPAPersistence.toOpenJPAObjectId(getMetaData(cls),
+                oid));
+    }
+
+    public void evictAll(Class cls, Object... oids) {
+        evictAll(cls, Arrays.asList(oids));
+    }
+
+    public void evictAll(Class cls, Collection oids) {
+        if (_cache.getDelegate() != null)
+            _cache.removeAll(
+                OpenJPAPersistence.toOpenJPAObjectIds(getMetaData(cls),
+                    oids));
+    }
+
+    public void evictAll() {
+        _cache.clear();
+    }
+
+    /**
+     * Return metadata for the given class, throwing the proper exception
+     * if not persistent.
+     */
+    private ClassMetaData getMetaData(Class cls) {
+        try {
+            return _repos.getMetaData(cls, null, true);
+        } catch (RuntimeException re) {
+            throw PersistenceExceptions.toPersistenceException(re);
+        }
+    }
+
+    public int hashCode() {
+        return _cache.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof StoreCacheImpl))
+            return false;
+        return _cache.equals (((StoreCacheImpl) other)._cache);
+	}
+}



Mime
View raw message