CVS update: JGroups/src/org/jgroups/protocols STOMP.java
"Bela Ban" <[email protected]> Tue, 26 Oct 2010 12:30:15 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/10/26 12:30:14
Modified: src/org/jgroups/protocols STOMP.java
Log:
ns
Revision Changes Path
1.17 +16 -22 JGroups/src/org/jgroups/protocols/STOMP.java
Index: STOMP.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/protocols/STOMP.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- STOMP.java 26 Oct 2010 11:57:36 -0000 1.16
+++ STOMP.java 26 Oct 2010 12:30:14 -0000 1.17
@@ -28,7 +28,7 @@
* todo: add PING to test health of client connections
* <p/>
* @author Bela Ban
- * @version $Id: STOMP.java,v 1.16 2010/10/26 11:57:36 belaban Exp $
+ * @version $Id: STOMP.java,v 1.17 2010/10/26 12:30:14 belaban Exp $
* @since 2.11
*/
@MBean
@@ -202,22 +202,12 @@
public static Frame readFrame(DataInputStream in) throws IOException {
- String tmp_verb=Util.readLine(in);
- if(tmp_verb == null)
+ String verb=Util.readLine(in);
+ if(verb == null)
throw new EOFException("reading verb");
- if(tmp_verb.length() == 0)
+ if(verb.length() == 0)
return null;
-
- ClientVerb verb;
-
- try {
- verb=ClientVerb.valueOf(tmp_verb);
- }
- catch(IllegalArgumentException illegal_ex) {
- // writeResponse(ServerVerb.ERROR, "message", "verb " + tmp_verb + " unknown");
- return null;
- }
-
+
Map<String,String> headers=new HashMap<String,String>();
byte[] body=null;
@@ -426,7 +416,9 @@
protected void handleFrame(Frame frame) {
Map<String,String> headers=frame.getHeaders();
- switch(frame.getVerb()) {
+ ClientVerb verb=ClientVerb.valueOf(frame.getVerb());
+
+ switch(verb) {
case CONNECT:
writeResponse(ServerVerb.CONNECTED,
"session-id", session_id.toString(),
@@ -520,11 +512,11 @@
public static class Frame {
- final ClientVerb verb;
+ final String verb;
final Map<String,String> headers;
- final byte[] body;
+ final byte[] body;
- public Frame(ClientVerb verb, Map<String, String> headers, byte[] body) {
+ public Frame(String verb, Map<String, String> headers, byte[] body) {
this.verb=verb;
this.headers=headers;
this.body=body;
@@ -538,7 +530,7 @@
return headers;
}
- public ClientVerb getVerb() {
+ public String getVerb() {
return verb;
}
@@ -550,9 +542,11 @@
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
if(body != null && body.length > 0) {
- sb.append("body: ").append(body.length).append(" bytes");
+ sb.append("body: ");
if(body.length < 50)
- sb.append(": " + new String(body));
+ sb.append(": " + new String(body)).append(body.length).append(" bytes");
+ else
+ sb.append(body.length).append(" bytes");
}
return sb.toString();
}
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev