Return-Path: Delivered-To: apmail-incubator-qpid-commits-archive@locus.apache.org Received: (qmail 85493 invoked from network); 5 Aug 2008 19:34:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Aug 2008 19:34:05 -0000 Received: (qmail 55359 invoked by uid 500); 5 Aug 2008 19:34:04 -0000 Delivered-To: apmail-incubator-qpid-commits-archive@incubator.apache.org Received: (qmail 55346 invoked by uid 500); 5 Aug 2008 19:34:04 -0000 Mailing-List: contact qpid-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: qpid-dev@incubator.apache.org Delivered-To: mailing list qpid-commits@incubator.apache.org Received: (qmail 55337 invoked by uid 99); 5 Aug 2008 19:34:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2008 12:34:04 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2008 19:33:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 91EF82388A06; Tue, 5 Aug 2008 12:33:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r682887 [2/2] - in /incubator/qpid/trunk/qpid/java: client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/ client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/ client/example/src/main/java/org/apache/qp... Date: Tue, 05 Aug 2008 19:33:12 -0000 To: qpid-commits@incubator.apache.org From: rhs@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080805193314.91EF82388A06@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java?rev=682887&view=auto ============================================================================== --- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java (added) +++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java Tue Aug 5 12:33:11 2008 @@ -0,0 +1,82 @@ +/* + * + * 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.qpid.util; + +import java.io.UnsupportedEncodingException; + + +/** + * Strings + * + */ + +public final class Strings +{ + + private static final byte[] EMPTY = new byte[0]; + + private static final ThreadLocal charbuf = new ThreadLocal() + { + public char[] initialValue() + { + return new char[4096]; + } + }; + + public static final byte[] toUTF8(String str) + { + if (str == null) + { + return EMPTY; + } + else + { + final int size = str.length(); + char[] chars = charbuf.get(); + if (size > chars.length) + { + chars = new char[Math.max(size, 2*chars.length)]; + charbuf.set(chars); + } + + str.getChars(0, size, chars, 0); + final byte[] bytes = new byte[size]; + for (int i = 0; i < size; i++) + { + if (chars[i] > 127) + { + try + { + return str.getBytes("UTF-8"); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e); + } + } + + bytes[i] = (byte) chars[i]; + } + return bytes; + } + } + +} Propchange: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/Strings.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/qpid/trunk/qpid/java/tools/bin/qpid-bench URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/tools/bin/qpid-bench?rev=682887&r1=682886&r2=682887&view=diff ============================================================================== --- incubator/qpid/trunk/qpid/java/tools/bin/qpid-bench (original) +++ incubator/qpid/trunk/qpid/java/tools/bin/qpid-bench Tue Aug 5 12:33:11 2008 @@ -30,7 +30,6 @@ export JAVA=java \ JAVA_VM=-server \ JAVA_MEM=-Xmx1024m \ - JAVA_GC="-XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError" \ QPID_CLASSPATH=$QPID_LIBS . qpid-run org.apache.qpid.tools.QpidBench "$@" Modified: incubator/qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java?rev=682887&r1=682886&r2=682887&view=diff ============================================================================== --- incubator/qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java (original) +++ incubator/qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/QpidBench.java Tue Aug 5 12:33:11 2008 @@ -524,7 +524,7 @@ StringBuilder str = new StringBuilder(); for (int i = 0; i < opts.size; i++) { - str.append((char) i); + str.append((char) (i % 128)); } String body = str.toString(); @@ -782,10 +782,8 @@ dp.setTimestamp(System.currentTimeMillis()); } - ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED); - ssn.header(dp, mp); - ssn.data(body.slice()); - ssn.endData(); + ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED, + new Header(dp, mp), body.slice()); count++; } @@ -827,10 +825,9 @@ { ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, - MessageAcquireMode.PRE_ACQUIRED); - ssn.header(dp, mp); - ssn.data(echo); - ssn.endData(); + MessageAcquireMode.PRE_ACQUIRED, + new Header(dp, mp), + echo); } if (sample)