org.glassfish.grizzly.memory.Buffers.getDefaultMemoryManager()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(16.1k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.glassfish.grizzly.memory.Buffers.getDefaultMemoryManager()方法的一些代码示例,展示了Buffers.getDefaultMemoryManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffers.getDefaultMemoryManager()方法的具体详情如下:
包路径:org.glassfish.grizzly.memory.Buffers
类名称:Buffers
方法名:getDefaultMemoryManager

Buffers.getDefaultMemoryManager介绍

暂无

代码示例

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-framework

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER 
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  
  return clone.flip();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-core

/**
 * Clones the source {@link Buffer}.
 * The method returns a new {@link Buffer} instance, which has the same content.
 * Please note, source and result {@link Buffer}s have the same content,
 * but it is *not* shared, so the following content changes in one of the
 * {@link Buffer}s won't be visible in another one.
 *
 * @param srcBuffer the source {@link Buffer}.
 * @param position the start position in the srcBuffer
 * @param limit the end position in the srcBuffer
 * @return the cloned {@link Buffer}.
 */
public static Buffer cloneBuffer(final Buffer srcBuffer,
    final int position, final int limit) {
  final int srcLength = limit - position;
  if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER
    return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER);
  }
  final Buffer clone = getDefaultMemoryManager().allocate(srcLength);
  clone.put(srcBuffer, position, srcLength);
  clone.order(srcBuffer.order());
  return clone.flip();
}

代码示例来源:origin: javaee/grizzly

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-core

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-framework

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

代码示例来源:origin: javaee/grizzly

/**
 * Returns {@link Buffer}, which wraps the part of byte array with
 * specific offset and length.
 *
 * @param memoryManager {@link MemoryManager}, which should be
 *                       used for wrapping.
 * @param array byte array to wrap
 * @param offset byte buffer offset
 * @param length byte buffer length
 *
 * @return {@link Buffer} wrapper on top of passed byte array.
 */
public static Buffer wrap(MemoryManager memoryManager,
    final byte[] array, final int offset, final int length) {
  if (memoryManager == null) {
    memoryManager = getDefaultMemoryManager();
  }
  if (memoryManager instanceof WrapperAware) {
    return ((WrapperAware) memoryManager).wrap(array, offset, length);
  }
  final Buffer buffer = memoryManager.allocate(length);
  buffer.put(array, offset, length);
  buffer.flip();
  return buffer;
}

相关文章