org.glassfish.grizzly.Connection.getTransport()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(137)

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

Connection.getTransport介绍

[英]Get the Transport, to which this Connection belongs to.
[中]获取此连接所属的传输。

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
  Connection<?> connection = context.getConnection();
  GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
  try {
    ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
    Object msg = context.getMessage();
    codec.encode(channel, channelBuffer, msg);
    GrizzlyChannel.removeChannelIfDisconnected(connection);
    Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
    buffer.put(channelBuffer.toByteBuffer());
    buffer.flip();
    buffer.allowBufferDispose(true);
    context.setMessage(buffer);
  } finally {
    GrizzlyChannel.removeChannelIfDisconnected(connection);
  }
  return context.getInvokeAction();
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
  Connection<?> connection = context.getConnection();
  GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
  try {
    ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
    Object msg = context.getMessage();
    codec.encode(channel, channelBuffer, msg);
    GrizzlyChannel.removeChannelIfDisconnected(connection);
    Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
    buffer.put(channelBuffer.toByteBuffer());
    buffer.flip();
    buffer.allowBufferDispose(true);
    context.setMessage(buffer);
  } finally {
    GrizzlyChannel.removeChannelIfDisconnected(connection);
  }
  return context.getInvokeAction();
}

代码示例来源:origin: com.ning/async-http-client

private void feederFlush(final Connection c) {
  if (isServiceThread()) {
    c.getTransport().getWorkerThreadPool().execute(new Runnable() {
      @Override
      public void run() {
        feederFlush0(c);
      }
    });
  } else {
    feederFlush0(c);
  }
}

代码示例来源:origin: com.ning/async-http-client

private static void block(final Connection c,
             final FutureImpl<Boolean> future) {
  try {
    final long writeTimeout =
        c.getTransport().getWriteTimeout(MILLISECONDS);
    if (writeTimeout != -1) {
      future.get(writeTimeout, MILLISECONDS);
    } else {
      future.get();
    }
  } catch (ExecutionException e) {
    c.closeWithReason(Exceptions.makeIOException(e.getCause()));
  } catch (Exception e) {
    c.closeWithReason(Exceptions.makeIOException(e));
  }
}

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

@Override
public Executor getThreadPoolFor(final Connection connection,
    final IOEvent ioEvent) {
  return WORKER_THREAD_EVENT_SET.contains(ioEvent) ?
      connection.getTransport().getWorkerThreadPool() :
      null;
}

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

@Override
public Executor getThreadPoolFor(final Connection connection,
    final IOEvent ioEvent) {
  return WORKER_THREAD_EVENT_SET.contains(ioEvent) ?
      connection.getTransport().getWorkerThreadPool() :
      null;
}

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

@Override
public Executor getThreadPoolFor(final Connection connection,
    final IOEvent ioEvent) {
  return WORKER_THREAD_EVENT_SET.contains(ioEvent) ?
      connection.getTransport().getWorkerThreadPool() :
      null;
}

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

/**
 * @return {@link Executor}, which will be used for notifying user
 * registered {@link WriteHandler}.
 */
protected Executor getThreadPool() {
  if (!Threads.isService()) {
    return null;
  }
  
  final ExecutorService es = connection.getTransport().getWorkerThreadPool();
  return es != null && !es.isShutdown() ? es : null;
}

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

/**
 * @return {@link Executor}, which will be used for notifying user
 * registered {@link ReadHandler}.
 */
protected Executor getThreadPool() {
  if (!Threads.isService()) {
    return null;
  }
  final ExecutorService es = connection.getTransport().getWorkerThreadPool();
  return es != null && !es.isShutdown() ? es : null;
}

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

/**
 * @return {@link Executor}, which will be used for notifying user
 * registered {@link WriteHandler}.
 */
protected Executor getThreadPool() {
  if (!Threads.isService()) {
    return null;
  }
  
  final ExecutorService es = connection.getTransport().getWorkerThreadPool();
  return es != null && !es.isShutdown() ? es : null;
}

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

/**
 * @return {@link Executor}, which will be used for notifying user
 * registered {@link WriteHandler}.
 */
protected Executor getThreadPool() {
  if (!Threads.isService()) {
    return null;
  }
  
  final ExecutorService es = connection.getTransport().getWorkerThreadPool();
  return es != null && !es.isShutdown() ? es : null;
}

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

/**
 * @return {@link Executor}, which will be used for notifying user
 * registered {@link WriteHandler}.
 */
protected Executor getThreadPool() {
  if (!Threads.isService()) {
    return null;
  }
  
  final ExecutorService es = connection.getTransport().getWorkerThreadPool();
  return es != null && !es.isShutdown() ? es : null;
}

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

protected Buffer acquireBuffer(Connection connection) {
  Transport connectionTransport = connection.getTransport();
  return connectionTransport.getMemoryManager().
      allocate(DEFAULT_BUFFER_SIZE);
}

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

@Override
public void write(Connection connection, Object dstAddress,
    Object message, CompletionHandler completionHandler,
    MessageCloner messageCloner) {
  
  final Transport transport = connection.getTransport();
  
  transport.getWriter(connection).write(connection, dstAddress,
      (Buffer) message, completionHandler, messageCloner);
}

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

@Override
public void read(Connection connection,
    CompletionHandler completionHandler) {
  
  final Transport transport = connection.getTransport();
  transport.getReader(connection).read(connection,
      null, completionHandler);
}

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

protected Buffer acquireBuffer(Connection connection) {
  Transport connectionTransport = connection.getTransport();
  return connectionTransport.getMemoryManager().
      allocate(DEFAULT_BUFFER_SIZE);
}

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

@Override
  public Executor getExecutor(final Request request) {
    if (!Threads.isService()) {
      return null; // Execute in the current thread
    }
    return request.getContext().getConnection().getTransport().getWorkerThreadPool();
  }
}

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

@Override
  public Executor getExecutor(final Request request) {
    if (!Threads.isService()) {
      return null; // Execute in the current thread
    }
    return request.getContext().getConnection().getTransport().getWorkerThreadPool();
  }
}

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

@SuppressWarnings("unchecked")
protected void sendRaw(byte[] rawData) {
  final Connection connection = protocolHandler.getConnection();
  final MemoryManager mm = connection.getTransport().getMemoryManager();
  final Buffer buffer = Buffers.wrap(mm, rawData);
  buffer.allowBufferDispose(false);
  connection.write(buffer);
}

代码示例来源:origin: org.mule.services/mule-service-http

@Before
public void setUp() {
 when(ctx.getConnection()).thenReturn(connection);
 when(connection.getTransport()).thenReturn(mock(Transport.class, RETURNS_DEEP_STUBS));
 InputStream mockStream = mock(InputStream.class);
 handler = new ResponseStreamingCompletionHandler(ctx,
                          request,
                          HttpResponse.builder().entity(new InputStreamHttpEntity(mockStream)).build(),
                          callback);
}

相关文章