ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Ws Wiki] Update of "FrontPage/Axis2/MessageContextSaveRestore" by AnnRobinson
Date Tue, 31 Oct 2006 21:10:17 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by AnnRobinson:

  Refer to  []
- In particular, this feature can be used by a WS-ReliableMessaging       
+ In particular, this feature can be used by a WS Reliable Messaging       
  implementation to persist and re-send messages and to recover from a    
  server restart. The idea being to save a message context, then later    
  restore the message context and pick up the message processing at the   
  point at which the message context was saved (that is, without having to
  completely restart the message from the beginning).                     
- Another consideration is with WS-Security handlers, which may have   
+ Another consideration is with WS Security handlers, which may have   
  message-specifc security data, like certificates or tokens, that need
  customized processing when a message context is saved and restored.  
@@ -72, +72 @@

  === Sample code to save a Message Context ===
    // attach a stream capable of writing objects to the output stream
-   ObjectOutputStream outObjStream = new ObjectOutputStream(outStream);
+    ObjectOutputStream outObjStream = new ObjectOutputStream(outStream);
    // save the message context
-   outObjStream.writeObject(msgContext);                               
+    outObjStream.writeObject(msgContext);                               
  === Sample code to restore a Message Context ===
    // attach a stream capable of reading objects from the input stream
-   ObjectInputStream inObjStream = new ObjectInputStream(inStream);       
+    ObjectInputStream inObjStream = new ObjectInputStream(inStream);       
    // restore the message context
-   MessageContext msgContext2 = (MessageContext) inObjStream.readObject();
+    MessageContext msgContext2 = (MessageContext) inObjStream.readObject();
-   // if you don't go through the AxisEngine then you need to activate
+   // if you don't go through the axis engine then you need to 
-   // the restored message context before using it
+    // activate the restored message context before using it
-   msgContext2.activate(configurationContext);                            
+     msgContext2.activate(configurationContext);                            
  == Limitations/Restrictions on the Message Context Serialization Support ==
   * The message context serialization has the limitation that the server, on
@@ -132, +132 @@

  customizing the default mechanism, and using a customized protocol        
+ An object that implements the interface uses the     
+ default protocol in Java to control the serialization.  All instance      
+ variables or fields of the object must be Serializable.  If a field in a  
+ class is marked as transient, the field will be skipped when Java         
+ serializes the object.  The only things that are saved from the object are
+ the non-static and non-transient instance data.  Class definitions are not
+ saved and must be available when the object is de-serialized.             
+ An object that implements the interface can customize
+ the default serialization mechanism by providing two private methods for  
+ reading and writing the object.                                           
+  private void writeObject ( ObjectOutputStream out ) throws IOException 
+  -  use out.defaultWriteObject() for default serialization              
+  private void readObject ( ObjectInputStream in ) throws IOException,   
+  ClassNotFoundException                                                 
+  -  use in.defaultReadObject() for default de-serialization             
+ The object can also explicitly declare the specific variables or fields to 
+ be saved by defining the variable                                          
+  private final static array ObjectStreamField[] serialPersistentFields = {}
+ An object uses the interface when the object needs
+ to control its serialization and re-constitution process.  This interface
+ allows the object to encode the serialized data, to select which         
+ fields are serialized, and to put any additional information to the      
+ serialization stream.                                                    
+ An Externalizable object must implement two methods:                 
+   - public void writeExternal ( ObjectOutput out ) throws IOException
+   - public void readExternal ( ObjectInput in ) throws IOException,  
+     ClassNotFoundException                                           
+ and have a public constructor that takes no arguments.               
+ In the writeExternal() method, the object must manually write each piece
+ of data to be saved to the ObjectOutput.  Note that the implementation  
+ must also account for all superclass information.                       
+ If a class definition changes, then the serialization of the class is     
+ affected.  Versioning of the class is important to identify class         
+ definitions.  For example, if an older version of a class is deserialized 
+ into a newer version of the class, it is important to determine what state
+ will that leave the object in.  The serialization mechanism uses an       
+ identification value to keep track.  The identifier is called the         
+ serialVersionUID (SUID) and is computed from the structure of the class to
+ form a unique 64-bit identifier.  The following example shows how to      
+ declare the SUID that the object is compatible with:                      
+    private static final long serialVersionUID = 7110175216435025451L; 
+ Refer to the "serialver" utility to compute an SUID for a class. 
+ Data that is serialized is in FIFO order; de-serialization sees the same
+ FIFO order.                                                             
+ An object that needs to be serialized but does not implement the     
+ Serializable or Externalizable interfaces will result in an exception
+ === Considerations for Using or Implementing Serialization ===

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message