User: starksm
Date: 05/04/10 14:29:29
Modified: src/main/javax/resource/spi Tag: Branch_4_0
ConnectionEvent.java
Log:
Use the SerialVersion constants to choose between the 4.0.2 serialVersionUID value compatible with the 1.4.1 RI or the legacy value of 4.0.1.
Revision Changes Path
No revision
No revision
1.6.6.2 +74 -2 jboss-j2ee/src/main/javax/resource/spi/ConnectionEvent.java
Index: ConnectionEvent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-j2ee/src/main/javax/resource/spi/ConnectionEvent.java,v
retrieving revision 1.6.6.1
retrieving revision 1.6.6.2
diff -u -r1.6.6.1 -r1.6.6.2
--- ConnectionEvent.java 3 Apr 2005 05:02:45 -0000 1.6.6.1
+++ ConnectionEvent.java 10 Apr 2005 21:29:29 -0000 1.6.6.2
@@ -6,8 +6,14 @@
package javax.resource.spi;
import java.io.Serializable;
+import java.io.ObjectStreamField;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.util.EventObject;
+import org.jboss.util.id.SerialVersion;
+
/**
* The ConnectionEvent class provides information about the source of a
* Connection related event. A ConnectionEvent contains:
@@ -28,12 +34,50 @@
* <li>Local transaction rolled back</li>
* <li>Connection error occurred</li>
* </ul>
- * @version $Revision: 1.6.6.1 $
+ * @version $Revision: 1.6.6.2 $
*/
public class ConnectionEvent extends EventObject
{
/** @since 4.0.2 */
- static final long serialVersionUID = 547071213627824490L;
+ static final long serialVersionUID;
+
+ // Constants -----------------------------------------------------
+ /**
+ * These field names match the j2ee 1.4.1 ri version names
+ */
+ private static final ObjectStreamField[] serialPersistentFields;
+ private static final int ID_IDX = 0;
+ private static final int EXCEPTION_IDX = 1;
+ private static final int CONN_HANDLE_IDX = 2;
+
+ static
+ {
+ if (SerialVersion.version == SerialVersion.LEGACY)
+ {
+ serialVersionUID = 2776168349823367611L;
+ serialPersistentFields = new ObjectStreamField[] {
+ /** @serialField id int */
+ new ObjectStreamField("id", int.class),
+ /** @serialField e Exception */
+ new ObjectStreamField("e", Exception.class),
+ /** @serialField connectionHandle Object */
+ new ObjectStreamField("connectionHandle", Object.class)
+ };
+ }
+ else
+ {
+ // j2ee 1.4.1 RI values
+ serialVersionUID = 5611772461379563249L;
+ serialPersistentFields = new ObjectStreamField[] {
+ /** @serialField id int */
+ new ObjectStreamField("id", int.class),
+ /** @serialField exception Exception */
+ new ObjectStreamField("exception", Exception.class),
+ /** @serialField connectionHandle Object */
+ new ObjectStreamField("connectionHandle", Object.class)
+ };
+ }
+ }
/**
* Connection has been closed
@@ -133,4 +177,32 @@
{
return connectionHandle;
}
+
+ // Private -------------------------------------------------------
+ private void readObject(ObjectInputStream ois)
+ throws ClassNotFoundException, IOException
+ {
+ ObjectInputStream.GetField fields = ois.readFields();
+ String name = serialPersistentFields[ID_IDX].getName();
+ this.id = fields.get(name, CONNECTION_ERROR_OCCURRED);
+ name = serialPersistentFields[EXCEPTION_IDX].getName();
+ this.e = (Exception) fields.get(name, null);
+ name = serialPersistentFields[CONN_HANDLE_IDX].getName();
+ this.connectionHandle = fields.get(name, null);
+ }
+
+ private void writeObject(ObjectOutputStream oos)
+ throws IOException
+ {
+ // Write j2ee 1.4.1 RI field names
+ ObjectOutputStream.PutField fields = oos.putFields();
+ String name = serialPersistentFields[ID_IDX].getName();
+ fields.put(name, id);
+ name = serialPersistentFields[EXCEPTION_IDX].getName();
+ fields.put(name, e);
+ name = serialPersistentFields[CONN_HANDLE_IDX].getName();
+ fields.put(name, connectionHandle);
+ oos.writeFields();
+ }
+
}
\ No newline at end of file
|