[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/marshal/serializable ...
Ron Sigal
ron_sigal at yahoo.com
Mon Jan 29 00:12:44 EST 2007
User: rsigal
Date: 07/01/29 00:12:44
Modified: src/main/org/jboss/remoting/marshal/serializable Tag:
remoting_2_x SerializableMarshaller.java
Log:
JBREM-692: Changed to implement interface PreferredStreamMarshaller.
Revision Changes Path
No revision
No revision
1.11.10.1 +28 -13 JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableMarshaller.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SerializableMarshaller.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/marshal/serializable/SerializableMarshaller.java,v
retrieving revision 1.11
retrieving revision 1.11.10.1
diff -u -b -r1.11 -r1.11.10.1
--- SerializableMarshaller.java 30 Dec 2005 05:26:30 -0000 1.11
+++ SerializableMarshaller.java 29 Jan 2007 05:12:44 -0000 1.11.10.1
@@ -22,11 +22,16 @@
package org.jboss.remoting.marshal.serializable;
+import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
+import java.util.Map;
+
import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.PreferredStreamMarshaller;
import org.jboss.remoting.marshal.SerialMarshaller;
+import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.serialization.SerializationStreamFactory;
/**
@@ -35,7 +40,7 @@
*
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
*/
-public class SerializableMarshaller implements SerialMarshaller
+public class SerializableMarshaller implements PreferredStreamMarshaller
{
static final long serialVersionUID = -5553685435323600244L;
@@ -61,6 +66,27 @@
}
}
+ public OutputStream getMarshallingStream(OutputStream outputStream) throws IOException
+ {
+ return getMarshallingStream(outputStream, null);
+ }
+
+ public OutputStream getMarshallingStream(OutputStream outputStream, Map config) throws IOException
+ {
+ if(outputStream instanceof ObjectOutputStream)
+ {
+ return outputStream;
+ }
+ else
+ {
+ BufferedOutputStream bos = new BufferedOutputStream(outputStream);
+ SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType());
+ ObjectOutputStream oos = manager.createOutput(bos);
+ oos.flush();
+ return oos;
+ }
+ }
+
/**
* Take the data object and write to the output. Has ben customized
* for working with ObjectOutputStreams since requires extra messaging.
@@ -71,19 +97,8 @@
*/
public void write(Object dataObject, OutputStream output) throws IOException
{
- ObjectOutputStream oos = null;
- if(output instanceof ObjectOutputStream)
- {
- oos = (ObjectOutputStream) output;
- }
- else
- {
- oos = SerializationStreamFactory.getManagerInstance(getSerializationType()).createOutput(output);
- }
-
+ ObjectOutputStream oos = (ObjectOutputStream) getMarshallingStream(output, null);
SerializationStreamFactory.getManagerInstance(getSerializationType()).sendObject(oos, dataObject);
-
-
}
public Marshaller cloneMarshaller()
More information about the jboss-cvs-commits
mailing list