1 /**
2 This file is part of GoldenGate Project (named also GoldenGate or GG).
3
4 Copyright 2009, Frederic Bregier, and individual contributors by the @author
5 tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 individual contributors.
7
8 All GoldenGate Project is free software: you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as published
10 by the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 GoldenGate is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GoldenGate . If not, see <http://www.gnu.org/licenses/>.
20 */
21 package openr66.client;
22
23 import openr66.protocol.exception.OpenR66ProtocolBusinessException;
24
25 import org.jboss.netty.buffer.ChannelBuffer;
26
27 /**
28 * Class to be implemented for {@link RecvThroughClient}
29 *
30 * @author Frederic Bregier
31 *
32 */
33 public abstract class RecvThroughHandler {
34 /**
35 * This method will be called for each valid packet received to be written
36 * @param buffer
37 * @exception OpenR66ProtocolBusinessException This exception has to be throw if any error
38 * occurs during write in business process.
39 */
40 abstract public void writeChannelBuffer(ChannelBuffer buffer)
41 throws OpenR66ProtocolBusinessException;
42
43 /**
44 * Facility function to read from buffer and transfer to an array of bytes
45 * @param buffer
46 * @return the array of bytes
47 */
48 protected byte[] getByte(ChannelBuffer buffer) {
49 byte [] dst = new byte[buffer.readableBytes()];
50 buffer.readBytes(dst, 0, dst.length);
51 return dst;
52 }
53 }