1 /* 2 * $Id: TcpProtocol.java 7963 2007-08-21 08:53:15Z dirk.olmes $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 11 package org.mule.providers.tcp; 12 13 import java.io.IOException; 14 import java.io.InputStream; 15 import java.io.OutputStream; 16 17 /** 18 * The TcpProtocol interface enables to plug different application level protocols on 19 * a TcpConnector. Note that this interface has lost the direct byte array write method. 20 * Standard callers should (and will, since it matches the same signature, which is why 21 * the method has not been deprecated) use the generic method instead. For more complex use, 22 * the method remains as an implementation detail in 23 * {@link org.mule.providers.tcp.protocols.ByteProtocol#writeByteArray(java.io.OutputStream, byte[])}. 24 */ 25 public interface TcpProtocol 26 { 27 28 /** 29 * Reads the input stream and returns a whole message. 30 * 31 * @param is the input stream 32 * @return an array of byte containing a full message 33 * @throws IOException if an exception occurs 34 */ 35 Object read(InputStream is) throws IOException; 36 37 /** 38 * Write the specified message to the output stream. 39 * 40 * @param os the output stream to write to 41 * @param data the data to write 42 * @throws IOException if an exception occurs 43 */ 44 void write(OutputStream os, Object data) throws IOException; 45 46 }