|
From: <hib...@li...> - 2006-06-06 03:51:20
|
Author: ste...@jb...
Date: 2006-06-05 23:50:59 -0400 (Mon, 05 Jun 2006)
New Revision: 9987
Modified:
trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
Log:
HHH-1816 : session deserialization - named session factory
Modified: trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-06-05 21:42:05 UTC (rev 9986)
+++ trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-06-06 03:50:59 UTC (rev 9987)
@@ -1028,9 +1028,6 @@
* @throws IOException
*/
void serialize(ObjectOutputStream oos) throws IOException {
- // we are only really concerned with the capability to deserialize
- // this reference within the same JVM, so simply writing out the
- // uuid is enough
oos.writeUTF( uuid );
oos.writeBoolean( name != null );
if ( name != null ) {
@@ -1047,14 +1044,19 @@
static SessionFactoryImpl deserialize(ObjectInputStream ois) throws IOException, ClassNotFoundException {
String uuid = ois.readUTF();
boolean isNamed = ois.readBoolean();
+ String name = null;
if ( isNamed ) {
- // todo : potentially use name for lookups on deserialization;
- // needed for clustered failover of a session (i.e. stateful session bean)
- String name = ois.readUTF();
+ name = ois.readUTF();
}
Object result = SessionFactoryObjectFactory.getInstance( uuid );
if ( result == null ) {
- throw new InvalidObjectException( "could not locate session factory by uuid [" + uuid + "] during session deserialization" );
+ log.trace( "could not locate session factory by uuid [" + uuid + "] during session deserialization; trying name" );
+ if ( isNamed ) {
+ result = SessionFactoryObjectFactory.getNamedInstance( name );
+ }
+ if ( result == null ) {
+ throw new InvalidObjectException( "could not resolve session factory during session deserialization [uuid=" + uuid + ", name=" + name + "]" );
+ }
}
return ( SessionFactoryImpl ) result;
}
|