[jboss-cvs] JBoss Messaging SVN: r4067 - trunk/src/main/org/jboss/messaging/core/remoting/impl/mina.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 16 11:37:57 EDT 2008
Author: jmesnil
Date: 2008-04-16 11:37:57 -0400 (Wed, 16 Apr 2008)
New Revision: 4067
Modified:
trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MessagingCodec.java
Log:
* fixed indentation + typo
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MessagingCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MessagingCodec.java 2008-04-16 15:15:09 UTC (rev 4066)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MessagingCodec.java 2008-04-16 15:37:57 UTC (rev 4067)
@@ -25,83 +25,86 @@
* A MessagingCodec
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
+ *
*/
-public class MessagingCodec extends CumulativeProtocolDecoder implements ProtocolEncoder
+public class MessagingCodec extends CumulativeProtocolDecoder implements
+ ProtocolEncoder
{
- private static final Logger log = Logger.getLogger(MessagingCodec.class);
+ private static final Logger log = Logger.getLogger(MessagingCodec.class);
-
- private final Map<PacketType, AbstractPacketCodec<?>> codecs =
- new HashMap<PacketType, AbstractPacketCodec<?>>();
-
- // ProtocolEncoder implementation ------------------------------------------------------------
-
- public void dispose(final IoSession session) throws Exception
- {
- }
+ private final Map<PacketType, AbstractPacketCodec<?>> codecs = new HashMap<PacketType, AbstractPacketCodec<?>>();
- public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception
- {
- Packet packet = (Packet)message;
-
+ // ProtocolEncoder implementation ------------------------------------------
+
+ public void dispose(final IoSession session) throws Exception
+ {
+ }
+
+ public void encode(final IoSession session, final Object message,
+ final ProtocolEncoderOutput out) throws Exception
+ {
+ Packet packet = (Packet) message;
+
AbstractPacketCodec codec = codecs.get(packet.getType());
-
+
if (codec == null)
{
- throw new IllegalStateException("no encoder has been registered for " + packet);
+ throw new IllegalStateException("no encoder has been registered for "
+ + packet);
}
-
+
codec.encode(packet, out);
- }
-
- // CumulataveProtocolDecoder overrides --------------------------------------------------------
-
- protected boolean doDecode(final IoSession session, final IoBuffer in, final ProtocolDecoderOutput out) throws Exception
- {
- int start = in.position();
-
- if (in.remaining() <= AbstractPacketCodec.INT_LENGTH)
- {
+ }
+
+ // CumulativeProtocolDecoder overrides -------------------------------------
+
+ protected boolean doDecode(final IoSession session, final IoBuffer in,
+ final ProtocolDecoderOutput out) throws Exception
+ {
+ int start = in.position();
+
+ if (in.remaining() <= AbstractPacketCodec.INT_LENGTH)
+ {
in.position(start);
return false;
- }
-
- int length = in.getInt();
+ }
+ int length = in.getInt();
+
if (in.remaining() < length)
- {
+ {
in.position(start);
return false;
- }
-
+ }
+
int limit = in.limit();
- in.limit(in.position() + length);
- byte byteType = in.get();
- PacketType packetType = PacketType.from(byteType);
-
- try
- {
- AbstractPacketCodec codec = codecs.get(packetType);
+ in.limit(in.position() + length);
+ byte byteType = in.get();
+ PacketType packetType = PacketType.from(byteType);
- if (codec == null)
- {
- throw new IllegalStateException("no encoder has been registered for " + packetType);
- }
+ try
+ {
+ AbstractPacketCodec codec = codecs.get(packetType);
- codec.decode(new BufferWrapper(in.slice()), out);
- return true;
- } finally
- {
- in.position(in.limit());
- in.limit(limit);
- }
+ if (codec == null)
+ {
+ throw new IllegalStateException(
+ "no decoder has been registered for " + packetType);
+ }
- }
-
- // Public --------------------------------------------------------
+ codec.decode(new BufferWrapper(in.slice()), out);
+ return true;
+ } finally
+ {
+ in.position(in.limit());
+ in.limit(limit);
+ }
- public void put(PacketType type, AbstractPacketCodec codec)
+ }
+
+ // Package protected ---------------------------------------------
+
+ void put(PacketType type, AbstractPacketCodec codec)
{
codecs.put(type, codec);
}
More information about the jboss-cvs-commits
mailing list