You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2005/05/22 20:01:48 UTC

svn commit: r171352 [10/11] - in /incubator/jdo/trunk/runtime20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/ejb/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/model/ src/java/org/apache/jdo/impl/model/java/ src/java/org/apache/jdo/impl/model/java/runtime/ src/java/org/apache/jdo/impl/model/jdo/ src/java/org/apache/jdo/impl/model/jdo/xml/ src/java/org/apache/jdo/impl/pm/ src/java/org/apache/jdo/impl/sco/ src/java/org/apache/jdo/impl/state/ src/java/org/apache/jdo/pm/ src/java/org/apache/jdo/query/ src/java/org/apache/jdo/sco/ src/java/org/apache/jdo/state/ src/java/org/apache/jdo/store/

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientClean.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientClean.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientClean.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientClean.java Sun May 22 11:01:45 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ *  TransientClean.java    August 10, 2001
+ */
+
+package org.apache.jdo.impl.state;
+
+import javax.jdo.JDOFatalInternalException;
+import javax.jdo.Transaction;
+
+/**
+ * This class represents TransientClean state specific state transitions as 
+ * requested by StateManagerImpl. This state is the result of a call to
+ * makeTransactional on a Transient instance, or commit or rollback of a
+ * TransientDirty instance.
+ *
+ * @author Marina Vatkina
+ */
+class TransientClean extends LifeCycleState {
+
+    TransientClean() {
+        // these flags are set only in the constructor 
+        // and shouldn't be changed afterwards
+        // (cannot make them final since they are declared in superclass 
+        // but their values are specific to subclasses)
+        isPersistent = false;
+        isTransactional = true;
+        isDirty = false;
+        isNew = false;
+        isDeleted = false;
+
+        isFlushed = true;
+        isNavigable = true;
+        isRefreshable = true;
+        isBeforeImageUpdatable = false;
+
+        stateType = T_CLEAN;
+    }
+
+   /**
+    * @see LifeCycleState#transitionMakeTransient(StateManagerImpl sm, Transaction tx)
+    */
+    protected LifeCycleState transitionMakeTransient(StateManagerImpl sm, 
+        Transaction tx) {
+        return this;
+    }
+
+   /**
+    * @see LifeCycleState#transitionMakeNontransactional(StateManagerImpl sm,
+    * Transaction tx)
+    */
+    protected LifeCycleState transitionMakeNontransactional(StateManagerImpl sm,
+        Transaction tx)  {  
+        sm.disconnect();
+        return changeState(TRANSIENT);
+    }
+
+   /**
+    * @see LifeCycleState#transitionMakePersistent(StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionMakePersistent(StateManagerImpl sm) {    
+        sm.registerTransactional();
+        return changeState(P_NEW);
+    }
+    
+   /**
+    * @see LifeCycleState#transitionToAutoPersistent(StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionToAutoPersistent(StateManagerImpl sm) {    
+        sm.registerTransactional();
+        return changeState(AP_NEW);
+    }
+    
+   /**
+    * @see LifeCycleState#transitionReadField(StateManagerImpl sm, Transaction tx)
+    */
+    protected LifeCycleState transitionReadField(StateManagerImpl sm, Transaction tx) {
+        return this;
+    }
+
+   /**
+    * @see LifeCycleState#transitionWriteField(StateManagerImpl sm, Transaction tx)
+    */
+    protected LifeCycleState transitionWriteField(StateManagerImpl sm,
+        Transaction tx) {
+        if (tx.isActive()) {
+            // This is the first change in the current transaction. Save image
+            // for rollback.
+            sm.createBeforeImage();
+            return changeState(T_DIRTY);
+        } else {
+            return this;
+        }
+    }
+
+   /**
+    * This is a no-op.
+    * @see LifeCycleState#transitionCommit(boolean retainValues, StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionCommit(boolean retainValues, StateManagerImpl sm) {
+        return this;
+    }
+
+   /**
+    * @see LifeCycleState#transitionRollback(boolean restoreValues, StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionRollback(boolean restoreValues, StateManagerImpl sm) {
+        sm.reset();
+        return this;
+    }
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientDirty.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientDirty.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientDirty.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/TransientDirty.java Sun May 22 11:01:45 2005
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ *  TransientDirty.java    August 10, 2001
+ */
+
+package org.apache.jdo.impl.state;
+
+import javax.jdo.Transaction;
+
+/**
+ * This class represents TransientDirty state specific state transitions as
+ * requested by StateManagerImpl. This state is the result of a wrie operation
+ * on a TransientClean instance
+ *
+ * @author Marina Vatkina
+ */
+class TransientDirty extends LifeCycleState {
+
+    TransientDirty() {
+        // these flags are set only in the constructor 
+        // and shouldn't be changed afterwards
+        // (cannot make them final since they are declared in superclass 
+        // but their values are specific to subclasses)
+        isPersistent = false;
+        isTransactional = true;
+        isDirty = true;
+        isNew = false;
+        isDeleted = false;
+
+        isNavigable = true;
+        isRefreshable = true;
+        isBeforeImageUpdatable = true;
+        isFlushed = false;
+        
+        stateType =  T_DIRTY;
+    }
+
+   /**
+    * @see LifeCycleState#transitionMakeTransient(StateManagerImpl sm,
+    * Transaction tx)
+    */
+    protected LifeCycleState transitionMakeTransient(StateManagerImpl sm,
+        Transaction tx) { 
+        return this;
+    } 
+ 
+   /**
+    * @see LifeCycleState#transitionMakePersistent(StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionMakePersistent(StateManagerImpl sm) {    
+
+        sm.registerTransactional();
+        return changeState(P_NEW);
+    }
+
+   /**
+    * @see LifeCycleState#transitionToAutoPersistent(StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionToAutoPersistent(StateManagerImpl sm) {    
+        sm.registerTransactional();
+        return changeState(AP_NEW);
+    }
+
+   /**
+    * @see LifeCycleState#transitionCommit(boolean retainValues, StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionCommit(boolean retainValues, StateManagerImpl sm) {     
+        sm.reset();
+        return changeState(T_CLEAN);
+    } 
+ 
+   /**
+    * @see LifeCycleState#transitionRollback(boolean restoreValues, StateManagerImpl sm)
+    */
+    protected LifeCycleState transitionRollback(boolean restoreValues, StateManagerImpl sm)  {      
+        sm.restoreFields();
+        sm.reset();
+        return changeState(T_CLEAN); 
+    }  
+  
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/Accessor.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/Accessor.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/Accessor.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/Accessor.java Sun May 22 11:01:45 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * Accessor.java
+ *
+ * Created on August 10, 2001, 3:17 PM
+ */
+
+package org.apache.jdo.pm;
+
+/**
+ *
+ * @author  Dave Bristor
+ * @version 1.0
+ */
+public interface Accessor {
+    /** 
+     * Return a default value in a Factory (either 
+     * a PersistenceManagerFactory or a ConnectionFactory.
+     * @return String form of a default value
+     */
+    public String getDefault();
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerFactoryInternal.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerFactoryInternal.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerFactoryInternal.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerFactoryInternal.java Sun May 22 11:01:45 2005
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * PersistenceManagerFactoryInternal.java
+ *
+ * Create on March 3, 2000
+ */
+
+package org.apache.jdo.pm;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+import org.apache.jdo.store.StoreManager;
+import org.apache.jdo.store.TranscriberFactory;
+
+
+/**
+* JDORI-internal PMF.
+*
+* @author Dave Bristor
+*/
+public interface PersistenceManagerFactoryInternal
+    extends PersistenceManagerFactory {
+
+    /**
+    * Provides the factory which can make Transcribers for this PMF.
+    * @return A TranscriberFactory particular to a kind of PMF.
+    */
+    public TranscriberFactory getTranscriberFactory();
+
+    /**
+    * In order for the application to construct instance of the ObjectId
+    * class it needs to know the class being used by the JDO implementation.
+    * @param cls the PersistenceCapable Class
+    * @return the Class of the ObjectId of the parameter
+    */
+    public Class getObjectIdClass(Class cls);
+
+    /**
+    * Provides a StoreManager that is ready to accept operations on it such
+    * as insert, etc.
+    * @param pm PersistenceManager that is requesting a StoreManager.
+    */
+    public StoreManager getStoreManager(PersistenceManager pm);
+
+    /**
+    * Allows the PMF to release any resources associated with the given PM's
+    * store manager.
+    * @param pm PersistenceManager that is releasing a StoreManager.
+    */
+    public void releaseStoreManager(PersistenceManager pm);
+
+    /**
+    * Returns store-specific mapping between Java classes and tracked SCO
+    * classes supported by this PMF. Called by PersistenceManager inside
+    *  requests for a new tracked instance.
+    * @param type Class to find mapping for.
+    * @return A Class for the tracked SCO or null if this Java class is not
+    * supported as tracked SCO.
+    */
+    public Class getTrackedClass(Class type);
+
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerInternal.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerInternal.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerInternal.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/PersistenceManagerInternal.java Sun May 22 11:01:45 2005
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2005 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.jdo.pm;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.spi.PersistenceCapable;
+
+import org.apache.jdo.state.StateManagerInternal;
+import org.apache.jdo.store.StoreManager;
+
+
+/**
+ * Extends the PersistenceManager interface for JDO-internal use.  Provides
+ * additional information and helper methods for StateManagerInternal
+ * interaction with the cache.
+ *
+ * @author Marina Vatkina
+ */
+public interface PersistenceManagerInternal extends PersistenceManager {
+    /**
+     * assert this PM instance is open
+     */
+    public void assertIsOpen();
+
+    /**
+     * assert that the NontransactionalRead flag is true or a transaction is active.
+     */
+    public void assertReadAllowed();
+    
+    /**
+    * Provides a StoreManager that is ready to accept operations on it.
+    * @return A StoreManager.
+    */
+    public StoreManager getStoreManager();
+
+    /**
+    * Provides a StateManagerInternal for the given Object Id.
+    * @param oid the given Object Id.
+    * @param pcClass Class of a PersistenceCapable instance to be created
+    * if this Object Id was not registered with this PersistenceManager.
+    * @return A StateManagerInternal.
+    */
+    public StateManagerInternal getStateManager(Object oid, Class pcClass);
+
+    /**
+    * Finds a StateManagerInternal for the given PersistenceCapable object.
+    * Validates PersistenceManager associated with this PersistenceCapable object.
+    * @param pc the given PersistenceCapable object.
+    * @return A StateManagerInternal.
+    */
+    public StateManagerInternal findStateManager(PersistenceCapable pc);
+
+
+    /**
+     * Provides a Class of the given name.  This method will use one of as
+     * many as three ClassLoaders in attempting to load the named class. The
+     * ClassLoaders are:
+     * <ul>
+     *   <li>The given Class Loader</li>
+     *   <li>The current Thread's context Class Loader</li>
+     *   <li>The class loader that was the context Class Loader of the thread
+     *     which created this PersistenceManagerInternal</li> 
+     * </ul>
+     * For each such non-null Class Loader, it is used as a parameter of
+     * Class.forName. If the result is not null, then the given Comparator's
+     * compare method is invoked with that Class and the given Object o. If
+     * that returns zero, that Class is returned. If either the Class.forName
+     * returns null or the comparator returns non-zero, the next non-null
+     * ClassLoader in the above list is tried in the same manner.
+     * <p>
+     * If after the above has been tried on all the ClassLoaders, an
+     * appropriate Class has not been found, throws JDOUserException.
+     * @param name Fully qualified name of the Class to load.
+     * @param given ClassLoader which is the first to be tried
+     * in loading the named Class. 
+     * @throws ClassNotFoundException - if an appropriate Class can not
+     * be loaded.
+     */
+
+     /* XXX At one point, we discussed also using a Comparator to validate
+     * the class loaded by the loader.  Pending resolution, we are omitting
+     * this, instead following the proposal Craig made to the JDO Experts.
+     *
+     * @param c Comparator used to determine if a
+     * Class loaded from a ClassLoader  is in fact
+     * that which the caller wants. Invoked with a loaded Class
+     * as the first argument, and the given object o as the second
+     * argument. If it returns zero, the comparison is deemed to have succeed,
+     * and that Class will be returned by this method.
+     * @param o Object passed as second argument to given
+     * Comparator's compare method.
+     */
+
+     public Class loadClass(String name,
+                            ClassLoader given) throws ClassNotFoundException;
+     //                     Comparator c,
+     //                     Object o) throws ClassNotFoundException;
+
+
+    /**
+     * Provides the Class object of the persistence-capable class that defines 
+     * the specified class as its ObjectId class. This method will use one of as
+     * many as three ClassLoaders in attempting to find the persistence-capable 
+     * class. The ClassLoaders are the same as in {@link #loadClass}:
+     * <ul>
+     * <li>The given Class Loader, here the given class loader is the class 
+     * loader of the ObjectId class</li>
+     * <li>The current Thread's context Class Loader</li>
+     * <li>The class loader that was the context Class Loader of the thread
+     *     which created this PersistenceManagerInternal</li> 
+     * </ul>
+     * The method returns the top most persistence-capable class in the case of 
+     * an inheritance hierachy.
+     */
+    public Class loadPCClassForObjectIdClass(Class objectIdClass) 
+        throws ClassNotFoundException;
+
+    /**
+    * Provides an object id for the given PersistenceCapable.  The object id
+    * must not be given to user/client code.
+    */     
+    public Object getInternalObjectId(Object pc);
+
+    /**
+    * Adds persistent object to the cache.
+    * @param sm instance of StateManagerInternal to be added
+    * @param oid ObjectId of the corresponding persistence-capable instance
+    * @param transactional true if the corresponding lifecycle state is transactional
+    * @param throwDuplicateException true if the exception should be thrown in case the same ObjectId
+    * has been already registered.
+    */
+    public void register(StateManagerInternal sm, Object oid, boolean transactional, 
+        boolean throwDuplicateException);
+
+    /**
+    * Adds transient object to the transient cache.
+    * @param sm instance of StateManagerInternal to be added
+    */
+    public void registerTransient(StateManagerInternal sm);
+
+    /**
+    * Removes the object from the cache.
+    * @param oid ObjectId of the instance to be removed.
+    */
+    public void deregister(Object oid);
+
+    /**
+    * Removes transient object from the transient cache.
+    * @param sm instance of StateManagerInternal to be removed
+    */
+    public void deregisterTransient(StateManagerInternal sm);
+
+    /**
+    * Replaces the objectId key value in the cache.
+    * @param oldId previous value of ObjectId.
+    * @param newId new value of ObjectId.
+    */
+    public void replaceObjectId(Object oldId, Object newId);
+
+   /** A helper method called from the StateManager inside getPersistenceManager()
+     * to identify StateManager associated with this PC instance
+     * @param pc PC instance
+     * @param sm StateManager to save
+     */  
+    public void hereIsStateManager(StateManagerInternal sm, PersistenceCapable pc);
+
+   /**
+    * Called by StateManagerInternal#markAsFlushed() to adjust transactional cache(s)
+    * if necessary after successful flush to the data store.
+    * @param sm StateManagerInternal instance that has been flushed
+    */
+    public void markAsFlushed(StateManagerInternal sm);
+
+   /**
+    * Returns true if the call initiated as a result of the commit process,
+    * versus flush for query in a datastore transaction.
+    * @return true if commit has started
+    */
+    public boolean insideCommit();
+
+    /**
+     * Called internally by the runtime to create a new tracked instance.
+     * Will not result in marking field as dirty
+     *
+     * Returns a new Second Class Object instance of the type java.uti.Date,
+     * or supported subclass.
+     * @param type Class of the new SCO instance
+     * @return the object of the class type
+     */
+    public Object newSCOInstanceInternal (Class type);
+
+    /**
+     * Called internally by the runtime to create a new tracked instance of type
+     * Collection.
+     * Will not result in marking field as dirty
+     *   
+     */  
+    public Collection newCollectionInstanceInternal(Class type,
+        Class elementType, boolean allowNulls, Integer initialSize,
+        Float loadFactor, Collection initialContents, Comparator comparator);
+
+    /**
+     * Called internally by the runtime to create a new tracked instance of type Map.
+     * Will not result in marking field as dirty
+     *   
+     */  
+    public Map newMapInstanceInternal(Class type, Class keyType, Class valueType, 
+        boolean allowNulls, Integer initialSize, Float loadFactor, 
+        Map initialContents, Comparator comparator);
+
+    /**
+     * Called by StateManager to verify field type.
+     * @param type Class type of the field.
+     * @return true if this type is a supported SCO type.
+     */
+    public boolean isSupportedSCOType(Class type);
+
+    /**
+     * Called by Query or Extent to flush updates to the database
+     * in a datastore transaction. It is up to the StoreManager to decide
+     * at what point of the processing to call this method. No validation
+     * of the transaction type is performed.
+     * @throws JDOUserException if current transaction is not active.
+     */
+    public void flush();
+
+    /**
+     * Returns current instance of PersistenceManager wrapper
+     */  
+    public PersistenceManager getCurrentWrapper();
+
+    /**
+     * Returns a Collection of instances that has been made persistent
+     * or become persistent through persistence-by-reachability
+     * algorithm in this transaction. Called by the Extent.iterator.
+     * @return Collection of Persistent-New instances.
+     */
+    public Collection getInsertedInstances();
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/package.html?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/package.html (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/pm/package.html Sun May 22 11:01:45 2005
@@ -0,0 +1,27 @@
+<!--
+ Copyright 2005 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.
+-->
+
+<html>
+<head>
+<title>Package org.apache.jdo.pm</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains provides internal interfaces for 
+PersistenceManagerFactory and PersistenceManager extending the ones from javax.jdo.
+</body>
+</html>

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/BasicQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/BasicQueryResult.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/BasicQueryResult.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/BasicQueryResult.java Sun May 22 11:01:45 2005
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * BasicQueryResult.java
+ *
+ * Created on March 18, 2001, 12:48 PM
+ */
+
+package org.apache.jdo.query;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.NoSuchElementException;
+
+
+import javax.jdo.*;
+import javax.jdo.spi.I18NHelper;
+
+
+/** This class implements the basic query execution
+ * strategy.  It first orders the candidate set
+ * using the query helper orderCandidates method.
+ * It then iterates over the ordered candidate
+ * collection, filtering each one, 
+ * using the query helper applyFilter method and removing the
+ * objects that fail the filter.
+ * All of the methods of Collection are then delegated
+ * to the result collection.
+ *
+ * @author Craig Russell
+ * @version 1.0
+ */
+public class BasicQueryResult extends Object implements QueryResult {
+
+    /** The result after filtering the candidates for the
+     * proper class, ordering the results, and filtering
+     * candidates for the user-defined filter.
+     */    
+    final List result;
+    
+    /** The open iterators against the query results.
+     */    
+    HashSet iterators;
+    
+    /** The flag indicating whether the query result is
+     * closed.  If the query result is closed, no further
+     * operations can be done on it.
+     */    
+    boolean closed;
+    
+    /** I18N support */
+    private final static I18NHelper msg =  
+        I18NHelper.getInstance(BasicQueryResult.class);
+
+    /** Creates new BasicQueryResult
+     * @param qrh the query result helper provided
+     * by the query parser.
+     */
+    public BasicQueryResult(QueryResultHelper qrh) {
+        iterators = new HashSet();
+        Collection candidates;
+        // getCandidates returns either a Collection or an Extent
+        Object possibles = qrh.getCandidates();
+        if (possibles instanceof Collection) {
+            candidates = (Collection) possibles;
+        } 
+        else {
+            // iterate the Extent to create the candidate Collection
+            candidates = new ArrayList();
+            Iterator it = ((Extent) possibles).iterator();
+                while (it.hasNext()) {
+                    candidates.add (it.next());
+                }
+        }
+        // order the candidates according to the user's request
+        result = qrh.orderCandidates(candidates);
+        Iterator it = result.iterator();
+        while (it.hasNext()) {
+            if (! qrh.applyFilter (it.next())) {
+                // remove non-qualifying elements and we are done.
+                it.remove();
+            }
+        }
+    }
+    
+    /** This method closes the result set, closes all open iterators, and releases
+     * all resources that might be held by the result.
+     */    
+    public void close() {
+        closed = true;
+        for (Iterator qrii = iterators.iterator(); qrii.hasNext(); ) {
+           ((QueryResultIterator) qrii.next()).close();
+        }
+        iterators = null;
+        result.clear();
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     * @param collection ignored.
+     * @return never.
+     */    
+    public boolean retainAll(java.util.Collection collection) {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }    
+
+    /** This method delegates to the result collection method.
+     * @param obj the object to be tested.
+     * @return <CODE>true</CODE> if the result collection contains
+     * the parameter object.
+     */    
+    public boolean contains(java.lang.Object obj) {
+        return result.contains (obj);
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return an array of all objects in the result
+     * collection that are of the runtime
+     * type of the parameter array.
+     * @param obj an array into which to place the
+     * objects from the result collection.
+     */    
+    public java.lang.Object[] toArray(java.lang.Object[] obj) {
+        return result.toArray (obj);
+    }
+
+    /** This method delegates to the result collection method.
+     * @return an iterator over the result collection.
+     */    
+    public java.util.Iterator iterator() {
+        QueryResultIterator i = new BasicQueryResultIterator (result.iterator());
+        if (closed)
+            i.close();
+        else
+            iterators.add(i);
+        return i;
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return the result collection as an array.
+     */    
+    public java.lang.Object[] toArray() {
+        return result.toArray();
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     * @param collection ignored.
+     * @return never.
+     */    
+    public boolean removeAll(java.util.Collection collection) {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     * @param obj ignored.
+     * @return never.
+     */    
+    public boolean remove(java.lang.Object obj) {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     */    
+    public void clear() {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     * @param collection ignored.
+     * @return never.
+     */    
+    public boolean addAll(java.util.Collection collection) {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return the size of the results.
+     */    
+    public int size() {
+        return result.size();
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return <CODE>true</CODE> if the result collection contains all of the
+     * elements in the parameter collection.
+     * @param collection a collection of elements to be tested.
+     */    
+    public boolean containsAll(java.util.Collection collection) {
+        return result.containsAll (collection);
+    }
+    
+    /** This method throws UnsupportedOperationException because
+     * the collection is read-only.
+     * @param obj ignored.
+     * @return never.
+     */    
+    public boolean add(java.lang.Object obj) {
+        throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return <CODE>true</CODE> if the result collection is empty.
+     */    
+    public boolean isEmpty() {
+        return result.isEmpty();
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return <CODE>true</CODE> if the result collection is equal to the parameter 
+     * collection.
+     * @param obj the object to which to compare this object.
+     */    
+    public boolean equals (Object obj) {
+        return result.equals (obj);
+    }
+    
+    /** This method delegates to the result collection method.
+     * @return the hashCode of the result collection.
+     */    
+    public int hashCode() {
+        return result.hashCode();
+    }
+    /** The internal query result iterator supports all
+     * iterator methods plus close, allowing early release
+     * of resources.
+     */    
+    public class BasicQueryResultIterator extends Object implements QueryResultIterator {
+        
+        /** The internal iterator over the query results.
+         */        
+        Iterator internalIterator;
+        
+        /** The flag indicating whether the query result is
+         * closed.  If the query result is closed, no further
+         * operations can be done on it.
+         */    
+        boolean closed;
+        
+        /** Construct a new query result iterator given the
+         * iterator over the results.
+         * @param it The iterator over the results of the query.
+         */        
+        private BasicQueryResultIterator (Iterator it) {
+            internalIterator = it;
+            closed = false;
+        }
+        
+        /** Return true if this query result iterator has not been
+         * closed and the internal iterator has more elements.
+         * @return true if there are more elements.
+         */        
+        public boolean hasNext() {
+            if (isClosed()) return false;
+            return internalIterator.hasNext();
+        }
+        
+        /** Advance and return the next element of the iterator.
+         * @return the next element of the iterator.
+         */        
+        public java.lang.Object next() {
+            if (isClosed()) throw new NoSuchElementException();
+            return internalIterator.next();
+        }
+        
+        /** Close this iterator and release any resources held.  After
+         * this method completes, the iterator will return false to
+         * hasNext(), and will throw NoSuchElementException to next().
+         */
+        public void close() {
+            // allow iterator to be garbage collected
+            internalIterator = null;
+            closed = true;
+        }
+        
+        /** Throw an exception.  This iterator is read-only.
+         */        
+        public void remove() {
+            throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N
+        }
+        
+        /** Return true if the user has closed this iterator.
+         * @return true if the user has closed this iterator.
+         */        
+        public boolean isClosed() {
+            return closed;
+        }
+        
+    }
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/Bundle.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/Bundle.properties (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/Bundle.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,28 @@
+#
+# Copyright 2005 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.
+
+# This file should conform to netbeans standards
+# (http://www.netbeans.org/i18n)
+
+# resource bundle for the messages
+# key consists of: <PREFIX_><description>
+# <PREFIX_> - any valid prefix like MSG_, EXC_, etc.
+# <description> - short description started with the upper case letter and used
+# upper case to represent each next word.
+
+#
+# BasicQueryResult
+#
+EXC_ReadOnly=Read only

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResult.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResult.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResult.java Sun May 22 11:01:45 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * QueryResult.java
+ *
+ * Created on March 18, 2001, 12:33 PM
+ */
+
+package org.apache.jdo.query;
+
+/** An instance of this interface is returned as the result of
+ * Query.execute(...).
+ * @author Craig Russell
+ * @version 0.9
+ */
+public interface QueryResult extends java.util.Collection {
+    
+    /** Close this query result and invalidate all iterators
+     * that have been opened on it.  After this method completes,
+     * no more iterators can be opened; and
+     * all iterators currently open on it will return false to 
+     * hasNext(), and will throw NoSuchElementException to next().
+     *
+     */
+    void close();
+
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultHelper.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultHelper.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultHelper.java Sun May 22 11:01:45 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * QueryResultHelper.java
+ *
+ * Created on March 18, 2001, 12:35 PM
+ */
+
+package org.apache.jdo.query;
+
+import java.util.Collection;
+import java.util.List;
+import javax.jdo.Extent;
+
+//brazil: import org.apache.jdo.jdoql.tree.QueryTree;
+//brazil: import org.apache.jdo.jdoql.tree.ValueTable;
+
+
+/** This interface is a helper for the query execution strategy
+ * of the StoreManager.   When a query is executed, the filter
+ * is parsed.  The parsed query, candidate collection or extent,
+ * and actual parameters of the execute are stored in the
+ * QueryResultHelper.
+ * This interface also provides methods useful for ordering
+ * the candidate objects and for filtering objects.
+ * @author Craig Russell
+ * @version 1.0
+ */
+public interface QueryResultHelper {
+
+    /** Return the candidate Collection or Extent specified by
+     * the user.
+     * @return the candidate Collection or Extent.
+     */
+    Object getCandidates();
+        
+    /** This method filters the specified collection, removing all elements that
+     * are not assignment compatible to the candidate Class specified by the 
+     * user, and then orders the results according to the ordering expression 
+     * specified by the user.  A new List is returned.
+     * @param candidates the collection of instances to be filtered and ordered
+     * @return the filtered parameter collection ordered by the ordering 
+     * expression.
+     */    
+    List orderCandidates(Collection candidates);
+    
+    /** This method determines whether the specified object is assignment 
+     * compatible to the candidate Class specified by the user and satisfies 
+     * the query filter.
+     * @return <CODE>true</CODE> if the specified object is of the candidate 
+     * class and satisfies the query filter; <CODE>false otherwise</CODE>
+     * @param obj the candidate object.
+     */    
+    boolean applyFilter(Object obj);
+    
+    /** Return the query tree which is either specified by the user or compiled 
+     * from a JDOQL query.
+     * @return the query tree
+     *
+     */
+    //brazil: QueryTree getQueryTree();
+    
+    /** This method returns the parameter values passed by the user
+     * in the execute(...) method.
+     * @return a ValueTable representing the parameter values
+     */
+    //brazil: ValueTable getParameterValues();
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultIterator.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultIterator.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/query/QueryResultIterator.java Sun May 22 11:01:45 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * QueryResultIterator.java
+ *
+ * Created on March 18, 2001, 12:34 PM
+ */
+
+package org.apache.jdo.query;
+
+/** This interface is used to iterate a query result.  It is
+ * returned to the user in response to the iterator() method
+ * of the query result Collection.
+ * @author Craig Russell
+ * @version 0.9
+ */
+public interface QueryResultIterator extends java.util.Iterator {
+
+    /** Close this iterator and release any resources held.  After
+     * this method completes, the iterator will return false to
+     * hasNext(), and will throw NoSuchElementException to next().
+     */
+    void close();
+    
+}
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCO.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCO.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCO.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCO.java Sun May 22 11:01:45 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * SCO.java
+ *
+ * created May 9, 2000
+ *
+ * @author Marina Vatkina
+ * @version 1.0.1
+ */
+
+package org.apache.jdo.sco;
+
+public interface SCO {
+    /**
+     * Returns the field name
+     *
+     * @return field name as java.lang.String
+     */
+    String getFieldName();
+
+    /**
+     * Returns the owner object of the SCO instance
+     *
+     * @return owner object
+     */
+    Object getOwner();
+
+    /** 
+     * Sets the owner and field number.  Called by StateManager upon
+     * assignment to a managed instance.
+     * @param owner the owner object. 
+     * @param fieldNumber the number of the field associated with this instance.
+     */
+    void setOwner (Object owner, int fieldNumber);
+
+    /**
+     * Nullifies references to the owner Object iff the passed in owner and 
+     * fieldNumber match.
+     * @param owner the existing owner object.
+     * @param fieldNumber the existing number of the field.
+     */
+    void unsetOwner(Object owner, int fieldNumber);
+
+    /**
+     * Make a copy of this object.
+     * @since 1.0.1
+     */
+    Object clone();
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOCollection.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOCollection.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOCollection.java Sun May 22 11:01:45 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * SCOCollection.java
+ *
+ * created April 3, 2000
+ *
+ * @author Marina Vatkina
+ * @version 1.0.1
+ */
+
+package org.apache.jdo.sco;
+import java.util.Collection;
+import java.util.Iterator;
+
+public interface SCOCollection extends java.util.Collection, SCO {
+    /**
+     * Resets removed and added lists after flush
+     */
+    void reset();
+
+    /**
+     * Adds object to the Collection without recording
+     * the event. Used internaly to initially populate the Collection
+     */ 
+    void addInternal(Object o);
+
+    /**
+     * Adds objects of the given Collection to this Collection without recording
+     * the event. Used internaly to initially populate the Collection
+     */ 
+    void addAllInternal(Collection c);
+
+
+    /**
+     * Clears Collection without recording
+     * the event. Used internaly to clear the Collection
+     */
+    void clearInternal();
+
+
+    /**
+     * Removes element from the Collection without recording
+     * the event. Used internaly to update the Collection
+     */
+    void removeInternal(Object o);
+
+    /**
+     * Returns the Collection of added elements
+     *
+     * @return Collection of the added elements as java.util.Collection
+     */
+    Collection getAdded();
+
+    /**
+     * Returns the Collection of removed elements
+     *
+     * @return Collection of the removed elements as java.util.Collection
+     */
+    Collection getRemoved();
+
+    /**
+     * Returns the element type assignment compatible with all
+     * added elements of this collection.
+     * 
+     * @return the element type assignment compatible with all
+     * added elements.
+     */
+    Class getElementType();
+
+    /**
+     * Returns whether nulls are permitted as elements.
+     *   
+     * @return true if nulls are permitted as elements. 
+     */ 
+    boolean allowNulls();
+
+    /**
+     * Set the contents of this Collection from the frozen elements.
+     * @since 1.0.1
+     * @param elements the frozen elements.
+     */
+    void setFrozen(Object[] elements);
+    
+    /**
+     * Get an iterator over the frozen elements of this collection. This allows
+     * iterator of the elements without thawing them, as is needed for
+     * transcription.
+     * @since 1.0.1
+     * @return an iterator over the frozen elements.
+     */
+    Iterator frozenIterator();
+    
+    /** Get an iterator regardless of whether the map is frozen.
+     * If frozen, get a frozen iterator.
+     * If thawed, get a regular iterator.
+     * @since 1.0.1
+     * @return the iterator over the elements.
+     */
+    Iterator eitherIterator();
+    
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCODate.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCODate.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCODate.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCODate.java Sun May 22 11:01:45 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * SCODate.java
+ *
+ * created April 5, 2000
+ *
+ * @author Marina Vatkina
+ * @version 1.0
+ */
+
+package org.apache.jdo.sco;
+
+public interface SCODate extends SCO
+{
+    /**
+     * Sets initial date value without notifying the owner object
+     *
+     * @param time in milliseconds
+     */
+    void setTimeInternal(long time);
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOMap.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOMap.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOMap.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/SCOMap.java Sun May 22 11:01:45 2005
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005 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.
+ */
+
+/*
+ * SCOMap.java
+ *
+ * created September 20, 2001
+ *
+ * @author Marina Vatkina
+ * @version 1.0.1
+ */
+
+package org.apache.jdo.sco;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public interface SCOMap extends java.util.Map, SCO {
+    /**
+     * Resets removed and added lists after flush
+     */
+    void reset();
+
+    /**
+     * Associates the specified value with the specified key in this map 
+     * without recording the event. Used internaly to initially populate 
+     * the Map.
+     */ 
+    void putInternal(Object key, Object value);
+
+    /**
+     * Copies all of the mappings from the specified map to this one without 
+     * recording the event. Used internaly to initially populate the Map.
+     */ 
+    void putAllInternal(Map t);
+
+
+    /**
+     * Clears Map without recording
+     * the event. Used internaly to clear the Map
+     */
+    void clearInternal();
+
+
+    /**
+     * Removes mappings from the Map without recording
+     * the event. Used internally to update the Map
+     */
+    void removeInternal(Object key);
+
+    /**
+     * Returns the Collection of added keys
+     *
+     * @return Collection of the added keys as java.util.Collection
+     */
+    Collection getAddedKeys();
+
+    /**
+     * Returns the Collection of added values
+     *
+     * @return Collection of the added values as java.util.Collection
+     */
+    Collection getAddedValues();
+
+    /**
+     * Returns the Collection of removed keys
+     *
+     * @return Collection of the removed keys as java.util.Collection
+     */
+    Collection getRemovedKeys();
+
+    /**
+     * Returns the Collection of removed values
+     *
+     * @return Collection of the removed values as java.util.Collection
+     */
+    Collection getRemovedValues();
+
+    /**
+     * Returns the type of the key assignment compatible with all
+     * keys of this map.
+     * 
+     * @return the type of the key assignment compatible with all
+     * keys.
+     */
+    Class getKeyType();
+
+    /**
+     * Returns the type of the value assignment compatible with all
+     * values of this map.
+     * 
+     * @return the type of the value assignment compatible with all
+     * values.
+     */
+    Class getValueType();
+
+    /**
+     * Returns whether nulls are permitted as keys or values.
+     *   
+     * @return true if nulls are permitted as keys or values. 
+     */ 
+    boolean allowNulls();
+
+    /**
+     * Set the contents of this Map from the frozen entries.
+     * @since 1.0.1
+     * @param entries the array of entries
+     */
+    void setFrozen(Map.Entry[] entries);
+    
+    /** Get an iterator regardless of whether the map is frozen.
+     * If frozen, get a frozen iterator.
+     * If thawed, get a regular iterator.
+     * @since 1.0.1
+     * @return an iterator over the map entries.
+     */
+    Iterator eitherIterator();
+    
+    /**
+     * Get an iterator over the frozen elements of this map. This allows
+     * iteration of the elements without thawing them, as is needed for
+     * transcription.
+     * @since 1.0.1
+     * @return an iterator over the frozen map entries.
+     */
+    Iterator frozenIterator();
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/package.html?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/package.html (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/sco/package.html Sun May 22 11:01:45 2005
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2005 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.
+-->
+
+<html>
+<head>
+<title>Package org.apache.jdo.sco</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains SCO-related interfaces.</p>
+</body>
+</html>

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/FieldManager.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/FieldManager.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/FieldManager.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/FieldManager.java Sun May 22 11:01:45 2005
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2005 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.jdo.state;
+
+/**
+ * This is the means by which a StateManager implementation's giveXXXField()
+ * method (where XXX is e.g. Int) can give the value to an object that wants
+ * the field.
+ *
+ * @author Dave Bristor
+ */
+public interface FieldManager {
+    /**
+     * Provides the means by which the value of a boolean field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Boolean that is the value of a particular field.
+     */
+    public void storeBooleanField(int fieldNum, boolean value);
+
+    public boolean fetchBooleanField(int fieldNum);
+    
+    /**
+     * Provides the means by which the value of a char field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Char that is the value of a particular field.
+     */
+    public void storeCharField(int fieldNum, char value);
+
+    public char fetchCharField(int fieldNum);
+    
+    /**
+     * Provides the means by which the value of a byte field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Byte that is the value of a particular field.
+     */
+    public void storeByteField(int fieldNum, byte value);
+
+    public byte fetchByteField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a short field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Short that is the value of a particular field.
+     */
+    public void storeShortField(int fieldNum, short value);
+
+    public short fetchShortField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a int field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Int that is the value of a particular field.
+     */
+    public void storeIntField(int fieldNum, int value);
+
+    public int fetchIntField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a long field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Long that is the value of a particular field.
+     */
+    public void storeLongField(int fieldNum, long value);
+
+    public long fetchLongField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a  field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value  that is the value of a particular field.
+     */
+    public void storeFloatField(int fieldNum, float value);
+
+    public float fetchFloatField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a double field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Double that is the value of a particular field.
+     */
+    public void storeDoubleField(int fieldNum, double value);
+
+    public double fetchDoubleField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of a String field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value String that is the value of a particular field.
+     */
+    public void storeStringField(int fieldNum, String value);
+
+    public String fetchStringField(int fieldNum);
+
+    /**
+     * Provides the means by which the value of an Object field can be given
+     * by a StateManager to an object that needs the value.
+     * @param fieldNum Field number of the field in the object whose value is
+     * given.
+     * @param value Object that is the value of a particular field.
+     */
+    public void storeObjectField(int fieldNum, Object value);
+
+    public Object fetchObjectField(int fieldNum);
+
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java Sun May 22 11:01:45 2005
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2005 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.jdo.state;
+
+import javax.jdo.spi.PersistenceCapable;
+import javax.jdo.spi.StateManager;
+
+import org.apache.jdo.pm.PersistenceManagerInternal;
+import org.apache.jdo.sco.SCO;
+import org.apache.jdo.store.StoreManager;
+
+
+/**
+ * Extends the StateManager interface for JDO-internal use.  Provides
+ * additional information about the state of particular fields.  Provides a
+ * means to give a field's value to an object that can cause that value to be
+ * stored.
+ *
+ * @author Dave Bristor
+ */
+public interface StateManagerInternal extends StateManager {
+
+    /**
+    * Return values for flush operations
+    */
+    public static final int FLUSHED_PARTIAL  = -1;
+    public static final int FLUSHED_NONE     = 0;
+    public static final int FLUSHED_COMPLETE = 1;
+
+    /**
+    * Provides the object managed by this state manager.
+    * @return The object managed by this state manager.
+    */
+    public PersistenceCapable getObject();
+
+
+    /**
+    * Returns internal representation of the object id associated with this statemanager.
+    * @return internal representation of the object id associated with this statemanager.
+    */
+    public Object getInternalObjectId();
+
+    /**
+    * Returns external representation of the object id associated with this statemanager.
+    * @return external representation of the object id associated with this statemanager.
+    */
+    public Object getExternalObjectId();
+
+    /**
+    * Allows a client to change this state manager's object Id.  For example,
+    * with datastore identity, allows one object id to be used before the
+    * object has been stored (i.e. a "provisional" id), and another once the
+    * object has been put into the datbase.
+    */
+    public void setObjectId(Object objectId);
+
+    /**
+    * Causes the state manager to send itself to the store manager for
+    * insert, update, and so on as per its own state.  It should flush itself
+    * only if it has no dependencies on other state manager.
+    * @param srm The StoreManager to which the instance should send itself.
+    * @return true if the state manager could flush itself, false if it has
+    * dependencies on other state managers and could not flush itself.
+    */
+    public boolean flush(StoreManager srm);
+
+    /**
+     * Causes the values of the field indicated by the specified field number
+     * be given to the FieldManager.
+     * @param fieldNumber Indicates which field should be provided to the
+     * fieldManager.
+     * @param fieldManager FieldManager to which the field should be given.
+     * @param identifying If true, provides values from the before or flushed
+     * image, as determined by this StateManager's state; if false provides
+     * values from the current image.
+     */
+    public void provideField(int fieldNumber, FieldManager fieldManager,
+                             boolean identifying);
+
+    /**
+     * Causes the values of the fields  indicated by the specified fields to
+     * be given to the FieldManager.
+     * @param fields Indicates which fields should be provided to the
+     * fieldManager.
+     * @param fieldManager FieldManager to which the field should be given.
+     * @param identifying If true, provides values from the before or flushed
+     * image, as determined by this StateManager's state; if false provides
+     * values from the current image.
+     */
+    public void provideFields(int fields[], FieldManager fieldManager,
+                              boolean identifying);
+
+    /**
+    * For replacing field values in a PC with the ones that is provided by
+    * the FieldManager.
+    * @param fields Indicates which fields should be replaced in the PC.
+    * @param fieldManager FieldManager from which the field values should
+    * be obtained.
+    */
+    public void replaceFields(int fields[], FieldManager fieldManager);
+
+    /** 
+     * Fetch or refresh object from the data store.
+     */  
+    public void reload();
+
+    /** 
+     * Retrieve an instance from the store.
+     */  
+    public void retrieve();
+    
+    /**
+     * Transition the lifecycle state as if the instance is retrieved from the 
+     * datastore, but use the specified field values instead of loading them 
+     * from the datastore.
+     * @param fields Indicates which fields should be replaced in the PC.
+     * @param fieldManager FieldManager from which the field values should
+     * be obtained.
+     */
+    public void replace(int fields[], FieldManager fieldManager);
+
+    /**
+     * Transitions lifecycle state in afterCompletion callback
+     * @param abort true if transaction has been rolled back
+     * @param retainValues true if values need to be preserved on commit.
+     * @param restoreValues true if values need to be restored on rollback.
+     */
+    public void afterCompletion(boolean abort, boolean retainValues,
+        boolean restoreValues);
+
+   /**
+     * Transitions lifecycle state in to PERSISTENT_NEW
+     */
+    public void makePersistent();
+
+   /**
+     * Transitions lifecycle state in to transactional
+     */
+    public void makeTransactional();
+
+   /**
+     * Transitions lifecycle state in to nontransactional
+     */
+    public void makeNontransactional();
+
+   /**
+     * Transitions lifecycle state in to TRANSIENT
+     */
+    public void makeTransient();
+
+   /**
+     * Transitions lifecycle state in to PERSISTENT_DELETED
+     */
+    public void deletePersistent();
+
+   /**
+     * Transitions lifecycle state to P_CLEAN or P_NON_TX
+     */
+    public void refreshInstance();
+
+   /**
+     * Transitions lifecycle state to HOLLOW
+     */
+    public void evictInstance();
+
+   /**
+     * Calls preStore on the associated object if necessary.
+     */
+    public void preStore();
+
+   /**
+     * Replaces field values that are regular SCO instances with tracked SCOs.
+     * Called internally during the afterCompletion processing when instance 
+     * transions to P-nontransactional (if the retainValues flag is set to true).
+     * May be called by the StoreManager during the flush process to store tracked
+     * instances in the data store.
+     */
+    public void replaceSCOFields();
+
+   /** Processes relationships for reachability algorithm
+     * and define the dependencies  
+     * @param flag is true if method is called inside the flush, false otherwise
+     */  
+    public void handleReachability(boolean flag);
+
+    /**
+     * Returns true if the instance exists in a datastore. Returns false
+     * for transient instances, PersistentNew, PersistentNewDeleted, and 
+     * PersistentDeletedFlushed
+     */
+    public boolean isStored();
+
+    /**
+     * Returns true if the instance has been flushed to the datastore. 
+     */
+    public boolean isFlushed();
+
+    /**
+     * Sets dependency object containing dependency information specific to this 
+     * instance of the StateManager
+     * @param dependency new dependency object
+     */  
+    public Object setDependency(Object dependency);
+
+    /**
+     * Returns dependency object that contains dependency information specific to 
+     * this instance of the StateManager
+     */  
+    public Object getDependency();
+    
+    /** 
+     * Returns PersistenceManager associated with this StateManager instance
+     * @return the PersistenceManager
+     */
+    public PersistenceManagerInternal getPersistenceManager();
+
+    /** Mark the associated PersistenceCapable field dirty.
+     * <P> The StateManager will make a copy of the field
+     * so it can be restored if needed later, and then mark
+     * the field as modified in the current transaction.
+     * @param fieldNumber the number of the field
+     */  
+    public void makeDirty (int fieldNumber); 
+
+    /**
+     * Processes changes to the Tracked SCO instance owned by this
+     * StateManager.
+     * @param fieldNumber the number of the field
+     * @param sco Tracked SCO instance.
+     */
+    public void trackUpdates(int fieldNumber, SCO sco);
+
+    /**
+     * Returns field name for the field number. Used for debugging.
+     * @param fieldNumber the number of the field
+     * @return field name as String
+     */  
+    public String getFieldName(int fieldNumber);
+
+    /**
+     * Allows StateManager to set the actual PC Class if it was not available
+     * at the constructor time and create a hollow instnce of that type.
+     * @param pcClass the Class type of the instance.
+     */
+    public void setPCClass(Class pcClass);
+
+    /**
+     * Returns PC Class known to this StateManager. Can be a candidate Class.
+     * @return the Class type of the PC instance.
+     */  
+    public Class getPCClass();
+
+    /** Tests whether this StateManager represents a instance made persistent
+     * object.
+     *
+     * @return <code>true</code> if this StateManager represents an
+     * instance made persistent in the current transaction.
+     */
+    public boolean isNew();
+
+}

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/package.html?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/package.html (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/package.html Sun May 22 11:01:45 2005
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2005 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.
+-->
+
+<html>
+<head>
+<title>Package org.apache.jdo.state</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains the internal StateManager and teh FIeldManager interface.</p>
+</body>
+</html>

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Bundle.properties?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Bundle.properties (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Bundle.properties Sun May 22 11:01:45 2005
@@ -0,0 +1,30 @@
+#
+# Copyright 2005 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.
+
+# This file should conform to netbeans standards
+# (http://www.netbeans.org/i18n)
+
+# resource bundle for the messages
+# key consists of: <PREFIX_><description>
+# <PREFIX_> - any valid prefix like MSG_, EXC_, etc.
+# <description> - short description started with the upper case letter and used
+# upper case to represent each next word.
+
+#
+# StoreManagerImpl
+#
+EXC_UnableToFlushAll=Not able to flush all transactional instances to the data store.
+
+

Added: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Connector.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Connector.java?rev=171352&view=auto
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Connector.java (added)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/store/Connector.java Sun May 22 11:01:45 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2005 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.jdo.store;
+
+/**
+* A Connector is the store-independent means of representing a connection.
+* Each different kind of store should implement it's own connector, which
+* delegates the operations to its particular kind of connection.
+*
+* @author Dave Bristor
+*/
+public interface Connector {
+
+    /**
+    * Informs the Connector that a transaction is beginning.
+    * @param optimistic If true, then an optimistic transaction is
+    * beginning.
+    * @throws JDODataStoreException is [@link setRollbackOnly} has been
+    * invoked on this Connector.
+    */
+    public void begin(boolean optimistic);
+    
+    /**
+    * Informs the Connector that the transaction has reached it's
+    * beforeCompletion phase.
+    * @throws JDODataStoreException is [@link setRollbackOnly} has been
+    * invoked on this Connector.
+    */
+    public void beforeCompletion();
+    
+    /**
+    * Requests that the Connector send all pending database operations to the
+    * store.
+    * @throws JDODataStoreException is [@link setRollbackOnly} has been
+    * invoked on this Connector.
+    */
+    public void flush();
+    
+    /**
+    * Requests that the Connector make all changes made since the previous
+    * commit/rollback permanent and releases any database locks held by the
+    * Connector.
+    * @throws JDODataStoreException is [@link setRollbackOnly} has been
+    * invoked on this Connector.
+    */
+    public void commit();
+
+    /**
+    * Requests that the Connector drop all changes made since the previous
+    * commit/rollback and releases any database locks currently held by this
+    * Connector.
+    */
+    public void rollback();
+
+    /**
+     * Requests that the Connector put itself in a state such that the only
+     * allowable operations is {@link
+     * org.apache.jdo.store.Connector#getRollbackOnly}. Once set, attempts to 
+     * do any other operations will result in a JDODataStoreException.
+     */
+    public void setRollbackOnly();
+    
+    /**
+     * Indicates whether or not the connector can do operations other than
+     * rollback.
+     * @return <code>false</code> if the connector can do operations other than
+     * rollback.
+     */
+    public boolean getRollbackOnly();
+    
+}