01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.codec;
22
23 import org.apache.mina.common.IoSession;
24 import org.apache.mina.filter.codec.ProtocolEncoder;
25 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
26
27 import org.apache.qpid.framing.AMQDataBlockEncoder;
28
29 /**
30 * AMQEncoder delegates encoding of AMQP to a data encoder.
31 *
32 * <p/><table id="crc"><caption>CRC Card</caption>
33 * <tr><th> Responsibilities <th> Collaborations
34 * <tr><td> Delegate AMQP encoding. <td> {@link AMQDataBlockEncoder}
35 * </table>
36 *
37 * @todo This class just delegates to another, so seems to be pointless. Unless it is going to handle some
38 * responsibilities in the future, then drop it.
39 */
40 public class AMQEncoder implements ProtocolEncoder
41 {
42 /** The data encoder that is delegated to. */
43 private AMQDataBlockEncoder _dataBlockEncoder = new AMQDataBlockEncoder();
44
45 /**
46 * Encodes AMQP.
47 *
48 * @param session The Mina session.
49 * @param message The data object to encode.
50 * @param out The Mina writer to output the raw byte data to.
51 *
52 * @throws Exception If the data cannot be encoded for any reason.
53 */
54 public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception
55 {
56 _dataBlockEncoder.encode(session, message, out);
57 }
58
59 /**
60 * Does nothing. Called by Mina to allow this to clean up resources when it is no longer needed.
61 *
62 * @param session The Mina session.
63 */
64 public void dispose(IoSession session)
65 { }
66 }
|