我想通过TCP发送对象感谢客户端服务器应用程序中的序列化。 TCP客户端写在android系统上,我使用ObjectOutputStream发送一个对象。 TCP服务器是用Spring集成编写的,我尝试使用解串器来读取这个对象。事情是这样的:InputStream对象转换 - 弹簧集成
<int-ip:tcp-connection-factory id="hosServer"
serializer="connectionSerializeDeserialize"
deserializer="connectionSerializeDeserialize" ..... >
在它实现了我createing从InputSream ObjectInputStream中这是在解串器方法的参数串行器和解串接口类。它的工作正常,我尝试再连接一次到服务器。然后,我在通过readObject()方法读取对象形式ObjectInputStream期间收到EOFException。
public class CommandConverter implements Serializer<Command>, Deserializer<Command>{
private ObjectInputStream ois = null;
private ObjectOutputStream oos = null;
private CommandBuilder commandBuilder = new CommandBuilder();
public Command deserialize(InputStream inputStream) throws IOException {
if (ois == null)
ois = new ObjectInputStream(inputStream);
Command cmd = null;
try {
cmd = (Command) ois.readObject();
} catch (ClassNotFoundException e) {
commandBuilder.setCommandBuilder(new ImproperCommandBuilder());
commandBuilder.createCommand();
cmd = commandBuilder.getCommand();
} catch (InvalidClassException e) {
commandBuilder.setCommandBuilder(new ImproperCommandBuilder());
commandBuilder.createCommand();
cmd = commandBuilder.getCommand();
}
return cmd;
}
春季集成中通过TCP发送对象的最佳方式是什么?