本文整理了Java中org.apache.activemq.util.ByteArrayOutputStream.toByteSequence()
方法的一些代码示例,展示了ByteArrayOutputStream.toByteSequence()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArrayOutputStream.toByteSequence()
方法的具体详情如下:
包路径:org.apache.activemq.util.ByteArrayOutputStream
类名称:ByteArrayOutputStream
方法名:toByteSequence
暂无
代码示例来源:origin: apache/activemq
@Override
public void storeContent() {
if (dataOut != null) {
try {
dataOut.close();
setContent(bytesOut.toByteSequence());
bytesOut = null;
dataOut = null;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
}
代码示例来源:origin: apache/activemq
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
// Need to marshal the properties.
if (marshalledProperties == null && properties != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
MarshallingSupport.marshalPrimitiveMap(properties, os);
os.close();
marshalledProperties = baos.toByteSequence();
}
}
代码示例来源:origin: apache/activemq
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
// Need to marshal the properties.
if (marshalledProperties == null && properties != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
MarshallingSupport.marshalPrimitiveMap(properties, os);
os.close();
marshalledProperties = baos.toByteSequence();
}
}
代码示例来源:origin: apache/activemq
public ByteSequence marshal(Object command) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream ds = new DataOutputStream(baos);
marshal(command, ds);
ds.close();
return baos.toByteSequence();
}
代码示例来源:origin: apache/activemq
protected void doCompress() throws IOException {
compressed = true;
ByteSequence bytes = getContent();
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = new DeflaterOutputStream(bytesOut);
os.write(bytes.data, bytes.offset, bytes.length);
os.close();
setContent(bytesOut.toByteSequence());
}
代码示例来源:origin: apache/activemq
private void trace(DataStructure command) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(maxTraceDatagramSize);
DataOutputStream out = new DataOutputStream(baos);
wireFormat.marshal(brokerId, out);
wireFormat.marshal(command, out);
out.close();
ByteSequence sequence = baos.toByteSequence();
DatagramPacket datagram = new DatagramPacket(sequence.getData(), sequence.getOffset(), sequence.getLength(), address);
socket.send(datagram);
} catch (Throwable e) {
LOG.debug("Failed to trace: {}", command, e);
}
}
代码示例来源:origin: apache/activemq
@Override
public void storeContent() {
ByteSequence bodyAsBytes = getContent();
if (bodyAsBytes == null && object != null) {
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = bytesOut;
ActiveMQConnection connection = getConnection();
if (connection != null && connection.isUseCompression()) {
compressed = true;
os = new DeflaterOutputStream(os);
}
DataOutputStream dataOut = new DataOutputStream(os);
ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
objOut.writeObject(object);
objOut.flush();
objOut.reset();
objOut.close();
setContent(bytesOut.toByteSequence());
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage(), ioe);
}
}
}
代码示例来源:origin: apache/activemq
@Override
public void storeContent() {
try {
if (getContent() == null && !map.isEmpty()) {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = bytesOut;
ActiveMQConnection connection = getConnection();
if (connection != null && connection.isUseCompression()) {
compressed = true;
os = new DeflaterOutputStream(os);
}
DataOutputStream dataOut = new DataOutputStream(os);
MarshallingSupport.marshalPrimitiveMap(map, dataOut);
dataOut.close();
setContent(bytesOut.toByteSequence());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/activemq
@Override
public void storeContent() {
if (dataOut != null) {
try {
dataOut.close();
ByteSequence bs = bytesOut.toByteSequence();
setContent(bs);
ActiveMQConnection connection = getConnection();
if (connection != null && connection.isUseCompression()) {
doCompress();
}
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage(), ioe);
} finally {
try {
if (bytesOut != null) {
bytesOut.close();
bytesOut = null;
}
if (dataOut != null) {
dataOut.close();
dataOut = null;
}
} catch (IOException ioe) {
}
}
}
}
代码示例来源:origin: apache/activemq
@Override
public void storeContent() {
try {
ByteSequence content = getContent();
String text = this.text;
if (content == null && text != null) {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = bytesOut;
ActiveMQConnection connection = getConnection();
if (connection != null && connection.isUseCompression()) {
compressed = true;
os = new DeflaterOutputStream(os);
}
DataOutputStream dataOut = new DataOutputStream(os);
MarshallingSupport.writeUTF8(dataOut, text);
dataOut.close();
setContent(bytesOut.toByteSequence());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/activemq
@Override
protected void doCompress() throws IOException {
compressed = true;
ByteSequence bytes = getContent();
if (bytes != null) {
int length = bytes.getLength();
ByteArrayOutputStream compressed = new ByteArrayOutputStream();
compressed.write(new byte[4]);
Deflater deflater = new Deflater();
try {
deflater.setInput(bytes.data);
deflater.finish();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int count = deflater.deflate(buffer);
compressed.write(buffer, 0, count);
}
bytes = compressed.toByteSequence();
ByteSequenceData.writeIntBig(bytes, length);
bytes.offset = 0;
setContent(bytes);
} finally {
deflater.end();
compressed.close();
}
}
}
}
代码示例来源:origin: org.apache.activemq/activemq-client
public ByteSequence marshal(Object command) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream ds = new DataOutputStream(baos);
marshal(command, ds);
ds.close();
return baos.toByteSequence();
}
代码示例来源:origin: org.apache.activemq/activemq-client
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
// Need to marshal the properties.
if (marshalledProperties == null && properties != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
MarshallingSupport.marshalPrimitiveMap(properties, os);
os.close();
marshalledProperties = baos.toByteSequence();
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
@Override
public ByteSequence marshal(Object command) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
marshal(command, dos);
dos.close();
return baos.toByteSequence();
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
// Need to marshal the properties.
if (marshalledProperties == null && properties != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
MarshallingSupport.marshalPrimitiveMap(properties, os);
os.close();
marshalledProperties = baos.toByteSequence();
}
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
public ByteSequence marshal(Object command) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
marshal(command, dos);
dos.close();
return baos.toByteSequence();
}
代码示例来源:origin: org.apache.activemq/activemq-all
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
// Need to marshal the properties.
if (marshalledProperties == null && properties != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
MarshallingSupport.marshalPrimitiveMap(properties, os);
os.close();
marshalledProperties = baos.toByteSequence();
}
}
代码示例来源:origin: org.apache.activemq/activemq-client
protected void doCompress() throws IOException {
compressed = true;
ByteSequence bytes = getContent();
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = new DeflaterOutputStream(bytesOut);
os.write(bytes.data, bytes.offset, bytes.length);
os.close();
setContent(bytesOut.toByteSequence());
}
代码示例来源:origin: org.apache.activemq/activemq-all
protected void doCompress() throws IOException {
compressed = true;
ByteSequence bytes = getContent();
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
OutputStream os = new DeflaterOutputStream(bytesOut);
os.write(bytes.data, bytes.offset, bytes.length);
os.close();
setContent(bytesOut.toByteSequence());
}
代码示例来源:origin: apache/activemq-artemis
private static ByteSequence writeCompressedDefaultType(final ByteSequence contents) throws IOException {
try (org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream();
OutputStream os = new InflaterOutputStream(decompressed)) {
os.write(contents.data, contents.offset, contents.getLength());
return decompressed.toByteSequence();
} catch (Exception e) {
throw new IOException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!