本文整理了Java中org.apache.mina.common.ByteBuffer.wrap()
方法的一些代码示例,展示了ByteBuffer.wrap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.wrap()
方法的具体详情如下:
包路径:org.apache.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:wrap
[英]Wraps the specified NIO java.nio.ByteBuffer into MINA buffer.
[中]包装指定的NIO java。尼奥。把它放进MINA缓冲区。
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: org.apache.directory.mina/mina-core
/**
* Wraps the specified byte array into MINA heap buffer.
*/
public static ByteBuffer wrap( byte[] byteArray )
{
return wrap( java.nio.ByteBuffer.wrap( byteArray ) );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
/**
* Wraps the specified byte array into MINA heap buffer.
* Please note that MINA buffers are going to be pooled, and
* therefore there can be waste of memory if you wrap
* your byte array specifying <tt>offset</tt> and <tt>length</tt>.
*/
public static ByteBuffer wrap( byte[] byteArray, int offset, int length )
{
return wrap( java.nio.ByteBuffer.wrap( byteArray, offset, length ) );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
private ByteBuffer getNextByteBuffer( InputStream is ) throws IOException
{
byte[] bytes = new byte[ writeBufferSize ];
int off = 0;
int n = 0;
while( off < bytes.length &&
( n = is.read( bytes, off, bytes.length - off ) ) != -1 )
{
off += n;
}
if( n == -1 && off == 0 )
{
return null;
}
ByteBuffer buffer = ByteBuffer.wrap( bytes, 0, off );
return buffer;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void write( byte[] b, int off, int len ) throws IOException
{
write( ByteBuffer.wrap( b, off, len ) );
}
代码示例来源:origin: org.apache.mina/mina-filter-ssl
/**
* Releases the specified buffer to buffer pool.
*/
public static void release(ByteBuffer buf) {
// Sweep buffer for security.
org.apache.mina.common.ByteBuffer.wrap(buf).sweep().release();
int stackIndex = getBufferStackIndex(buf.capacity());
if (stackIndex >= PACKET_BUFFER_INDEX) {
Stack stack = bufferStacks[getBufferStackIndex(buf.capacity())];
synchronized (stack) {
stack.push(buf);
}
}
}
代码示例来源:origin: org.apache.directory.mina/mina-filter-codec-asn1
ByteBuffer wrappedBuf = ByteBuffer.wrap( buf );
代码示例来源:origin: net.jahhan/dubbo-remoting-mina
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnectd(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: remoting/dubbox
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnectd(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: com.alibaba/dubbo
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: remoting/dubbox
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnectd(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: org.apache.dubbo/dubbo
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: com.alibaba/dubbo-remoting-mina
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
代码示例来源:origin: org.apache.dubbo/dubbo-remoting-mina
@Override
public void encode(IoSession session, Object msg, ProtocolEncoderOutput out) throws Exception {
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
MinaChannel channel = MinaChannel.getOrAddChannel(session, url, handler);
try {
codec.encode(channel, buffer, msg);
} finally {
MinaChannel.removeChannelIfDisconnected(session);
}
out.write(ByteBuffer.wrap(buffer.toByteBuffer()));
out.flush();
}
}
内容来源于网络,如有侵权,请联系作者删除!