Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 63946 invoked from network); 3 Jun 2009 19:21:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Jun 2009 19:21:14 -0000 Received: (qmail 21297 invoked by uid 500); 3 Jun 2009 19:21:26 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 21270 invoked by uid 500); 3 Jun 2009 19:21:26 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 21261 invoked by uid 99); 3 Jun 2009 19:21:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jun 2009 19:21:26 +0000 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; Wed, 03 Jun 2009 19:21:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 572DF2388903; Wed, 3 Jun 2009 19:20:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r781514 [6/6] - in /activemq/sandbox/activemq-flow: ./ activemq-all/ activemq-bio/ activemq-bio/src/main/java/org/apache/activemq/ activemq-bio/src/main/java/org/apache/activemq/transport/tcp/ activemq-broker/ activemq-broker/src/main/java/... Date: Wed, 03 Jun 2009 19:20:33 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090603192035.572DF2388903@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/Buffer.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/Buffer.java?rev=781514&r1=781513&r2=781514&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/Buffer.java (original) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/Buffer.java Wed Jun 3 19:20:13 2009 @@ -1,208 +1,208 @@ -/** - * 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.activemq.protobuf; - -import java.util.List; - -public class Buffer implements Comparable { - - final public byte[] data; - final public int offset; - final public int length; - - public Buffer(Buffer other) { - this(other.data, other.offset, other.length); - } - - public Buffer(byte data[]) { - this(data, 0, data.length); - } - - public Buffer(byte data[], int offset, int length) { - this.data = data; - this.offset = offset; - this.length = length; - } - - @Deprecated - public Buffer(String value) { - this(UTF8Buffer.encode(value)); - } - - public final Buffer slice(int low, int high) { - int sz; - - if (high < 0) { - sz = length + high; - } else { - sz = high - low; - } - - if (sz < 0) { - sz = 0; - } - - return new Buffer(data, offset + low, sz); - } - - public final byte[] getData() { - return data; - } - - public final int getLength() { - return length; - } - - public final int getOffset() { - return offset; - } - - public Buffer compact() { - if (length != data.length) { - return new Buffer(toByteArray()); - } - return this; - } - - final public byte[] toByteArray() { - if (length != data.length) { - byte t[] = new byte[length]; - System.arraycopy(data, offset, t, 0, length); - } - return data; - } - - public byte byteAt(int i) { - return data[offset + i]; - } - - - @Override - public int hashCode() { - byte[] target = new byte[4]; - for (int i = 0; i < length; i++) { - target[i % 4] ^= data[offset + i]; - } - return target[0] << 24 | target[1] << 16 | target[2] << 8 | target[3]; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) - return true; - - if (obj == null || obj.getClass() != Buffer.class) - return false; - - return equals((Buffer) obj); - } - - final public boolean equals(Buffer obj) { - if (length != obj.length) { - return false; - } - for (int i = 0; i < length; i++) { - if (obj.data[obj.offset + i] != data[offset + i]) { - return false; - } - } - return true; - } - - final public BufferInputStream newInput() { - return new BufferInputStream(this); - } - - final public BufferOutputStream newOutput() { - return new BufferOutputStream(this); - } - - final public boolean isEmpty() { - return length == 0; - } - - final public boolean contains(byte value) { - return indexOf(value, 0) >= 0; - } - - final public int indexOf(byte value, int pos) { - for (int i = pos; i < length; i++) { - if (data[offset + i] == value) { - return i; - } - } - return -1; - } - - final public static Buffer join(List items, Buffer seperator) { - if (items.isEmpty()) - return new Buffer(seperator.data, 0, 0); - - int size = 0; - for (Buffer item : items) { - size += item.length; - } - size += seperator.length * (items.size() - 1); - - int pos = 0; - byte data[] = new byte[size]; - for (Buffer item : items) { - if (pos != 0) { - System.arraycopy(seperator.data, seperator.offset, data, pos, seperator.length); - pos += seperator.length; - } - System.arraycopy(item.data, item.offset, data, pos, item.length); - pos += item.length; - } - - return new Buffer(data, 0, size); - } - - @Deprecated - public String toStringUtf8() { - return UTF8Buffer.decode(this); - } - - public int compareTo(Buffer o) { - int minLength = Math.min(length, o.length); - if (offset == o.offset) { - int pos = offset; - int limit = minLength + offset; - while (pos < limit) { - byte b1 = data[pos]; - byte b2 = o.data[pos]; - if (b1 != b2) { - return b1 - b2; - } - pos++; - } - } else { - int offset1 = offset; - int offset2 = o.offset; - while ( minLength-- != 0) { - byte b1 = data[offset1++]; - byte b2 = o.data[offset2++]; - if (b1 != b2) { - return b1 - b2; - } - } - } - return length - o.length; - } - -} +/** + * 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.activemq.protobuf; + +import java.util.List; + +public class Buffer implements Comparable { + + final public byte[] data; + final public int offset; + final public int length; + + public Buffer(Buffer other) { + this(other.data, other.offset, other.length); + } + + public Buffer(byte data[]) { + this(data, 0, data.length); + } + + public Buffer(byte data[], int offset, int length) { + this.data = data; + this.offset = offset; + this.length = length; + } + + @Deprecated + public Buffer(String value) { + this(UTF8Buffer.encode(value)); + } + + public final Buffer slice(int low, int high) { + int sz; + + if (high < 0) { + sz = length + high; + } else { + sz = high - low; + } + + if (sz < 0) { + sz = 0; + } + + return new Buffer(data, offset + low, sz); + } + + public final byte[] getData() { + return data; + } + + public final int getLength() { + return length; + } + + public final int getOffset() { + return offset; + } + + public Buffer compact() { + if (length != data.length) { + return new Buffer(toByteArray()); + } + return this; + } + + final public byte[] toByteArray() { + if (length != data.length) { + byte t[] = new byte[length]; + System.arraycopy(data, offset, t, 0, length); + } + return data; + } + + public byte byteAt(int i) { + return data[offset + i]; + } + + + @Override + public int hashCode() { + byte[] target = new byte[4]; + for (int i = 0; i < length; i++) { + target[i % 4] ^= data[offset + i]; + } + return target[0] << 24 | target[1] << 16 | target[2] << 8 | target[3]; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + + if (obj == null || obj.getClass() != Buffer.class) + return false; + + return equals((Buffer) obj); + } + + final public boolean equals(Buffer obj) { + if (length != obj.length) { + return false; + } + for (int i = 0; i < length; i++) { + if (obj.data[obj.offset + i] != data[offset + i]) { + return false; + } + } + return true; + } + + final public BufferInputStream newInput() { + return new BufferInputStream(this); + } + + final public BufferOutputStream newOutput() { + return new BufferOutputStream(this); + } + + final public boolean isEmpty() { + return length == 0; + } + + final public boolean contains(byte value) { + return indexOf(value, 0) >= 0; + } + + final public int indexOf(byte value, int pos) { + for (int i = pos; i < length; i++) { + if (data[offset + i] == value) { + return i; + } + } + return -1; + } + + final public static Buffer join(List items, Buffer seperator) { + if (items.isEmpty()) + return new Buffer(seperator.data, 0, 0); + + int size = 0; + for (Buffer item : items) { + size += item.length; + } + size += seperator.length * (items.size() - 1); + + int pos = 0; + byte data[] = new byte[size]; + for (Buffer item : items) { + if (pos != 0) { + System.arraycopy(seperator.data, seperator.offset, data, pos, seperator.length); + pos += seperator.length; + } + System.arraycopy(item.data, item.offset, data, pos, item.length); + pos += item.length; + } + + return new Buffer(data, 0, size); + } + + @Deprecated + public String toStringUtf8() { + return UTF8Buffer.decode(this); + } + + public int compareTo(Buffer o) { + int minLength = Math.min(length, o.length); + if (offset == o.offset) { + int pos = offset; + int limit = minLength + offset; + while (pos < limit) { + byte b1 = data[pos]; + byte b2 = o.data[pos]; + if (b1 != b2) { + return b1 - b2; + } + pos++; + } + } else { + int offset1 = offset; + int offset2 = o.offset; + while ( minLength-- != 0) { + byte b1 = data[offset1++]; + byte b2 = o.data[offset2++]; + if (b1 != b2) { + return b1 - b2; + } + } + } + return length - o.length; + } + +} Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/Buffer.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferInputStream.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferInputStream.java?rev=781514&r1=781513&r2=781514&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferInputStream.java (original) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferInputStream.java Wed Jun 3 19:20:13 2009 @@ -1,109 +1,109 @@ -/** - * 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.activemq.protobuf; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Very similar to the java.io.ByteArrayInputStream but this version is not - * thread safe. - */ -final public class BufferInputStream extends InputStream { - - byte buffer[]; - int limit; - int pos; - int mark; - - public BufferInputStream(byte data[]) { - this(data, 0, data.length); - } - - public BufferInputStream(Buffer sequence) { - this(sequence.getData(), sequence.getOffset(), sequence.getLength()); - } - - public BufferInputStream(byte data[], int offset, int size) { - this.buffer = data; - this.mark = offset; - this.pos = offset; - this.limit = offset + size; - } - - public int read() throws IOException { - if (pos < limit) { - return buffer[pos++] & 0xff; - } else { - return -1; - } - } - - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - public int read(byte b[], int off, int len) { - if (pos < limit) { - len = Math.min(len, limit - pos); - System.arraycopy(buffer, pos, b, off, len); - pos += len; - return len; - } else { - return -1; - } - } - - public Buffer readBuffer(int len) { - Buffer rc=null; - if (pos < limit) { - len = Math.min(len, limit - pos); - rc = new Buffer(buffer, pos, len); - pos += len; - } - return rc; - } - - public long skip(long len) throws IOException { - if (pos < limit) { - len = Math.min(len, limit - pos); - if (len > 0) { - pos += len; - } - return len; - } else { - return -1; - } - } - - public int available() { - return limit - pos; - } - - public boolean markSupported() { - return true; - } - - public void mark(int markpos) { - mark = pos; - } - - public void reset() { - pos = mark; - } - -} +/** + * 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.activemq.protobuf; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Very similar to the java.io.ByteArrayInputStream but this version is not + * thread safe. + */ +final public class BufferInputStream extends InputStream { + + byte buffer[]; + int limit; + int pos; + int mark; + + public BufferInputStream(byte data[]) { + this(data, 0, data.length); + } + + public BufferInputStream(Buffer sequence) { + this(sequence.getData(), sequence.getOffset(), sequence.getLength()); + } + + public BufferInputStream(byte data[], int offset, int size) { + this.buffer = data; + this.mark = offset; + this.pos = offset; + this.limit = offset + size; + } + + public int read() throws IOException { + if (pos < limit) { + return buffer[pos++] & 0xff; + } else { + return -1; + } + } + + public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + + public int read(byte b[], int off, int len) { + if (pos < limit) { + len = Math.min(len, limit - pos); + System.arraycopy(buffer, pos, b, off, len); + pos += len; + return len; + } else { + return -1; + } + } + + public Buffer readBuffer(int len) { + Buffer rc=null; + if (pos < limit) { + len = Math.min(len, limit - pos); + rc = new Buffer(buffer, pos, len); + pos += len; + } + return rc; + } + + public long skip(long len) throws IOException { + if (pos < limit) { + len = Math.min(len, limit - pos); + if (len > 0) { + pos += len; + } + return len; + } else { + return -1; + } + } + + public int available() { + return limit - pos; + } + + public boolean markSupported() { + return true; + } + + public void mark(int markpos) { + mark = pos; + } + + public void reset() { + pos = mark; + } + +} Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferInputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferOutputStream.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferOutputStream.java?rev=781514&r1=781513&r2=781514&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferOutputStream.java (original) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferOutputStream.java Wed Jun 3 19:20:13 2009 @@ -1,101 +1,101 @@ -/** - * 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.activemq.protobuf; - -import java.io.EOFException; -import java.io.IOException; -import java.io.OutputStream; - - -/** - * Very similar to the java.io.ByteArrayOutputStream but this version - * is not thread safe and the resulting data is returned in a Buffer - * to avoid an extra byte[] allocation. It also does not re-grow it's - * internal buffer. - */ -final public class BufferOutputStream extends OutputStream { - - byte buffer[]; - int offset; - int limit; - int pos; - - public BufferOutputStream(int size) { - this(new byte[size]); - } - - public BufferOutputStream(byte[] buffer) { - this.buffer = buffer; - this.limit = buffer.length; - } - - public BufferOutputStream(Buffer data) { - this.buffer = data.data; - this.pos = this.offset = data.offset; - this.limit = data.offset+data.length; - } - - - public void write(int b) throws IOException { - int newPos = pos + 1; - checkCapacity(newPos); - buffer[pos] = (byte) b; - pos = newPos; - } - - public void write(byte b[], int off, int len) throws IOException { - int newPos = pos + len; - checkCapacity(newPos); - System.arraycopy(b, off, buffer, pos, len); - pos = newPos; - } - - public Buffer getNextBuffer(int len) throws IOException { - int newPos = pos + len; - checkCapacity(newPos); - return new Buffer(buffer, pos, len); - } - - /** - * Ensures the the buffer has at least the minimumCapacity specified. - * @param i - * @throws EOFException - */ - private void checkCapacity(int minimumCapacity) throws IOException { - if( minimumCapacity > limit ) { - throw new EOFException("Buffer limit reached."); - } - } - - public void reset() { - pos = offset; - } - - public Buffer toBuffer() { - return new Buffer(buffer, offset, pos); - } - - public byte[] toByteArray() { - return toBuffer().toByteArray(); - } - - public int size() { - return offset-pos; - } - - -} +/** + * 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.activemq.protobuf; + +import java.io.EOFException; +import java.io.IOException; +import java.io.OutputStream; + + +/** + * Very similar to the java.io.ByteArrayOutputStream but this version + * is not thread safe and the resulting data is returned in a Buffer + * to avoid an extra byte[] allocation. It also does not re-grow it's + * internal buffer. + */ +final public class BufferOutputStream extends OutputStream { + + byte buffer[]; + int offset; + int limit; + int pos; + + public BufferOutputStream(int size) { + this(new byte[size]); + } + + public BufferOutputStream(byte[] buffer) { + this.buffer = buffer; + this.limit = buffer.length; + } + + public BufferOutputStream(Buffer data) { + this.buffer = data.data; + this.pos = this.offset = data.offset; + this.limit = data.offset+data.length; + } + + + public void write(int b) throws IOException { + int newPos = pos + 1; + checkCapacity(newPos); + buffer[pos] = (byte) b; + pos = newPos; + } + + public void write(byte b[], int off, int len) throws IOException { + int newPos = pos + len; + checkCapacity(newPos); + System.arraycopy(b, off, buffer, pos, len); + pos = newPos; + } + + public Buffer getNextBuffer(int len) throws IOException { + int newPos = pos + len; + checkCapacity(newPos); + return new Buffer(buffer, pos, len); + } + + /** + * Ensures the the buffer has at least the minimumCapacity specified. + * @param i + * @throws EOFException + */ + private void checkCapacity(int minimumCapacity) throws IOException { + if( minimumCapacity > limit ) { + throw new EOFException("Buffer limit reached."); + } + } + + public void reset() { + pos = offset; + } + + public Buffer toBuffer() { + return new Buffer(buffer, offset, pos); + } + + public byte[] toByteArray() { + return toBuffer().toByteArray(); + } + + public int size() { + return offset-pos; + } + + +} Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/BufferOutputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/protobuf/UTF8Buffer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/BitArray.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/BitArrayBin.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteArrayOutputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequence.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ByteSequenceData.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/Callback.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/Comparators.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/DataByteArrayOutputStream.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/FactoryFinder.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HashList.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/HexSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/IOExceptionSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/IdGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/IndentPrinter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/IntSequenceGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/JMXSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/LRUCache.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/LongSequenceGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/Mapper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/PriorityLinkedList.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/PriorityMap.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ServiceListener.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ServiceStopper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/ServiceSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/SortedLinkedList.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/SortedLinkedListNode.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/TimerHeap.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/TreeMap.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/activemq/util/URISupport.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/LockFile.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/LockFile.java?rev=781514&r1=781513&r2=781514&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/LockFile.java (original) +++ activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/LockFile.java Wed Jun 3 19:20:13 2009 @@ -1,106 +1,106 @@ -/** - * 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.kahadb.util; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.FileLock; -import java.nio.channels.OverlappingFileLockException; - -/** - * Used to lock a File. - * - * @author chirino - */ -public class LockFile { - - private static final boolean DISABLE_FILE_LOCK = "true".equals(System.getProperty("java.nio.channels.FileLock.broken", "false")); - final private File file; - - private FileLock lock; - private RandomAccessFile readFile; - private int lockCounter; - private final boolean deleteOnUnlock; - - public LockFile(File file, boolean deleteOnUnlock) { - this.file = file; - this.deleteOnUnlock = deleteOnUnlock; - } - - /** - * @throws IOException - */ - synchronized public void lock() throws IOException { - if (DISABLE_FILE_LOCK) { - return; - } - - lockCounter++; - if( lockCounter!=1 ) { - return; - } - - IOHelper.mkdirs(file.getParentFile()); - readFile = new RandomAccessFile(file, "rw"); - if (lock == null) { - try { - lock = readFile.getChannel().tryLock(); - } catch (OverlappingFileLockException e) { - throw IOExceptionSupport.create("File '" + file + "' could not be locked.",e); - } - if (lock == null) { - throw new IOException("File '" + file + "' could not be locked."); - } - } - } - - /** - */ - public void unlock() { - if (DISABLE_FILE_LOCK) { - return; - } - - lockCounter--; - if( lockCounter!=0 ) { - return; - } - - // release the lock.. - if (lock != null) { - try { - lock.release(); - } catch (Throwable ignore) { - } - lock = null; - } - // close the file. - if (readFile != null) { - try { - readFile.close(); - } catch (Throwable ignore) { - } - readFile = null; - } - - if( deleteOnUnlock ) { - file.delete(); - } - } - -} +/** + * 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.kahadb.util; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.channels.FileLock; +import java.nio.channels.OverlappingFileLockException; + +/** + * Used to lock a File. + * + * @author chirino + */ +public class LockFile { + + private static final boolean DISABLE_FILE_LOCK = "true".equals(System.getProperty("java.nio.channels.FileLock.broken", "false")); + final private File file; + + private FileLock lock; + private RandomAccessFile readFile; + private int lockCounter; + private final boolean deleteOnUnlock; + + public LockFile(File file, boolean deleteOnUnlock) { + this.file = file; + this.deleteOnUnlock = deleteOnUnlock; + } + + /** + * @throws IOException + */ + synchronized public void lock() throws IOException { + if (DISABLE_FILE_LOCK) { + return; + } + + lockCounter++; + if( lockCounter!=1 ) { + return; + } + + IOHelper.mkdirs(file.getParentFile()); + readFile = new RandomAccessFile(file, "rw"); + if (lock == null) { + try { + lock = readFile.getChannel().tryLock(); + } catch (OverlappingFileLockException e) { + throw IOExceptionSupport.create("File '" + file + "' could not be locked.",e); + } + if (lock == null) { + throw new IOException("File '" + file + "' could not be locked."); + } + } + } + + /** + */ + public void unlock() { + if (DISABLE_FILE_LOCK) { + return; + } + + lockCounter--; + if( lockCounter!=0 ) { + return; + } + + // release the lock.. + if (lock != null) { + try { + lock.release(); + } catch (Throwable ignore) { + } + lock = null; + } + // close the file. + if (readFile != null) { + try { + readFile.close(); + } catch (Throwable ignore) { + } + readFile = null; + } + + if( deleteOnUnlock ) { + file.delete(); + } + } + +} Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/LockFile.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/main/java/org/apache/kahadb/util/VariableMarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/activemq-util/src/test/java/org/apache/activemq/util/TreeMapTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/sandbox/activemq-flow/kahadb/src/main/java/org/apache/kahadb/journal/ReplicationTarget.java URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/kahadb/src/main/java/org/apache/kahadb/journal/ReplicationTarget.java?rev=781514&r1=781513&r2=781514&view=diff ============================================================================== --- activemq/sandbox/activemq-flow/kahadb/src/main/java/org/apache/kahadb/journal/ReplicationTarget.java (original) +++ activemq/sandbox/activemq-flow/kahadb/src/main/java/org/apache/kahadb/journal/ReplicationTarget.java Wed Jun 3 19:20:13 2009 @@ -1,25 +1,25 @@ -/** - * 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.kahadb.journal; - -import org.apache.kahadb.util.ByteSequence; - -public interface ReplicationTarget { - - void replicate(Location location, ByteSequence sequence, boolean sync); - -} +/** + * 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.kahadb.journal; + +import org.apache.kahadb.util.ByteSequence; + +public interface ReplicationTarget { + + void replicate(Location location, ByteSequence sequence, boolean sync); + +} Propchange: activemq/sandbox/activemq-flow/kahadb/src/main/java/org/apache/kahadb/journal/ReplicationTarget.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/sandbox/activemq-flow/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native