Author: rhs
Date: Thu Oct 4 20:24:43 2007
New Revision: 582065
URL: http://svn.apache.org/viewvc?rev=582065&view=rev
Log:
replaced random printlns with strategically placed log statements, also added
useful toString() for structs
Added:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java
(with props)
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java
(with props)
Modified:
incubator/qpid/trunk/qpid/java/common/generate
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Channel.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Connection.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionEvent.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Data.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Header.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/RangeSet.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/SessionDelegate.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Struct.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractDecoder.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractEncoder.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java
Modified: incubator/qpid/trunk/qpid/java/common/generate
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/generate?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/generate (original)
+++ incubator/qpid/trunk/qpid/java/common/generate Thu Oct 4 20:24:43 2007
@@ -21,6 +21,7 @@
self.line("package %s;" % self.package)
self.line()
+ self.line("import java.util.ArrayList;")
self.line("import java.util.List;")
self.line("import java.util.Map;")
self.line("import java.util.UUID;")
@@ -270,6 +271,11 @@
out.line(" }")
out.line()
+ out.line(" private static final List<Field<?>> FIELDS = new
ArrayList<Field<?>>();")
+ out.line(" public List<Field<?>> getFields() { return FIELDS; }")
+ out.line()
+
+ out.line()
for type, name in self.fields:
out.line(" private %s %s;" % (jtype(type), name))
@@ -309,6 +315,7 @@
out.line(" delegate.%s(context, this);" % dromedary(self.name))
out.line(" }")
+ index = 0
for type, name in self.fields:
out.line()
out.line(" public %s %s() {" % (jtype(type), camel(1, "get", name)))
@@ -316,13 +323,29 @@
out.line(" }")
out.line(" public %s %s(%s value) {" %
(self.name, camel(1, "set", name), jtype(type)))
- out.line(" this.%s = value;" % name);
+ out.line(" this.%s = value;" % name)
out.line(" return this;")
out.line(" }")
out.line(" public %s %s(%s value) {" % (self.name, name, jtype(type)))
- out.line(" this.%s = value;" % name);
+ out.line(" this.%s = value;" % name)
out.line(" return this;")
out.line(" }")
+
+ out.line(' static {')
+ out.line(' FIELDS.add(new Field<%s>(%s.class, "%s", %d) {' %
+ (self.name, self.name, name, index))
+ out.line(' public Object get(Object struct) {')
+ out.line(' return check(struct).%s;' % name)
+ out.line(' }')
+ out.line(' public void read(Decoder dec, Object struct) {')
+# out.line(' check(struct).%s = dec.read%s();' % (name,
camel(0, type)))
+ out.line(' }')
+ out.line(' public void write(Encoder enc, Object struct) {')
+# out.line(' enc.write%s(check(struct).%s);' % (camel(0,
type), name))
+ out.line(' }')
+ out.line(' });')
+ out.line(' }')
+ index += 1;
out.line()
out.line(" public void read(Decoder dec, byte major, byte minor) {")
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Channel.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Channel.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Channel.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Channel.java
Thu Oct 4 20:24:43 2007
@@ -20,11 +20,14 @@
*/
package org.apache.qpidity.transport;
+import org.apache.qpidity.transport.util.Logger;
+
import java.nio.ByteBuffer;
import java.util.List;
import java.util.ArrayList;
+
import static org.apache.qpidity.transport.network.Frame.*;
import static org.apache.qpidity.transport.util.Functions.*;
@@ -39,6 +42,8 @@
implements Receiver<ProtocolEvent>, ProtocolDelegate<Void>
{
+ private static final Logger log = Logger.get(Channel.class);
+
final private Connection connection;
final private int channel;
final private MethodDelegate<Channel> delegate;
@@ -111,7 +116,7 @@
public void closed()
{
- System.out.println("channel closed: " + this);
+ log.debug("channel closed: ", this);
if (session != null)
{
session.closed();
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ChannelDelegate.java
Thu Oct 4 20:24:43 2007
@@ -37,21 +37,11 @@
Session ssn = new Session();
ssn.attach(channel);
long lifetime = open.getDetachedLifetime();
- System.out.println("Session Opened lifetime = " + lifetime);
ssn.sessionAttached(UUID.randomUUID(), lifetime);
}
- public @Override void sessionAttached(Channel channel,
- SessionAttached attached)
- {
- System.out.println("Session attached: " + attached.getSessionId() + ",
" +
- attached.getDetachedLifetime());
- }
-
public @Override void sessionClosed(Channel channel, SessionClosed closed)
{
- System.out.println("Session closed: [" + closed.getReplyCode() + "]" +
- closed.getReplyText());
channel.getSession().closed();
// XXX: should we remove the channel from the connection? It
// could have an external reference to it. Maybe we need a
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Connection.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Connection.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Connection.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Connection.java
Thu Oct 4 20:24:43 2007
@@ -20,6 +20,8 @@
*/
package org.apache.qpidity.transport;
+import org.apache.qpidity.transport.util.Logger;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -42,6 +44,8 @@
implements Receiver<ConnectionEvent>, Sender<ConnectionEvent>
{
+ private static final Logger log = Logger.get(Connection.class);
+
final private Sender<ConnectionEvent> sender;
final private ConnectionDelegate delegate;
@@ -61,12 +65,14 @@
public void received(ConnectionEvent event)
{
+ log.debug("RECV: %s", event);
Channel channel = getChannel(event.getChannel());
channel.received(event.getProtocolEvent());
}
public void send(ConnectionEvent event)
{
+ log.debug("SEND: %s", event);
sender.send(event);
}
@@ -94,7 +100,7 @@
public void closed()
{
- System.out.println("connection closed: " + this);
+ log.debug("connection closed: %s", this);
synchronized (channels)
{
for (Iterator<Channel> it = channels.values().iterator();
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
Thu Oct 4 20:24:43 2007
@@ -20,6 +20,8 @@
*/
package org.apache.qpidity.transport;
+import org.apache.qpidity.transport.util.Logger;
+
import org.apache.qpidity.SecurityHelper;
import org.apache.qpidity.QpidException;
@@ -49,6 +51,9 @@
*/
public abstract class ConnectionDelegate extends MethodDelegate<Channel>
{
+
+ private static final Logger log = Logger.get(ConnectionDelegate.class);
+
private String _username = "guest";
private String _password = "guest";;
private String _mechanism;
@@ -70,7 +75,6 @@
public void init(Channel ch, ProtocolHeader hdr)
{
- System.out.println(hdr);
// XXX: hardcoded version
if (hdr.getMajor() != 0 && hdr.getMinor() != 10)
{
@@ -80,9 +84,6 @@
}
else
{
-
- System.out.println("\n--------------------Broker Start Connection
Negotiation -----------------------\n");
-
ch.connectionStart(hdr.getMajor(), hdr.getMinor(), null, "PLAIN",
"utf8");
}
}
@@ -92,9 +93,6 @@
//-----------------------------------------------
@Override public void connectionStart(Channel context, ConnectionStart
struct)
{
- System.out.println("\n--------------------Client Start Connection
Negotiation -----------------------\n");
- System.out.println("The broker has sent connection-start");
-
String mechanism = null;
String response = null;
try
@@ -123,8 +121,6 @@
@Override public void connectionSecure(Channel context, ConnectionSecure
struct)
{
- System.out.println("The broker has sent connection-secure with
chanllenge " + struct.getChallenge());
-
try
{
String response = new
String(saslClient.evaluateChallenge(struct.getChallenge().getBytes()),_locale);
@@ -142,8 +138,6 @@
@Override public void connectionTune(Channel context, ConnectionTune
struct)
{
- System.out.println("The broker has sent connection-tune " +
struct.toString());
-
// should update the channel max given by the broker.
context.connectionTuneOk(struct.getChannelMax(), struct.getFrameMax(),
struct.getHeartbeat());
context.connectionOpen(_virtualHost, null, Option.INSIST);
@@ -153,8 +147,6 @@
@Override public void connectionOpenOk(Channel context, ConnectionOpenOk
struct)
{
String knownHosts = struct.getKnownHosts();
- System.out.println("The broker has opened the connection for use");
- System.out.println("The broker supplied the following hosts for
failover " + knownHosts);
if(_negotiationCompleteLock != null)
{
_negotiationCompleteLock.lock();
@@ -167,7 +159,6 @@
_negotiationCompleteLock.unlock();
}
}
- System.out.println("\n-------------------- Client End Connection
Negotiation -----------------------\n");
}
public void connectionRedirect(Channel context, ConnectionRedirect struct)
@@ -184,8 +175,6 @@
_locale = struct.getLocale();
_mechanism = struct.getMechanism();
- System.out.println("The client has sent connection-start-ok");
-
//try
//{
//saslServer = Sasl.createSaslServer(_mechanism, "AMQP",
"ABC",null,SecurityHelper.createCallbackHandler(_mechanism,_username,_password));
@@ -193,12 +182,10 @@
byte[] challenge = null;
if ( challenge == null)
{
- System.out.println("Authentication sucessfull");
context.connectionTune(Integer.MAX_VALUE,maxFrame, 0);
}
else
{
- System.out.println("Authentication failed");
try
{
context.connectionSecure(new String(challenge,_locale));
@@ -221,26 +208,18 @@
}*/
}
- @Override public void connectionTuneOk(Channel context, ConnectionTuneOk
struct)
- {
- System.out.println("The client has excepted the tune params");
- }
-
@Override public void connectionSecureOk(Channel context,
ConnectionSecureOk struct)
{
- System.out.println("The client has sent connection-secure-ok");
try
{
saslServer = Sasl.createSaslServer(_mechanism, "AMQP", "ABC",new
HashMap(),SecurityHelper.createCallbackHandler(_mechanism,_username,_password));
byte[] challenge =
saslServer.evaluateResponse(struct.getResponse().getBytes());
if ( challenge == null)
{
- System.out.println("Authentication sucessfull");
context.connectionTune(Integer.MAX_VALUE,maxFrame, 0);
}
else
{
- System.out.println("Authentication failed");
try
{
context.connectionSecure(new String(challenge,_locale));
@@ -267,9 +246,7 @@
@Override public void connectionOpen(Channel context, ConnectionOpen
struct)
{
String hosts = "amqp:1223243232325";
- System.out.println("The client has sent connection-open");
context.connectionOpenOk(hosts);
- System.out.println("\n-------------------- Broker End Connection
Negotiation -----------------------\n");
}
public String getPassword()
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionEvent.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionEvent.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionEvent.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionEvent.java
Thu Oct 4 20:24:43 2007
@@ -48,4 +48,9 @@
return event;
}
+ public String toString()
+ {
+ return String.format("[%d] %s", channel, event);
+ }
+
}
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Data.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Data.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Data.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Data.java
Thu Oct 4 20:24:43 2007
@@ -26,6 +26,8 @@
import java.util.Collections;
+import static org.apache.qpidity.transport.util.Functions.*;
+
/**
* Data
@@ -74,6 +76,28 @@
public <C> void delegate(C context, ProtocolDelegate<C> delegate)
{
delegate.data(context, this);
+ }
+
+ public String toString()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("Data(");
+ boolean first = true;
+ for (ByteBuffer buf : getFragments())
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ str.append(" | ");
+ }
+ str.append(str(buf, 20));
+ }
+ str.setLength(str.length() - 3);
+ str.append(")");
+ return str.toString();
}
}
Added:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java?rev=582065&view=auto
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java
(added)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java
Thu Oct 4 20:24:43 2007
@@ -0,0 +1,72 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpidity.transport;
+
+import org.apache.qpidity.transport.codec.Decoder;
+import org.apache.qpidity.transport.codec.Encoder;
+
+
+/**
+ * Field
+ *
+ */
+
+public abstract class Field<T>
+{
+
+ private final Class<T> container;
+ private final String name;
+ private final int index;
+
+ Field(Class<T> container, String name, int index)
+ {
+ this.container = container;
+ this.name = name;
+ this.index = index;
+ }
+
+ public Class<T> getContainer()
+ {
+ return container;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ protected T check(Object struct)
+ {
+ return container.cast(struct);
+ }
+
+ public abstract Object get(Object struct);
+
+ public abstract void read(Decoder dec, Object struct);
+
+ public abstract void write(Encoder enc, Object struct);
+
+}
Propchange:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Field.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Header.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Header.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Header.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Header.java
Thu Oct 4 20:24:43 2007
@@ -68,4 +68,25 @@
delegate.header(context, this);
}
+ public String toString()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("Header(");
+ boolean first = true;
+ for (Struct s : structs)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ str.append(", ");
+ }
+ str.append(s);
+ }
+ str.append(")");
+ return str.toString();
+ }
+
}
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/RangeSet.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/RangeSet.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/RangeSet.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/RangeSet.java
Thu Oct 4 20:24:43 2007
@@ -100,7 +100,23 @@
public String toString()
{
- return ranges.toString();
+ StringBuffer str = new StringBuffer();
+ str.append("{");
+ boolean first = true;
+ for (Range range : ranges)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ str.append(", ");
+ }
+ str.append(range);
+ }
+ str.append("}");
+ return str.toString();
}
public static final void main(String[] args)
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Session.java
Thu Oct 4 20:24:43 2007
@@ -20,8 +20,11 @@
*/
package org.apache.qpidity.transport;
+
import org.apache.qpidity.transport.network.Frame;
+import org.apache.qpidity.transport.util.Logger;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
@@ -38,6 +41,8 @@
public class Session extends Invoker
{
+ private static final Logger log = Logger.get(Session.class);
+
// channel may be null
Channel channel;
@@ -82,7 +87,6 @@
public void processed(Method command)
{
- System.out.printf("processed[%d]: %s\n", command.getId(),
command.getClass());
processed(command.getId());
}
@@ -99,13 +103,15 @@
public void processed(Range range)
{
+ log.debug("%s processed(%s)", this, range);
+
boolean flush;
synchronized (processed)
{
processed.add(range);
flush = syncPoint != null && processed.includes(syncPoint);
}
- if (! flush)
+ if (!flush)
{
flushProcessed();
}
@@ -118,7 +124,6 @@
RangeSet rest = new RangeSet();
for (Range r: processed)
{
- System.out.println("Completed Range [" + r.getLower() + "," +
r.getUpper() +"]" );
if (first)
{
first = false;
@@ -129,15 +134,14 @@
rest.add(r);
}
}
- System.out.println("Notifying peer with execution complete");
executionComplete(mark, rest);
}
void syncPoint()
{
- System.out.println("===========Request received to
sync==========================");
-
- Range range = new Range(0, getCommandsIn() - 1);
+ long id = getCommandsIn() - 1;
+ log.debug("%s synced to %d", this, id);
+ Range range = new Range(0, id - 1);
boolean flush;
synchronized (processed)
{
@@ -178,7 +182,7 @@
if (commands.isEmpty())
{
- System.out.println("\n All outstanding commands are completed
!!!! \n");
+ log.debug("%s no outsanding commands", this);
commands.notifyAll();
}
}
@@ -196,7 +200,6 @@
{
synchronized (commands)
{
- System.out.println("sent command " + m.getClass().getName() +
" command Id" + commandsOut);
commands.put(commandsOut++, m);
}
}
@@ -240,7 +243,7 @@
public void sync()
{
- System.out.println("calling sync()");
+ log.debug("%s sync()", this);
synchronized (commands)
{
if (!commands.isEmpty())
@@ -251,9 +254,8 @@
while (!closed && !commands.isEmpty())
{
try {
- System.out.println("\n============sync() waiting for
commmands to be completed ==============\n");
+ log.debug("%s waiting");
commands.wait();
- System.out.println("\n============sync() got
notified=========================================\n");
}
catch (InterruptedException e)
{
@@ -352,7 +354,7 @@
public void close()
{
sessionClose();
- channel.close();
+ // XXX: channel.close();
}
public void closed()
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/SessionDelegate.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/SessionDelegate.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/SessionDelegate.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/SessionDelegate.java
Thu Oct 4 20:24:43 2007
@@ -70,12 +70,10 @@
{
for (Range range : ranges)
{
- System.out.println("completed command range: " +
range.getLower() + " to " + range.getUpper());
ssn.complete(range.getLower(), range.getUpper());
}
}
ssn.complete(excmp.getCumulativeExecutionMark());
- System.out.println("outstanding commands: " +
ssn.getOutstandingCommands());
}
@Override public void executionFlush(Session ssn, ExecutionFlush flush)
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Struct.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Struct.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Struct.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/Struct.java
Thu Oct 4 20:24:43 2007
@@ -20,6 +20,8 @@
*/
package org.apache.qpidity.transport;
+import java.util.List;
+
import org.apache.qpidity.transport.codec.Encodable;
@@ -37,6 +39,34 @@
return StructFactory.create(type);
}
+ public abstract List<Field<?>> getFields();
+
public abstract int getEncodedType();
+
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append(getClass().getSimpleName());
+
+ str.append("(");
+ boolean first = true;
+ for (Field<?> f : getFields())
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ str.append(", ");
+ }
+ str.append(f.getName());
+ str.append("=");
+ str.append(f.get(this));
+ }
+ str.append(")");
+
+ return str.toString();
+ }
}
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractDecoder.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractDecoder.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractDecoder.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractDecoder.java
Thu Oct 4 20:24:43 2007
@@ -325,9 +325,7 @@
return readLonglong();
case DOUBLE:
- long bits = readLonglong();
- System.out.println("double in: " + bits);
- return Double.longBitsToDouble(bits);
+ return Double.longBitsToDouble(readLonglong());
case SIXTEEN_OCTETS:
case THIRTY_TWO_OCTETS:
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractEncoder.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractEncoder.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractEncoder.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/AbstractEncoder.java
Thu Oct 4 20:24:43 2007
@@ -496,7 +496,6 @@
case DOUBLE:
long bits = Double.doubleToLongBits(coerce(Double.class, value));
- System.out.println("double out: " + bits);
writeLonglong(bits);
break;
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java?rev=582065&r1=582064&r2=582065&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java
Thu Oct 4 20:24:43 2007
@@ -40,6 +40,8 @@
import org.apache.qpidity.transport.Receiver;
import org.apache.qpidity.transport.Sender;
+import org.apache.qpidity.transport.util.Logger;
+
import org.apache.qpidity.transport.network.Assembler;
import org.apache.qpidity.transport.network.Disassembler;
import org.apache.qpidity.transport.network.InputHandler;
@@ -55,6 +57,8 @@
public class MinaHandler implements IoHandler
{
+ private static final Logger log = Logger.get(MinaHandler.class);
+
private final ConnectionDelegate delegate;
private final InputHandler.State state;
@@ -78,7 +82,7 @@
public void exceptionCaught(IoSession ssn, Throwable e)
{
- e.printStackTrace();
+ log.error(e, "exception caught");
}
public void sessionCreated(final IoSession ssn)
@@ -88,7 +92,7 @@
public void sessionOpened(final IoSession ssn)
{
- System.out.println("opened " + ssn);
+ log.debug("opened: %s", this);
// XXX: hardcoded version + max-frame
Connection conn = new Connection
(new Disassembler(new OutputHandler(new MinaSender(ssn)),
@@ -107,7 +111,7 @@
public void sessionClosed(IoSession ssn)
{
- System.out.println("closed " + ssn);
+ log.debug("closed: %s", ssn);
Attachment attachment = (Attachment) ssn.getAttachment();
attachment.receiver.closed();
ssn.setAttachment(null);
Added:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java?rev=582065&view=auto
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java
(added)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java
Thu Oct 4 20:24:43 2007
@@ -0,0 +1,125 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpidity.transport.util;
+
+import org.slf4j.LoggerFactory;
+
+/**
+ * Logger
+ *
+ */
+
+public final class Logger
+{
+
+ public static final Logger get(Class<?> klass)
+ {
+ return new Logger(LoggerFactory.getLogger(klass));
+ }
+
+ private final org.slf4j.Logger log;
+
+ private Logger(org.slf4j.Logger log)
+ {
+ this.log = log;
+ }
+
+ public void debug(String message, Object ... args)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format(message, args));
+ }
+ }
+
+ public void debug(Throwable t, String message, Object ... args)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format(message, args), t);
+ }
+ }
+
+ public void error(String message, Object ... args)
+ {
+ if (log.isErrorEnabled())
+ {
+ log.error(String.format(message, args));
+ }
+ }
+
+ public void error(Throwable t, String message, Object ... args)
+ {
+ if (log.isErrorEnabled())
+ {
+ log.error(String.format(message, args), t);
+ }
+ }
+
+ public void warn(String message, Object ... args)
+ {
+ if (log.isWarnEnabled())
+ {
+ log.warn(String.format(message, args));
+ }
+ }
+
+ public void warn(Throwable t, String message, Object ... args)
+ {
+ if (log.isWarnEnabled())
+ {
+ log.warn(String.format(message, args), t);
+ }
+ }
+
+ public void info(String message, Object ... args)
+ {
+ if (log.isInfoEnabled())
+ {
+ log.info(String.format(message, args));
+ }
+ }
+
+ public void info(Throwable t, String message, Object ... args)
+ {
+ if (log.isInfoEnabled())
+ {
+ log.info(String.format(message, args), t);
+ }
+ }
+
+ public void trace(String message, Object ... args)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace(String.format(message, args));
+ }
+ }
+
+ public void trace(Throwable t, String message, Object ... args)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace(String.format(message, args), t);
+ }
+ }
+
+}
Propchange:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/util/Logger.java
------------------------------------------------------------------------------
svn:eol-style = native