本文整理汇总了Java中io.apiman.gateway.engine.io.IApimanBuffer.getNativeBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java IApimanBuffer.getNativeBuffer方法的具体用法?Java IApimanBuffer.getNativeBuffer怎么用?Java IApimanBuffer.getNativeBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.apiman.gateway.engine.io.IApimanBuffer
的用法示例。
在下文中一共展示了IApimanBuffer.getNativeBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import io.apiman.gateway.engine.io.IApimanBuffer; //导入方法依赖的package包/类
/**
* @see io.apiman.gateway.engine.io.IWriteStream#write(io.apiman.gateway.engine.io.IApimanBuffer)
*/
@Override
public void write(IApimanBuffer chunk) {
try {
if (!connected) {
throw new IOException("Not connected."); //$NON-NLS-1$
}
if (outputStream == null) {
outputStream = connection.getOutputStream();
}
if (chunk instanceof ByteBuffer) {
byte[] buffer = (byte[]) chunk.getNativeBuffer();
outputStream.write(buffer, 0, chunk.length());
} else {
outputStream.write(chunk.getBytes());
}
} catch (IOException e) {
handleConnectionError(e);
}
}
示例2: write
import io.apiman.gateway.engine.io.IApimanBuffer; //导入方法依赖的package包/类
@Override
public void write(IApimanBuffer chunk) {
if (inboundFinished) {
throw new IllegalStateException(Messages.getString("HttpConnector.0"));
}
if (chunk.getNativeBuffer() instanceof Buffer) {
clientRequest.write((Buffer) chunk.getNativeBuffer());
// When write queue has diminished sufficiently, drain handler will be invoked.
if (clientRequest.writeQueueFull() && drainHandler != null) {
clientRequest.drainHandler(drainHandler::handle);
}
} else {
throw new IllegalArgumentException(Messages.getString("HttpConnector.1"));
}
}
示例3: getNativeBuffer
import io.apiman.gateway.engine.io.IApimanBuffer; //导入方法依赖的package包/类
private Buffer getNativeBuffer(IApimanBuffer buffer) {
if (buffer.getNativeBuffer() instanceof Buffer) {
return (Buffer) buffer.getNativeBuffer();
} else {
logger.debug("Received an IApimanBuffer with a non-Vert.x implementation. " //$NON-NLS-1$
+ "This will function but may require copying and be less efficient."); //$NON-NLS-1$
return Buffer.buffer(buffer.getBytes());
}
}