Supporting Serialization

When you build web services that will support conversations, variables whose data is required throughout the lifetime of the conversation must be declared as types that support serialization. Serialization is a technology through which object data may be written as a stream of bytes to disk.

During a conversation, WebLogic Server uses serialization to write your service's state-related data to disk. This occurs after each completed execution of:

- A method marked with a @jws:operation tag and marked with a @jws:conversation phase attribute of start or continue.

- A control callback handler.

Note that serialization will not occur for these if the method, callback, or callback handler throws an exception while executing.

You may find that in most cases the serialization prerequisite is easy to meet. For Java primitive types, serialization is supported by default. These types include byte, boolean, char, short, int, long, double, and float. Also, while classes in Java must implement the Serializable interface, many of the Java classes representing common data types already implement do so. These include those that are wrappers around the primitive types — such as Boolean, Long, Double, Integer, and so on — as well as String and StringBuffer. (When you are in doubt about whether a particular common class implements Serializable, check reference information for the class before using it.)

When you create your own classes for use in typing member variables, or when you handle classes created by others, you must take care to ensure that these classes implement the Serializable interface. Even so, this is typically easy to do because the interface contains no methods to implement — implementing the interface merely marks the class as supporting serialization. Your class code must simply import the package containing the interface and its declaration must be marked with the implements keyword, as follows:

    import java.io.Serializable;
    public class MyClass implements Serializable
    {...}

For more information on supporting serialization, see the serialization information at the Sun Microsystems web site at java.sun.com/j2se/1.3/docs/guide/serialization or your favorite Java book.

Related Topics

Overview: Conversations

How Do I: Add Support for Conversations?