Author: clr
Date: Mon Mar 28 10:25:05 2005
New Revision: 159273
URL: http://svn.apache.org/viewcvs?view=rev&rev=159273
Log:
initial JDO API 2.0 jar
Added:
incubator/jdo/trunk/api20/src/java/
incubator/jdo/trunk/api20/src/java/javax/
incubator/jdo/trunk/api20/src/java/javax/jdo/
incubator/jdo/trunk/api20/src/java/javax/jdo/Bundle.properties
incubator/jdo/trunk/api20/src/java/javax/jdo/Extent.java
incubator/jdo/trunk/api20/src/java/javax/jdo/FetchPlan.java
incubator/jdo/trunk/api20/src/java/javax/jdo/InstanceCallbacks.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOCanRetryException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDODataStoreException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDODetachedFieldAccessException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalDataStoreException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalInternalException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalUserException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOObjectNotFoundException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOOptimisticVerificationException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUnsupportedOptionException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUserException.java
incubator/jdo/trunk/api20/src/java/javax/jdo/PersistenceManager.java
incubator/jdo/trunk/api20/src/java/javax/jdo/PersistenceManagerFactory.java
incubator/jdo/trunk/api20/src/java/javax/jdo/Query.java
incubator/jdo/trunk/api20/src/java/javax/jdo/Transaction.java
incubator/jdo/trunk/api20/src/java/javax/jdo/datastore/
incubator/jdo/trunk/api20/src/java/javax/jdo/datastore/DataStoreCache.java
incubator/jdo/trunk/api20/src/java/javax/jdo/datastore/JDOConnection.java
incubator/jdo/trunk/api20/src/java/javax/jdo/datastore/Sequence.java
incubator/jdo/trunk/api20/src/java/javax/jdo/datastore/package.html
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/ByteIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/CharIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/IntIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/LongIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/ShortIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/SingleFieldIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/StringIdentity.java
incubator/jdo/trunk/api20/src/java/javax/jdo/identity/package.html
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/AttachCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/AttachLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/ClearCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/ClearLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/CreateLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/DeleteCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/DeleteLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/DetachCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/DetachLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/DirtyLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/InstanceLifecycleEvent.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/InstanceLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/LoadCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/LoadLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/StoreCallback.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/StoreLifecycleListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/listener/package.html
incubator/jdo/trunk/api20/src/java/javax/jdo/package.html
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/Detachable.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/I18NHelper.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOImplHelper.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOPermission.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/PersistenceCapable.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/RegisterClassEvent.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/RegisterClassListener.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/StateInterrogation.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/StateManager.java
incubator/jdo/trunk/api20/src/java/javax/jdo/spi/package.html
incubator/jdo/trunk/api20/test/
incubator/jdo/trunk/api20/test/java/
incubator/jdo/trunk/api20/test/java/javax/
incubator/jdo/trunk/api20/test/java/javax/jdo/
incubator/jdo/trunk/api20/test/java/javax/jdo/JDOHelperTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/ByteIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/CharIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/ConcreteTestIdentity.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/IntIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/LongIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/ShortIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/SingleFieldIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/identity/StringIdentityTest.java
incubator/jdo/trunk/api20/test/java/javax/jdo/listener/
Modified:
incubator/jdo/trunk/api20/project.xml
Modified: incubator/jdo/trunk/api20/project.xml
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/project.xml?view=diff&r1=159272&r2=159273
==============================================================================
--- incubator/jdo/trunk/api20/project.xml (original)
+++ incubator/jdo/trunk/api20/project.xml Mon Mar 28 10:25:05 2005
@@ -21,7 +21,7 @@
<!-- ============== -->
<!-- Identification -->
<!-- ============== -->
- <name>JDO API 2.0</name>
+ <name>JDO</name>
<artifactId>jdo-api</artifactId>
<currentVersion>2.0</currentVersion>
<package>javax.jdo</package>
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/Bundle.properties
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/Bundle.properties?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/Bundle.properties (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/Bundle.properties Mon Mar 28
10:25:05 2005
@@ -0,0 +1,47 @@
+#
+# 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.
+
+# ResourceBundle properties file for JDO
+ERR_AbstractClassNoIdentity=Abstract class {0} does not implement key field
helper methods
+ERR_CannotInitCause=The initCause method cannot be used. To set the cause of
this exception, \
+use a constructor with a Throwable[] argument.
+ERR_StateManagerClassCast=An element of the parameter collection is of class
{0}. \
+The parameter collection must contain only elements that are instances of
java.lang.Class.
+ERR_NoMetadata=No metadata has been registered for class {0}.
+ERR_NoSuchMethod=Method getPersistenceManagerFactory(Properties) does not
exist or is not public
+ERR_UnexpectedException=Unexpected exception caught
+EXC_ClassNotFound=Class {0} was not found
+EXC_IllegalAccess=Illegal Access for class {0}
+EXC_NoClassNameProperty=A property named PersistenceManagerFactoryClass must
be specified.
+EXC_getPersistenceManagerFactory=Exception thrown by
getPersistenceManagerFactory(Properties)
+MSG_FailedObject=FailedObject:
+MSG_NestedThrowables=NestedThrowables:
+MSG_NestedThrowablesStackTrace=NestedThrowablesStackTrace:
+MSG_ExceptionGettingFailedToString=Exception getting failed.toString():
''{0}''.
+MSG_ExceptionGettingFailedToStringObjectId=Exception getting
failed.toString(): ''{0}''. ObjectId of failed instance: ''{1}''.
+ERR_NullClass=JDO implementation error: the parameter class object must not be
null.
+EXC_NullResource: The resource name argument to this method cannot be null.
+EXC_NullLoader: The class loader argument to this method cannot be null.
+EXC_NoResource: The resource named "{0}" could not be found in the class
loader "{1}".
+EXC_IOExceptionRsrc: An IOException was thrown while loading the resource \
+named "{0}" into a java.util.Properties object.
+EXC_NullFile: The file argument to this method cannot be null.
+EXC_NoFile: The file named "{0}" could not be found.
+EXC_IOExceptionFile: An IOException was thrown while loading the file \
+named "{0}" into a java.util.Properties object.
+EXC_NullJndiLoc: The JNDI location argument to this method cannot be null.
+EXC_NamingException: A NamingException was thrown while obtaining the \
+PersistenceManagerFactory at "{0}" from JNDI.
+EXC_StringWrongLength: There must be exactly one character in the input String
for CharIdentity.
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/Extent.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/Extent.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/Extent.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/Extent.java Mon Mar 28
10:25:05 2005
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+/*
+ * Extent.java
+ *
+ */
+
+package javax.jdo;
+
+import java.util.Iterator;
+
+/** Instances of the <code>Extent</code> class represent the entire collection
+ * of instances in the data store of the candidate class
+ * possibly including its subclasses.
+ * <P>The <code>Extent</code> instance has two possible uses:
+ * <ol>
+ * <li>to iterate all instances of a particular class
+ * <li>to execute a <code>Query</code> in the data store over all instances
+ * of a particular class
+ * </ol>
+ * @version 2.0
+ */
+public interface Extent {
+
+ /** Returns an iterator over all the instances in the <code>Extent</code>.
+ * The behavior of the returned iterator might depend on the setting of the
+ * <code>ignoreCache</code> flag in the owning
<code>PersistenceManager</code>.
+ * @return an iterator over all instances in the <code>Extent</code>
+ */
+ Iterator iterator();
+
+ /** Returns whether this <code>Extent</code> was defined to contain
subclasses.
+ * @return true if this <code>Extent</code> was defined to contain
instances
+ * that are of a subclass type.
+ */
+ boolean hasSubclasses();
+
+ /** An <code>Extent</code> contains all instances of a particular class in
the data
+ * store; this method returns the <code>Class</code> of the instances.
+ * @return the <code>Class</code> of instances of this
<code>Extent</code>.
+ */
+ Class getCandidateClass();
+
+ /** An <code>Extent</code> is managed by a <code>PersistenceManager</code>;
+ * this method gives access to the owning <code>PersistenceManager</code>.
+ * @return the owning <code>PersistenceManager</code>
+ */
+ PersistenceManager getPersistenceManager();
+
+ /** Close all <code>Iterator</code>s associated with this
<code>Extent</code> instance.
+ * <code>Iterator</code>s closed by this method will return
<code>false</code>
+ * to <code>hasNext()</code> and will throw
+ * <code>NoSuchElementException</code> on <code>next()</code>.
+ * The <code>Extent</code> instance can still be used
+ * as a parameter of <code>Query.setExtent</code>, and to get an
<code>Iterator</code>.
+ */
+ void closeAll ();
+
+ /** Close an <code>Iterator</code> associated with this
<code>Extent</code> instance.
+ * <code>Iterator</code>s closed by this method will return
<code>false</code>
+ * to <code>hasNext()</code> and will throw
<code>NoSuchElementException</code>
+ * on <code>next()</code>. The <code>Extent</code> instance can still be
used
+ * as a parameter of <code>Query.setExtent</code>, and to get an
<code>Iterator</code>.
+ * @param it an <code>Iterator</code> obtained by the method
+ * <code>iterator()</code> on this <code>Extent</code> instance.
+ */
+ void close (Iterator it);
+
+ /** Get the fetch plan associated with this Extent.
+ * @return the fetch plan
+ * @since 2.0
+ */
+ FetchPlan getFetchPlan();
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/FetchPlan.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/FetchPlan.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/FetchPlan.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/FetchPlan.java Mon Mar 28
10:25:05 2005
@@ -0,0 +1,142 @@
+/*
+ * FetchPlan.java
+ *
+ * Created on June 10, 2004
+ */
+
+package javax.jdo;
+
+
+import java.util.Collection;
+import javax.jdo.*;
+
+
+/**
+ * Fetch groups are activated using methods on this interface. An
+ * instance of this interface can be obtained from [EMAIL PROTECTED]
+ * PersistenceManager#getFetchPlan}, [EMAIL PROTECTED] Extent#getFetchPlan},
and
+ * [EMAIL PROTECTED] Query#getFetchPlan}. When a <code>Query</code> or
+ * <code>Extent</code> is retrieved from a
+ * <code>PersistenceManager</code>, its <code>FetchPlan</code> is
+ * initialized to the same settings as that of the
+ * <code>PersistenceManager</code>. Subsequent modifications of the
+ * <code>Query</code> or <code>Extent</code>'s <code>FetchPlan</code>
+ * are not reflected in the <code>FetchPlan</code> of the
+ * <code>PersistenceManager</code>.
+ * @version 2.0
+ * @since 2.0
+ */
+public interface FetchPlan {
+
+ /**
+ * For use with [EMAIL PROTECTED] #addGroup}, [EMAIL PROTECTED]
#removeGroup}, and the
+ * various [EMAIL PROTECTED] #setGroups} calls. Value:
<code>default</code>.
+ * @since 2.0
+ */
+ public static final String DEFAULT = "default";
+
+ /**
+ * For use with [EMAIL PROTECTED] #addGroup}, [EMAIL PROTECTED]
#removeGroup}, and the
+ * various [EMAIL PROTECTED] #setGroups} calls. Value: <code>all</code>.
+ * @since 2.0
+ */
+ public static final String ALL = "all";
+
+ /**
+ * For use with [EMAIL PROTECTED] #addGroup}, [EMAIL PROTECTED]
#removeGroup}, and the
+ * various [EMAIL PROTECTED] #setGroups} calls. Value: <code>values</code>.
+ * @since 2.0
+ */
+ public static final String VALUES = "values";
+
+ /**
+ * For use with [EMAIL PROTECTED] #addGroup}, [EMAIL PROTECTED]
#removeGroup}, and the
+ * various [EMAIL PROTECTED] #setGroups} calls. Value: <code>none</code>.
+ * ### this is not mentioned in 12.7.2. It is referred to in 12.7's text.
+ * @since 2.0
+ */
+ public static final String NONE = "none";
+
+ /**
+ * For use with [EMAIL PROTECTED] #setFetchSize}. Value: -1.
+ * @since 2.0
+ */
+ public static final int FETCH_SIZE_GREEDY = -1;
+
+ /**
+ * For use with [EMAIL PROTECTED] #setFetchSize}. Value: 0.
+ * @since 2.0
+ */
+ public static final int FETCH_SIZE_OPTIMAL = 0;
+
+ /**
+ * Add the fetch group to the set of active fetch groups.
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan addGroup(String fetchGroupName);
+
+ /**
+ * Remove the fetch group from the set active fetch groups.
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan removeGroup(String fetchGroupName);
+
+ /**
+ * Remove all active groups leaving no active fetch group.
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan clearGroups();
+
+ /**
+ * Return the names of all active fetch groups.
+ * @return the names of active fetch groups
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ Collection getGroups();
+
+ /**
+ * Set a collection of groups.
+ * @param fetchGroupNames a collection of names of fetch groups
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan setGroups(Collection fetchGroupNames);
+
+ /**
+ * Set a collection of groups.
+ * @param fetchGroupNames a String array of names of fetch groups
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan setGroups(String[]fetchGroupNames);
+
+ /**
+ * Set the active fetch groups to the single named fetch group.
+ * @param fetchGroupName the single fetch group
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan setGroup(String fetchGroupName);
+
+ /**
+ * Set the fetch size for large result set support. Use
+ * [EMAIL PROTECTED] #FETCH_SIZE_OPTIMAL} to unset, and [EMAIL PROTECTED]
#FETCH_SIZE_GREEDY}
+ * to force loading of everything.
+ * @param fetchSize the fetch size
+ * @return the FetchPlan
+ * @since 2.0
+ */
+ FetchPlan setFetchSize(int fetchSize);
+
+ /**
+ * Return the fetch size, or [EMAIL PROTECTED] #FETCH_SIZE_OPTIMAL} if not
set,
+ * or [EMAIL PROTECTED] #FETCH_SIZE_GREEDY} to fetch all.
+ * @return the fetch size
+ * @since 2.0
+ */
+ int getFetchSize();
+}
\ No newline at end of file
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/InstanceCallbacks.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/InstanceCallbacks.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/InstanceCallbacks.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/InstanceCallbacks.java Mon Mar
28 10:25:05 2005
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*
+ * InstanceCallbacks.java
+ *
+ */
+
+package javax.jdo;
+
+/** A <code>PersistenceCapable</code> class that provides callback methods for
life
+ * cycle events implements this interface.
+ *
+ * <P>Classes which include non-persistent fields whose values depend
+ * on the values of persistent fields require callbacks on specific
+ * JDO instance life cycle events in order to correctly populate the
+ * values in these fields.
+ *
+ * <P>This interface defines the methods executed
+ * by the <code>PersistenceManager</code> for these life cycle events. If the
class
+ * implements <code>InstanceCallbacks</code>, it must explicitly declare it in
the
+ * class definition.
+ *
+ * <P>The callbacks might also be used if the persistent instances
+ * need to be put into the runtime infrastructure of the application.
+ * For example, a persistent instance might notify other instances
+ * on changes to state. The persistent instance is in a list of
+ * managed instances, and when the persistent instance is made hollow,
+ * it can no longer generate change events, and the persistent
+ * instance should be removed from the list of managed instances.
+ *
+ * <P>To implement this, the application programmer would implement
+ * the <code>jdoPostLoad</code> callback to put itself into the list of managed
+ * instances; and implement the <code>jdoPreClear</code> to remove itself from
+ * the list.
+ *
+ * <P>Note that JDO does not manage the state of non-persistent
+ * fields, and when a JDO instance transitions to hollow, JDO clears
+ * the persistent fields. It is the programmer's responsibility to
+ * clear non-persistent fields so that garbage collection of
+ * referred instances can occur.
+ *
+ * @version 2.0
+ */
+public interface InstanceCallbacks
+ extends javax.jdo.listener.ClearCallback,
+ javax.jdo.listener.DeleteCallback,
+ javax.jdo.listener.LoadCallback,
+ javax.jdo.listener.StoreCallback {
+
+ /**
+ * Called after the values are loaded from the data store into
+ * this instance.
+ *
+ * <P>This method is not modified by the Reference Enhancer.
+ * <P>Derived fields should be initialized in this method.
+ * The context in which this call is made does not allow access to
+ * other persistent JDO instances.
+ */
+ void jdoPostLoad();
+
+ /**
+ * Called before the values are stored from this instance to the
+ * data store.
+ *
+ * <P>Data store fields that might have been affected by modified
+ * non-persistent fields should be updated in this method.
+ *
+ * <P>This method is modified by the enhancer so that changes to
+ * persistent fields will be reflected in the data store.
+ * The context in which this call is made allows access to the
+ * <code>PersistenceManager</code> and other persistent JDO instances.
+ */
+ void jdoPreStore();
+
+ /**
+ * Called before the values in the instance are cleared.
+ *
+ * <P>Transient fields should be cleared in this method.
+ * Associations between this
+ * instance and others in the runtime environment should be cleared.
+ *
+ * <P>This method is not modified by the enhancer.
+ */
+ void jdoPreClear();
+
+ /**
+ * Called before the instance is deleted.
+ * This method is called before the state transition to persistent-deleted
+ * or persistent-new-deleted. Access to field values within this call
+ * are valid. Access to field values after this call are disallowed.
+ * <P>This method is modified by the enhancer so that fields referenced
+ * can be used in the business logic of the method.
+ */
+ void jdoPreDelete();
+}
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOCanRetryException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOCanRetryException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOCanRetryException.java
(added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOCanRetryException.java Mon
Mar 28 10:25:05 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOCanRetryException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This is the base class for exceptions that can be retried.
+ *
+ * @version 1.0
+ */
+public class JDOCanRetryException extends JDOException {
+
+ /**
+ * Constructs a new <code>JDOCanRetryException</code> without a detail
message.
+ */
+ public JDOCanRetryException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOCanRetryException</code> with the specified
detail message.
+ * @param msg the detail message.
+ */
+ public JDOCanRetryException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOCanRetryException</code> with the specified
detail
+ * message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOCanRetryException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOCanRetryException</code> with the specified
detail
+ * message and nested <code>Throwable<code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOCanRetryException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /** Constructs a new <code>JDOCanRetryException</code> with the specified
detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOCanRetryException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /** Constructs a new <code>JDOCanRetryException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDOCanRetryException(String msg, Throwable[] nested, Object failed) {
+ super(msg, nested, failed);
+
+ }
+ /** Constructs a new <code>JDOCanRetryException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDOCanRetryException(String msg, Throwable nested, Object failed) {
+ super(msg, nested, failed);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDODataStoreException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDODataStoreException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDODataStoreException.java
(added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDODataStoreException.java Mon
Mar 28 10:25:05 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDODataStoreException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents data store exceptions that can be retried.
+ *
+ * @version 1.0
+ */
+public class JDODataStoreException extends JDOCanRetryException {
+
+ /**
+ * Constructs a new <code>JDODataStoreException</code> without a detail
message.
+ */
+ public JDODataStoreException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDODataStoreException</code> with the specified
detail message.
+ * @param msg the detail message.
+ */
+ public JDODataStoreException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDODataStoreException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDODataStoreException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDODataStoreException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDODataStoreException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /** Constructs a new <code>JDODataStoreException</code> with the specified
detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDODataStoreException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /** Constructs a new <code>JDODataStoreException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDODataStoreException(String msg, Throwable[] nested, Object failed) {
+ super(msg, nested, failed);
+ }
+
+ /** Constructs a new <code>JDODataStoreException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDODataStoreException(String msg, Throwable nested, Object failed) {
+ super(msg, nested, failed);
+ }
+
+}
+
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDODetachedFieldAccessException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDODetachedFieldAccessException.java?view=auto&rev=159273
==============================================================================
---
incubator/jdo/trunk/api20/src/java/javax/jdo/JDODetachedFieldAccessException.java
(added)
+++
incubator/jdo/trunk/api20/src/java/javax/jdo/JDODetachedFieldAccessException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDODetachedFieldAccessException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents exceptions caused by access of an unloaded field
while
+ * the instance is detached.
+ *
+ * @version 2.0
+ * @since 2.0
+ */
+public class JDODetachedFieldAccessException extends JDOUserException {
+
+ /**
+ * Constructs a new <code>JDODetachedFieldAccessException</code> without a
detail message.
+ * @since 2.0
+ */
+ public JDODetachedFieldAccessException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDODetachedFieldAccessException</code> with the
specified detail message.
+ * @param msg the detail message.
+ * @since 2.0
+ */
+ public JDODetachedFieldAccessException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDODetachedFieldAccessException</code> with the
+ * specified detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @since 2.0
+ */
+ public JDODetachedFieldAccessException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDODetachedFieldAccessException</code> with the
+ * specified detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @since 2.0
+ */
+ public JDODetachedFieldAccessException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOException.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOException.java Mon Mar 28
10:25:05 2005
@@ -0,0 +1,295 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOException.java
+ *
+ */
+
+package javax.jdo;
+
+import javax.jdo.spi.I18NHelper;
+
+/** This is the root of all JDO Exceptions. It contains an optional detail
+ * message, an optional nested <code>Throwable</code> array and an optional
failed object.
+ * @author Craig Russell
+ * @version 1.0.2
+ */
+public class JDOException extends java.lang.RuntimeException {
+
+ /** This exception was generated because of an exception in the runtime
library.
+ * @serial the nested <code>Throwable</code> array
+ */
+ Throwable[] nested;
+
+ /** This exception may be the result of incorrect parameters supplied
+ * to an API. This is the object from which the user can determine
+ * the cause of the problem.
+ * @serial the failed <code>Object</code>
+ */
+ Object failed;
+
+ /** The Internationalization message helper.
+ */
+ private static I18NHelper msg = I18NHelper.getInstance
("javax.jdo.Bundle"); //NOI18N
+
+ /** Flag indicating whether printStackTrace is being executed.
+ */
+ private boolean inPrintStackTrace = false;
+
+ /**
+ * Constructs a new <code>JDOException</code> without a detail message.
+ */
+ public JDOException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOException</code> with the specified detail
message.
+ * @param msg the detail message.
+ */
+ public JDOException(String msg) {
+ super(msg);
+ }
+
+ /** Constructs a new <code>JDOException</code> with the specified detail
message
+ * and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOException(String msg, Throwable[] nested) {
+ super(msg);
+ this.nested = nested;
+ }
+
+ /** Constructs a new <code>JDOException</code> with the specified detail
message
+ * and nested <code>Throwable</code>.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOException(String msg, Throwable nested) {
+ super(msg);
+ this.nested = new Throwable[] {nested};
+ }
+
+ /** Constructs a new <code>JDOException</code> with the specified detail
message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOException(String msg, Object failed) {
+ super(msg);
+ this.failed = failed;
+ }
+
+ /** Constructs a new <code>JDOException</code> with the specified detail
message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDOException(String msg, Throwable[] nested, Object failed) {
+ super(msg);
+ this.nested = nested;
+ this.failed = failed;
+ }
+
+ /** Constructs a new <code>JDOException</code> with the specified detail
message,
+ * nested <code>Throwable</code>, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDOException(String msg, Throwable nested, Object failed) {
+ super(msg);
+ this.nested = new Throwable[] {nested};
+ this.failed = failed;
+ }
+
+ /** The exception may include a failed object.
+ * @return the failed object.
+ */
+ public Object getFailedObject() {
+ return failed;
+ }
+
+ /** The exception may have been caused by multiple exceptions in the runtime.
+ * If multiple objects caused the problem, each failed object will have
+ * its own <code>Exception</code>.
+ * @return the nested Throwable array.
+ */
+ public Throwable[] getNestedExceptions() {
+ return nested;
+ }
+
+ /** Often there is only one nested exception, and this method returns it.
+ * If there are more than one, then this method returns the first nested
+ * exception. If there is no nested exception, then null is returned.
+ * @return the first or only nested Throwable.
+ * @since 1.0.1
+ */
+ public synchronized Throwable getCause() {
+ // super.printStackTrace calls getCause to handle the cause.
+ // Returning null prevents the superclass from handling the cause;
+ // instead the local implementation of printStackTrace should
+ // handle the cause. Otherwise, the cause is printed twice.
+ if (nested == null || nested.length == 0 || inPrintStackTrace) {
+ return null;
+ } else {
+ return nested[0];
+ }
+ }
+
+ /** JDK 1.4 includes a new chaining mechanism for Throwable, but since
+ * JDO has its own "legacy" chaining mechanism, the "standard" mechanism
+ * cannot be used. This method always throws a JDOFatalInternalException.
+ * @param cause ignored.
+ * @return never.
+ */
+ public Throwable initCause(Throwable cause) {
+ throw new JDOFatalInternalException(msg.msg("ERR_CannotInitCause"));
+ }
+
+ /** The <code>String</code> representation includes the name of the class,
+ * the descriptive comment (if any),
+ * the <code>String</code> representation of the failed <code>Object</code>
(if any),
+ * and the <code>String</code> representation of the nested
<code>Throwable</code>s (if any).
+ * @return the <code>String</code>.
+ */
+ public synchronized String toString() {
+ int len = nested==null?0:nested.length;
+ // calculate approximate size of the String to return
+ StringBuffer sb = new StringBuffer (10 + 100 * len);
+ sb.append (super.toString());
+ // include failed object information
+ if (failed != null) {
+ sb.append ("\n").append (msg.msg ("MSG_FailedObject"));
+ String failedToString = null;
+ try {
+ failedToString = failed.toString();
+ } catch (Exception ex) {
+ // include the information from the exception thrown by
failed.toString
+ Object objectId = JDOHelper.getObjectId(failed);
+ if (objectId == null) {
+ failedToString = msg.msg("MSG_ExceptionGettingFailedToString",
//NOI18N
+ exceptionToString(ex));
+ }
+ else {
+ // include the ObjectId information
+ String objectIdToString = null;
+ try {
+ objectIdToString = objectId.toString();
+ }
+ catch (Exception ex2) {
+ objectIdToString = exceptionToString(ex2);
+ }
+ failedToString =
msg.msg("MSG_ExceptionGettingFailedToStringObjectId", //NOI18N
+ exceptionToString(ex),
objectIdToString);
+ }
+ }
+ sb.append (failedToString);
+ }
+ // include nested Throwable information, but only if not called by
+ // printStackTrace; the stacktrace will include the cause anyway.
+ if (len > 0 && !inPrintStackTrace) {
+ sb.append ("\n").append (msg.msg ("MSG_NestedThrowables")).append ("\n");
+ Throwable exception = nested[0];
+ sb.append (exception==null?"null":exception.toString()); //NOI18N
+ for (int i=1; i<len; ++i) {
+ sb.append ("\n"); //NOI18N
+ exception = nested[i];
+ sb.append (exception==null?"null":exception.toString()); //NOI18N
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Prints this <code>JDOException</code> and its backtrace to the
+ * standard error output.
+ * Print nested Throwables' stack trace as well.
+ */
+ public void printStackTrace() {
+ printStackTrace (System.err);
+ }
+
+ /**
+ * Prints this <code>JDOException</code> and its backtrace to the
+ * specified print stream.
+ * Print nested Throwables' stack trace as well.
+ * @param s <code>PrintStream</code> to use for output
+ */
+ public synchronized void printStackTrace(java.io.PrintStream s) {
+ int len = nested==null?0:nested.length;
+ synchronized (s) {
+ inPrintStackTrace = true;
+ super.printStackTrace(s);
+ if (len > 0) {
+ s.println (msg.msg ("MSG_NestedThrowablesStackTrace"));
+ for (int i=0; i<len; ++i) {
+ Throwable exception = nested[i];
+ if (exception != null) {
+ exception.printStackTrace(s);
+ }
+ }
+ }
+ inPrintStackTrace = false;
+ }
+ }
+
+ /**
+ * Prints this <code>JDOException</code> and its backtrace to the specified
+ * print writer.
+ * Print nested Throwables' stack trace as well.
+ * @param s <code>PrintWriter</code> to use for output
+ */
+ public synchronized void printStackTrace(java.io.PrintWriter s) {
+ int len = nested==null?0:nested.length;
+ synchronized (s) {
+ inPrintStackTrace = true;
+ super.printStackTrace(s);
+ if (len > 0) {
+ s.println (msg.msg ("MSG_NestedThrowablesStackTrace"));
+ for (int i=0; i<len; ++i) {
+ Throwable exception = nested[i];
+ if (exception != null) {
+ exception.printStackTrace(s);
+ }
+ }
+ }
+ inPrintStackTrace = false;
+ }
+ }
+
+ /**
+ * Helper method returning a short description of the exception passed
+ * as an argument. The returned string has the format defined by
+ * Throwable.toString. If the exception has a non-null detail message
+ * string, then it returns the name of exception class concatenated
+ * with ": " concatenated with the detailed message. Otherwise it
+ * returns the name of exception class.
+ * @param ex the exception to be represented.
+ * @return a string representation of the exception passed as an argument.
+ */
+ private static String exceptionToString(Exception ex)
+ {
+ if (ex == null) return null;
+ String s = ex.getClass().getName();
+ String message = ex.getMessage();
+ return (message != null) ? (s + ": " + message) : s;
+ }
+}
+
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalDataStoreException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalDataStoreException.java?view=auto&rev=159273
==============================================================================
---
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalDataStoreException.java
(added)
+++
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalDataStoreException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOFatalDataStoreException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents data store exceptions that cannot be retried.
+ *
+ * @version 1.0.1
+ */
+public class JDOFatalDataStoreException extends JDOFatalException {
+
+ /**
+ * Constructs a new <code>JDOFatalDataStoreException</code> without a detail
message.
+ */
+ public JDOFatalDataStoreException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOFatalDataStoreException</code> with the
specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOFatalDataStoreException(String msg) {
+ super(msg);
+ }
+
+ /** Constructs a new <code>JDOFatalDataStoreException</code> with the
specified detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOFatalDataStoreException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalDataStoreException</code> with the
specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOFatalDataStoreException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalDataStoreException</code> with the
specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOFatalDataStoreException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalException.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalException.java Mon Mar
28 10:25:05 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOFatalException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents exceptions that are fatal; that is, the condition
+ * that caused it cannot be bypassed even if the operation is retried.
+ *
+ * @version 1.0
+ */
+public class JDOFatalException extends JDOException {
+
+ /**
+ * Constructs a new <code>JDOFatalException</code> without a detail message.
+ */
+ public JDOFatalException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOFatalException</code> with the specified detail
message.
+ * @param msg the detail message.
+ */
+ public JDOFatalException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalException</code> with the specified detail
+ * message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOFatalException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalException</code> with the specified detail
+ * message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOFatalException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /** Constructs a new <code>JDOFatalException</code> with the specified
detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOFatalException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /** Constructs a new <code>JDOFatalException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDOFatalException(String msg, Throwable[] nested, Object failed) {
+ super(msg, nested, failed);
+
+ }
+ /** Constructs a new <code>JDOFatalException</code> with the specified
detail message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDOFatalException(String msg, Throwable nested, Object failed) {
+ super(msg, nested, failed);
+ }
+}
+
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalInternalException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalInternalException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalInternalException.java
(added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalInternalException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOFatalInternalException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents errors in the implementation for which no user
+ * error handling is possible. The error should be reported to the JDO
+ * vendor for corrective action.
+ *
+ * @version 1.0
+ */
+public class JDOFatalInternalException extends JDOFatalException {
+
+ /**
+ * Constructs a new <code>JDOFatalInternalException</code> without a detail
message.
+ */
+ public JDOFatalInternalException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOFatalInternalException</code> with the
specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOFatalInternalException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalInternalException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOFatalInternalException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalInternalException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOFatalInternalException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalUserException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalUserException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalUserException.java
(added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOFatalUserException.java Mon
Mar 28 10:25:05 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOUserException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents user errors that cannot be retried.
+ *
+ * @version 1.0
+ */
+public class JDOFatalUserException extends JDOFatalException {
+
+ /**
+ * Constructs a new <code>JDOFatalUserException</code> without a detail
message.
+ */
+ public JDOFatalUserException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOFatalUserException</code> with the specified
detail message.
+ * @param msg the detail message.
+ */
+ public JDOFatalUserException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalUserException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOFatalUserException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOFatalUserException</code> with the specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOFatalUserException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /** Constructs a new <code>JDOFatalUserException</code> with the specified
+ * detail message and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOFatalUserException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /** Constructs a new <code>JDOFatalUserException</code> with the specified
+ * detail message, nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDOFatalUserException(String msg, Throwable[] nested, Object failed) {
+ super(msg, nested, failed);
+ }
+
+ /** Constructs a new <code>JDOFatalUserException</code> with the specified
+ * detail message, nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDOFatalUserException(String msg, Throwable nested, Object failed) {
+ super(msg, nested, failed);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOHelper.java Mon Mar 28
10:25:05 2005
@@ -0,0 +1,478 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOHelper.java
+ *
+ */
+
+package javax.jdo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+import java.util.Properties;
+
+import javax.jdo.spi.I18NHelper;
+import javax.jdo.spi.PersistenceCapable;
+import javax.jdo.spi.StateManager; // for javadoc
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import javax.rmi.PortableRemoteObject;
+
+
+/**
+ * This class can be used by a JDO-aware application to call the JDO behavior
+ * of <code>PersistenceCapable</code> instances without declaring them to be
+ * <code>PersistenceCapable</code>.
+ * It is also used to acquire a <code>PersistenceManagerFactory</code> via
+ * various methods.
+ * <P>This helper class defines static methods that allow a JDO-aware
+ * application to examine the runtime state of instances. For example,
+ * an application can discover whether the instance is persistent,
transactional,
+ * dirty, new, or deleted; and to get its associated
+ * <code>PersistenceManager</code> if it has one.
+ *
+ * @version 2.0
+ */
+public class JDOHelper extends Object {
+
+ /** The Internationalization message helper.
+ */
+ private final static I18NHelper msg = I18NHelper.getInstance
("javax.jdo.Bundle"); //NOI18N
+
+ /** Return the associated <code>PersistenceManager</code> if there is one.
+ * Transactional and persistent instances return the associated
+ * <code>PersistenceManager</code>.
+ *
+ * <P>Transient non-transactional instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>null</code>.
+ * @see PersistenceCapable#jdoGetPersistenceManager()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return the <code>PersistenceManager</code> associated with the
parameter instance.
+ */
+ public static PersistenceManager getPersistenceManager(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoGetPersistenceManager():null;
+ }
+
+ /** Explicitly mark the parameter instance and field dirty.
+ * Normally, <code>PersistenceCapable</code> classes are able to detect
changes made
+ * to their fields. However, if a reference to an array is given to a
+ * method outside the class, and the array is modified, then the
+ * persistent instance is not aware of the change. This API allows the
+ * application to notify the instance that a change was made to a field.
+ *
+ * <P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> ignore this
method.
+ * @see PersistenceCapable#jdoMakeDirty(String fieldName)
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @param fieldName the name of the field to be marked dirty.
+ */
+ public static void makeDirty(Object pc, String fieldName) {
+ if (pc instanceof PersistenceCapable)
+ ((PersistenceCapable)pc).jdoMakeDirty(fieldName);
+ }
+
+ /** Return a copy of the JDO identity associated with the parameter
instance.
+ *
+ * <P>Persistent instances of <code>PersistenceCapable</code> classes have
a JDO identity
+ * managed by the <code>PersistenceManager</code>. This method returns a
copy of the
+ * ObjectId that represents the JDO identity.
+ *
+ * <P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>null</code>.
+ *
+ * <P>The ObjectId may be serialized
+ * and later restored, and used with a <code>PersistenceManager</code>
from the same JDO
+ * implementation to locate a persistent instance with the same data store
+ * identity.
+ *
+ * <P>If the JDO identity is managed by the application, then the ObjectId
may
+ * be used with a <code>PersistenceManager</code> from any JDO
implementation that supports
+ * the <code>PersistenceCapable</code> class.
+ *
+ * <P>If the JDO identity is not managed by the application or the data
store,
+ * then the ObjectId returned is only valid within the current transaction.
+ *<P>
+ * @see PersistenceManager#getObjectId(Object pc)
+ * @see PersistenceCapable#jdoGetObjectId()
+ * @see PersistenceManager#getObjectById(Object oid, boolean validate)
+ * @param pc the PersistenceCapable instance.
+ * @return a copy of the ObjectId of the parameter instance as of the
beginning of the transaction.
+ */
+ public static Object getObjectId(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoGetObjectId():null;
+ }
+
+ /** Return a copy of the JDO identity associated with the parameter
instance.
+ *
+ * @see PersistenceCapable#jdoGetTransactionalObjectId()
+ * @see PersistenceManager#getObjectById(Object oid, boolean validate)
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return a copy of the ObjectId of the parameter instance as modified in
this transaction.
+ */
+ public static Object getTransactionalObjectId(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoGetTransactionalObjectId():null;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static Object getVersion (Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoGetVersion():null;
+ }
+ /** Tests whether the parameter instance is dirty.
+ *
+ * Instances that have been modified, deleted, or newly
+ * made persistent in the current transaction return <code>true</code>.
+ *
+ *<P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>false</code>.
+ *<P>
+ * @see StateManager#makeDirty(PersistenceCapable pc, String fieldName)
+ * @see PersistenceCapable#jdoIsDirty()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return <code>true</code> if the parameter instance has been modified
in the current transaction.
+ */
+ public static boolean isDirty(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsDirty():false;
+ }
+
+ /** Tests whether the parameter instance is transactional.
+ *
+ * Instances whose state is associated with the current transaction
+ * return true.
+ *
+ *<P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>false</code>.
+ * @see PersistenceCapable#jdoIsTransactional()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return <code>true</code> if the parameter instance is transactional.
+ */
+ public static boolean isTransactional(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsTransactional():false;
+ }
+
+ /** Tests whether the parameter instance is persistent.
+ *
+ * Instances that represent persistent objects in the data store
+ * return <code>true</code>.
+ *
+ *<P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>false</code>.
+ *<P>
+ * @see PersistenceManager#makePersistent(Object pc)
+ * @see PersistenceCapable#jdoIsPersistent()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return <code>true</code> if the parameter instance is persistent.
+ */
+ public static boolean isPersistent(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsPersistent():false;
+ }
+
+ /** Tests whether the parameter instance has been newly made persistent.
+ *
+ * Instances that have been made persistent in the current transaction
+ * return <code>true</code>.
+ *
+ *<P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>false</code>.
+ *<P>
+ * @see PersistenceManager#makePersistent(Object pc)
+ * @see PersistenceCapable#jdoIsNew()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return <code>true</code> if the parameter instance was made persistent
+ * in the current transaction.
+ */
+ public static boolean isNew(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsNew():false;
+ }
+
+ /** Tests whether the parameter instance has been deleted.
+ *
+ * Instances that have been deleted in the current transaction return
<code>true</code>.
+ *
+ *<P>Transient instances and instances of classes
+ * that do not implement <code>PersistenceCapable</code> return
<code>false</code>.
+ *<P>
+ * @see PersistenceManager#deletePersistent(Object pc)
+ * @see PersistenceCapable#jdoIsDeleted()
+ * @param pc the <code>PersistenceCapable</code> instance.
+ * @return <code>true</code> if the parameter instance was deleted
+ * in the current transaction.
+ */
+ public static boolean isDeleted(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsDeleted():false;
+ }
+
+ /** Tests whether the parameter instance has been detached.
+ *
+ * Instances that have been detached return true.
+ *
+ *<P>Transient instances return false.
+ *<P>
+ * @see PersistenceCapable#jdoIsDetached()
+ * @return <code>true</code> if this instance is detached.
+ * @since 2.0
+ */
+ public static boolean isDetached(Object pc) {
+ return pc instanceof
PersistenceCapable?((PersistenceCapable)pc).jdoIsDetached():false;
+ }
+
+ /** Get a <code>PersistenceManagerFactory</code> based on a
<code>Properties</code> instance, using
+ * the current thread's context class loader to locate the
+ * <code>PersistenceManagerFactory</code> class.
+ * @return the <code>PersistenceManagerFactory</code>.
+ * @param props a <code>Properties</code> instance with properties of the
<code>PersistenceManagerFactory</code>.
+ * @see #getPersistenceManagerFactory(Properties,ClassLoader)
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (Properties props) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return getPersistenceManagerFactory (props, cl);
+ }
+
+ /** Get a <code>PersistenceManagerFactory</code> based on a
<code>Properties</code>
+ * instance and a class loader.
+ * The following are standard key values:
+ * <BR><code>"javax.jdo.PersistenceManagerFactoryClass"
+ * <BR>"javax.jdo.option.Optimistic",
+ * <BR>"javax.jdo.option.RetainValues",
+ * <BR>"javax.jdo.option.RestoreValues",
+ * <BR>"javax.jdo.option.IgnoreCache",
+ * <BR>"javax.jdo.option.NontransactionalRead",
+ * <BR>"javax.jdo.option.NontransactionalWrite",
+ * <BR>"javax.jdo.option.Multithreaded",
+ * <BR>"javax.jdo.option.ConnectionUserName",
+ * <BR>"javax.jdo.option.ConnectionPassword",
+ * <BR>"javax.jdo.option.ConnectionURL",
+ * <BR>"javax.jdo.option.ConnectionFactoryName",
+ * <BR>"javax.jdo.option.ConnectionFactory2Name".
+ * </code><P>JDO implementations
+ * are permitted to define key values of their own. Any key values not
+ * recognized by the implementation must be ignored. Key values that are
+ * recognized but not supported by an implementation must result in a
+ * <code>JDOFatalUserException</code> thrown by the method.
+ * <P>The returned <code>PersistenceManagerFactory</code> is not
configurable (the
+ * <code>set<I>XXX</I></code> methods will throw an exception).
+ * <P>JDO implementations might manage a map of instantiated
+ * <code>PersistenceManagerFactory</code> instances based on specified
property key
+ * values, and return a previously instantiated
<code>PersistenceManagerFactory</code>
+ * instance. In this case, the properties of the returned
+ * instance must exactly match the requested properties.
+ * @return the <code>PersistenceManagerFactory</code>.
+ * @param props a <code>Properties</code> instance with properties of the
<code>PersistenceManagerFactory</code>.
+ * @param cl a class loader to use to load the
<code>PersistenceManagerFactory</code> class.
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (Properties props, ClassLoader cl) {
+ String pmfClassName = (String) props.get
("javax.jdo.PersistenceManagerFactoryClass"); //NOI18N
+ if (pmfClassName == null) {
+ throw new JDOFatalUserException
(msg.msg("EXC_NoClassNameProperty")); // NOI18N
+ }
+ try {
+ Class pmfClass = cl.loadClass (pmfClassName);
+ Method pmfMethod = pmfClass.getMethod
("getPersistenceManagerFactory", //NOI18N
+ new Class[] {Properties.class});
+ return (PersistenceManagerFactory) pmfMethod.invoke (null, new
Object[] {props});
+ } catch (ClassNotFoundException cnfe) {
+ throw new JDOFatalUserException (msg.msg("EXC_ClassNotFound",
pmfClassName), cnfe); //NOI18N
+ } catch (IllegalAccessException iae) {
+ throw new JDOFatalUserException (msg.msg("EXC_IllegalAccess",
pmfClassName), iae); //NOI18N
+ } catch (NoSuchMethodException nsme) {
+ throw new JDOFatalInternalException (msg.msg("ERR_NoSuchMethod"),
nsme); //NOI18N
+ } catch (InvocationTargetException ite) {
+ Throwable nested = ite.getTargetException();
+ if (nested instanceof JDOException) {
+ throw (JDOException)nested;
+ } else throw new JDOFatalUserException
(msg.msg("EXC_getPersistenceManagerFactory"), ite); //NOI18N
+ } catch (Exception e) {
+ throw new JDOFatalInternalException
(msg.msg("ERR_UnexpectedException"), e); //NOI18N
+ }
+ }
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory} configured based
+ * on the properties stored in the resource at
+ * <code>propsResource</code>. This method is equivalent to
+ * invoking [EMAIL PROTECTED]
+ * #getPersistenceManagerFactory(String,ClassLoader)} with
+ * <code>Thread.currentThread().getContextClassLoader()</code> as
+ * the <code>loader</code> argument.
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (String propsResource) {
+ return getPersistenceManagerFactory (propsResource,
+ Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory} configured based
+ * on the properties stored in the resource at
+ * <code>propsResource</code>. Loads the resource via
+ * <code>loader</code>, and creates a [EMAIL PROTECTED]
+ * PersistenceManagerFactory} with <code>loader</code>. Any
+ * <code>IOException</code>s thrown during resource loading will
+ * be wrapped in a [EMAIL PROTECTED] JDOFatalUserException}.
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (String propsResource, ClassLoader loader) {
+
+ if (propsResource == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullResource"));
+ if (loader == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullLoader"));
+
+ Properties props = new Properties ();
+ InputStream in = null;
+ try {
+ in = loader.getResourceAsStream (propsResource);
+ if (in == null)
+ throw new JDOFatalUserException
+ (msg.msg ("EXC_NoResource", propsResource, loader));
+ props.load (in);
+ } catch (IOException ioe) {
+ throw new JDOFatalUserException
+ (msg.msg ("EXC_IOExceptionRsrc", propsResource), ioe);
+ }
+ finally {
+ if (in != null)
+ try {
+ in.close ();
+ } catch (IOException ioe) { }
+ }
+
+ return getPersistenceManagerFactory (props, loader);
+ }
+
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory}
configured based
+ * on the properties stored in the file at
+ * <code>propsResource</code>. This method is equivalent to
+ * invoking [EMAIL PROTECTED]
+ * #getPersistenceManagerFactory(File,ClassLoader)} with
+ * <code>Thread.currentThread().getContextClassLoader()</code> as
+ * the <code>loader</code> argument.
+ *
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (File propsFile) {
+ return getPersistenceManagerFactory (propsFile,
+ Thread.currentThread().getContextClassLoader());
+ }
+
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory}
configured based
+ * on the properties stored in the file at
+ * <code>propsResource</code>. Creates a [EMAIL PROTECTED]
+ * PersistenceManagerFactory} with <code>loader</code>. Any
+ * <code>IOException</code>s or
+ * <code>FileNotFouldException</code>s thrown during resource
+ * loading will be wrapped in a [EMAIL PROTECTED]
JDOFatalUserException}.
+ *
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (File propsFile, ClassLoader loader) {
+ if (propsFile == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullFile"));
+ if (loader == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullLoader"));
+ Properties props = new Properties ();
+ InputStream in = null;
+ try {
+ in = new FileInputStream (propsFile);
+ props.load (in);
+ } catch (FileNotFoundException fnfe) {
+ throw new JDOFatalUserException
+ (msg.msg ("EXC_NoFile", propsFile, loader), fnfe);
+ } catch (IOException ioe) {
+ throw new JDOFatalUserException
+ (msg.msg ("EXC_IOExceptionFile", propsFile), ioe);
+ } finally {
+ if (in != null)
+ try {
+ in.close ();
+ } catch (IOException ioe) { }
+ }
+ return getPersistenceManagerFactory (props, loader);
+ }
+
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory} at the
JNDI
+ * location specified by <code>jndiLocation</code> in the context
+ * <code>context</code>. If <code>context</code> is
+ * <code>null</code>, <code>new InitialContext()</code> will be
+ * used. This method is equivalent to invoking [EMAIL PROTECTED]
+ * #getPersistenceManagerFactory(String,Context,ClassLoader)}
+ * with
+ * <code>Thread.currentThread().getContextClassLoader()</code> as
+ * the <code>loader</code> argument.
+ *
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (String jndiLocation, Context context) {
+ return getPersistenceManagerFactory (jndiLocation, context,
+ Thread.currentThread ().getContextClassLoader ());
+ }
+
+
+ /**
+ * Returns a [EMAIL PROTECTED] PersistenceManagerFactory} at the
JNDI
+ * location specified by <code>jndiLocation</code> in the context
+ * <code>context</code>. If <code>context</code> is
+ * <code>null</code>, <code>new InitialContext()</code> will be
+ * used. Creates a [EMAIL PROTECTED] PersistenceManagerFactory}
with
+ * <code>loader</code>. Any <code>NamingException</code>s thrown
+ * will be wrapped in a [EMAIL PROTECTED] JDOFatalUserException}.
+ *
+ * @since 2.0
+ */
+ public static PersistenceManagerFactory getPersistenceManagerFactory
+ (String jndiLocation, Context context, ClassLoader loader) {
+ if (jndiLocation == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullJndiLoc"));
+ if (loader == null)
+ throw new JDOFatalUserException (msg.msg ("EXC_NullLoader"));
+ try {
+ if (context == null)
+ context = new InitialContext ();
+
+ Object o = context.lookup (jndiLocation);
+ return (PersistenceManagerFactory) PortableRemoteObject.narrow
+ (o, PersistenceManagerFactory.class);
+ } catch (NamingException ne) {
+ throw new JDOFatalUserException
+ (msg.msg ("EXC_NamingException", jndiLocation, loader), ne);
+ }
+ }
+}
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOObjectNotFoundException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOObjectNotFoundException.java?view=auto&rev=159273
==============================================================================
---
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOObjectNotFoundException.java
(added)
+++
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOObjectNotFoundException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOObjectNotFoundException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents exceptions caused by the user accessing
+ * an object that does not exist in the datastore.
+ *
+ * @since 1.0.1
+ * @version 1.0.1
+ */
+public class JDOObjectNotFoundException extends JDODataStoreException {
+
+ /**
+ * Constructs a new <code>JDOObjectNotFoundException</code>
+ * without a detail message.
+ */
+ public JDOObjectNotFoundException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOObjectNotFoundException</code>
+ * with the specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOObjectNotFoundException(String msg) {
+ super(msg);
+ }
+
+ /** Constructs a new <code>JDOObjectNotFoundException</code> with the
specified detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOObjectNotFoundException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /**
+ * Constructs a new <code>JDOObjectNotFoundException</code> with the
+ * specified detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOObjectNotFoundException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+}
+
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOOptimisticVerificationException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOOptimisticVerificationException.java?view=auto&rev=159273
==============================================================================
---
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOOptimisticVerificationException.java
(added)
+++
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOOptimisticVerificationException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOOptimisticVerificationException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents optimistic verification failures. The nested
+ * exception array contains an exception for each instance that failed
+ * the optimistic verification.
+ *
+ * @since 1.0.1
+ * @version 1.0.1
+ */
+public class JDOOptimisticVerificationException extends
JDOFatalDataStoreException {
+
+ /**
+ * Constructs a new <code>JDOOptimisticVerificationException</code> without
a detail message.
+ */
+ public JDOOptimisticVerificationException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOOptimisticVerificationException</code> with the
specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOOptimisticVerificationException(String msg) {
+ super(msg);
+ }
+
+ /** Constructs a new <code>JDOOptimisticVerificationException</code> with
the specified detail message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOOptimisticVerificationException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /**
+ * Constructs a new <code>JDOOptimisticVerificationException</code> with the
specified
+ * detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOOptimisticVerificationException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+}
+
Added:
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUnsupportedOptionException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUnsupportedOptionException.java?view=auto&rev=159273
==============================================================================
---
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUnsupportedOptionException.java
(added)
+++
incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUnsupportedOptionException.java
Mon Mar 28 10:25:05 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOUnsupportedOptionException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents exceptions caused by the use of optional features
+ * not supported by the JDO implementation.
+ *
+ * @version 1.0
+ */
+public class JDOUnsupportedOptionException extends JDOUserException {
+
+ /**
+ * Constructs a new <code>JDOUnsupportedOptionException</code> without a
detail message.
+ */
+ public JDOUnsupportedOptionException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOUnsupportedOptionException</code> with the
specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOUnsupportedOptionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOUnsupportedOptionException</code> with the
+ * specified detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOUnsupportedOptionException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOUnsupportedOptionException</code> with the
+ * specified detail message and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOUnsupportedOptionException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+}
+
Added: incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUserException.java
URL:
http://svn.apache.org/viewcvs/incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUserException.java?view=auto&rev=159273
==============================================================================
--- incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUserException.java (added)
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/JDOUserException.java Mon Mar
28 10:25:05 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOUserException.java
+ *
+ */
+
+package javax.jdo;
+
+/** This class represents user errors that can possibly be retried.
+ *
+ * @version 1.0
+ */
+public class JDOUserException extends JDOCanRetryException {
+
+ /**
+ * Constructs a new <code>JDOUserException</code> without a detail message.
+ */
+ public JDOUserException() {
+ }
+
+
+ /**
+ * Constructs a new <code>JDOUserException</code> with the specified detail
message.
+ * @param msg the detail message.
+ */
+ public JDOUserException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOUserException</code> with the specified detail
message
+ * and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ */
+ public JDOUserException(String msg, Throwable[] nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Constructs a new <code>JDOUserException</code> with the specified detail
message
+ * and nested <code>Throwable</code>s.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ */
+ public JDOUserException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /** Constructs a new <code>JDOUserException</code> with the specified detail
message
+ * and failed object.
+ * @param msg the detail message.
+ * @param failed the failed object.
+ */
+ public JDOUserException(String msg, Object failed) {
+ super(msg, failed);
+ }
+
+ /** Constructs a new <code>JDOUserException</code> with the specified detail
message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable[]</code>.
+ * @param failed the failed object.
+ */
+ public JDOUserException(String msg, Throwable[] nested, Object failed) {
+ super(msg, nested, failed);
+ }
+
+ /** Constructs a new <code>JDOUserException</code> with the specified detail
message,
+ * nested <code>Throwable</code>s, and failed object.
+ * @param msg the detail message.
+ * @param nested the nested <code>Throwable</code>.
+ * @param failed the failed object.
+ */
+ public JDOUserException(String msg, Throwable nested, Object failed) {
+ super(msg, nested, failed);
+ }
+}
+