Tabnine Logo
SelectionKeyHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
SelectionKeyHandler
in
org.glassfish.grizzly.nio

Best Java code snippets using org.glassfish.grizzly.nio.SelectionKeyHandler (Showing top 20 results out of 315)

origin: javaee/grizzly

try {
  final Connection connection =
      transport.getSelectionKeyHandler().getConnectionForKey(key);
  } else {
    final SelectableChannel channel = key.channel();
    transport.getSelectionKeyHandler().cancel(key);
    channel.close();
origin: javaee/grizzly

private boolean iterateKeyEvents()
    throws IOException {
  final SelectionKey keyLocal = key;
  final SelectionKeyHandler selectionKeyHandler = transport.getSelectionKeyHandler();
  final IOStrategy ioStrategy = transport.getIOStrategy();
  final IOEvent[] ioEvents = selectionKeyHandler.getIOEvents(keyReadyOps);
  final NIOConnection connection =
      selectionKeyHandler.getConnectionForKey(keyLocal);
  for (IOEvent ioEvent : ioEvents) {
    NIOConnection.notifyIOEventReady(connection, ioEvent);
    
    final int interest = ioEvent.getSelectionKeyInterest();
    keyReadyOps &= (~interest);
    if (selectionKeyHandler.onProcessInterest(keyLocal, interest)) {
      if (!ioStrategy.executeIoEvent(connection, ioEvent)) {
        return false;
      }
    }
  }
  return true;
}
origin: javaee/grizzly

protected final void switchToNewSelector() throws IOException {
  final Selector oldSelector = selector;
  final Selector newSelector = Selectors.newSelector(transport.getSelectorProvider());
  final Set<SelectionKey> keys = oldSelector.keys();
  final SelectionKeyHandler selectionKeyHandler =
      transport.getSelectionKeyHandler();
  
  for (final SelectionKey selectionKey : keys) {
    if (selectionKey.isValid()) {
      try {
        final NIOConnection nioConnection =
            selectionKeyHandler.getConnectionForKey(selectionKey);
        final SelectionKey newSelectionKey =
            selectionKey.channel().register(newSelector,
            selectionKey.interestOps(), selectionKey.attachment());
        nioConnection.onSelectionKeyUpdated(newSelectionKey);
      } catch (Exception e) {
        LOGGER.log(Level.FINE, "Error switching channel to a new selector", e);
      }
    }
  }
  setSelector(newSelector);
  try {
    oldSelector.close();
  } catch (Exception ignored) {
  }
}
origin: org.glassfish.grizzly/grizzly-websockets-server

selectorRunner.getTransport().getSelectionKeyHandler().cancel(key);
    onKeyDeregistered(key);
origin: org.glassfish.grizzly/grizzly-websockets-server

onKeyRegistered(registeredSelectionKey);
origin: javaee/grizzly

protected final void switchToNewSelector() throws IOException {
  final Selector oldSelector = selector;
  final Selector newSelector = Selectors.newSelector(transport.getSelectorProvider());
  final Set<SelectionKey> keys = oldSelector.keys();
  final SelectionKeyHandler selectionKeyHandler =
      transport.getSelectionKeyHandler();
  
  for (final SelectionKey selectionKey : keys) {
    if (selectionKey.isValid()) {
      try {
        final NIOConnection nioConnection =
            selectionKeyHandler.getConnectionForKey(selectionKey);
        final SelectionKey newSelectionKey =
            selectionKey.channel().register(newSelector,
            selectionKey.interestOps(), selectionKey.attachment());
        nioConnection.onSelectionKeyUpdated(newSelectionKey);
      } catch (Exception e) {
        LOGGER.log(Level.FINE, "Error switching channel to a new selector", e);
      }
    }
  }
  setSelector(newSelector);
  try {
    oldSelector.close();
  } catch (Exception ignored) {
  }
}
origin: javaee/grizzly

selectorRunner.getTransport().getSelectionKeyHandler().cancel(key);
    onKeyDeregistered(key);
origin: javaee/grizzly

onKeyRegistered(registeredSelectionKey);
origin: javaee/grizzly

private boolean iterateKeyEvents()
    throws IOException {
  final SelectionKey keyLocal = key;
  final SelectionKeyHandler selectionKeyHandler = transport.getSelectionKeyHandler();
  final IOStrategy ioStrategy = transport.getIOStrategy();
  final IOEvent[] ioEvents = selectionKeyHandler.getIOEvents(keyReadyOps);
  final NIOConnection connection =
      selectionKeyHandler.getConnectionForKey(keyLocal);
  for (IOEvent ioEvent : ioEvents) {
    NIOConnection.notifyIOEventReady(connection, ioEvent);
    
    final int interest = ioEvent.getSelectionKeyInterest();
    keyReadyOps &= (~interest);
    if (selectionKeyHandler.onProcessInterest(keyLocal, interest)) {
      if (!ioStrategy.executeIoEvent(connection, ioEvent)) {
        return false;
      }
    }
  }
  return true;
}
origin: org.glassfish.grizzly/grizzly-http-server-core

protected final void switchToNewSelector() throws IOException {
  final Selector oldSelector = selector;
  final Selector newSelector = Selectors.newSelector(transport.getSelectorProvider());
  final Set<SelectionKey> keys = oldSelector.keys();
  final SelectionKeyHandler selectionKeyHandler =
      transport.getSelectionKeyHandler();
  
  for (final SelectionKey selectionKey : keys) {
    if (selectionKey.isValid()) {
      try {
        final NIOConnection nioConnection =
            selectionKeyHandler.getConnectionForKey(selectionKey);
        final SelectionKey newSelectionKey =
            selectionKey.channel().register(newSelector,
            selectionKey.interestOps(), selectionKey.attachment());
        nioConnection.onSelectionKeyUpdated(newSelectionKey);
      } catch (Exception e) {
        LOGGER.log(Level.FINE, "Error switching channel to a new selector", e);
      }
    }
  }
  setSelector(newSelector);
  try {
    oldSelector.close();
  } catch (Exception ignored) {
  }
}
origin: javaee/grizzly

selectorRunner.getTransport().getSelectionKeyHandler().cancel(key);
    onKeyDeregistered(key);
origin: javaee/grizzly

try {
  final Connection connection =
      transport.getSelectionKeyHandler().getConnectionForKey(key);
  } else {
    final SelectableChannel channel = key.channel();
    transport.getSelectionKeyHandler().cancel(key);
    channel.close();
origin: javaee/grizzly

onKeyRegistered(registeredSelectionKey);
origin: javaee/grizzly

private boolean iterateKeyEvents()
    throws IOException {
  final SelectionKey keyLocal = key;
  final SelectionKeyHandler selectionKeyHandler = transport.getSelectionKeyHandler();
  final IOStrategy ioStrategy = transport.getIOStrategy();
  final IOEvent[] ioEvents = selectionKeyHandler.getIOEvents(keyReadyOps);
  final NIOConnection connection =
      selectionKeyHandler.getConnectionForKey(keyLocal);
  for (IOEvent ioEvent : ioEvents) {
    NIOConnection.notifyIOEventReady(connection, ioEvent);
    
    final int interest = ioEvent.getSelectionKeyInterest();
    keyReadyOps &= (~interest);
    if (selectionKeyHandler.onProcessInterest(keyLocal, interest)) {
      if (!ioStrategy.executeIoEvent(connection, ioEvent)) {
        return false;
      }
    }
  }
  return true;
}
origin: javaee/grizzly

protected final void switchToNewSelector() throws IOException {
  final Selector oldSelector = selector;
  final Selector newSelector = Selectors.newSelector(transport.getSelectorProvider());
  final Set<SelectionKey> keys = oldSelector.keys();
  final SelectionKeyHandler selectionKeyHandler =
      transport.getSelectionKeyHandler();
  
  for (final SelectionKey selectionKey : keys) {
    if (selectionKey.isValid()) {
      try {
        final NIOConnection nioConnection =
            selectionKeyHandler.getConnectionForKey(selectionKey);
        final SelectionKey newSelectionKey =
            selectionKey.channel().register(newSelector,
            selectionKey.interestOps(), selectionKey.attachment());
        nioConnection.onSelectionKeyUpdated(newSelectionKey);
      } catch (Exception e) {
        LOGGER.log(Level.FINE, "Error switching channel to a new selector", e);
      }
    }
  }
  setSelector(newSelector);
  try {
    oldSelector.close();
  } catch (Exception ignored) {
  }
}
origin: javaee/grizzly

selectorRunner.getTransport().getSelectionKeyHandler().cancel(key);
    onKeyDeregistered(key);
origin: javaee/grizzly

try {
  final Connection connection =
      transport.getSelectionKeyHandler().getConnectionForKey(key);
  } else {
    final SelectableChannel channel = key.channel();
    transport.getSelectionKeyHandler().cancel(key);
    channel.close();
origin: javaee/grizzly

onKeyRegistered(registeredSelectionKey);
origin: javaee/grizzly

private boolean iterateKeyEvents()
    throws IOException {
  final SelectionKey keyLocal = key;
  final SelectionKeyHandler selectionKeyHandler = transport.getSelectionKeyHandler();
  final IOStrategy ioStrategy = transport.getIOStrategy();
  final IOEvent[] ioEvents = selectionKeyHandler.getIOEvents(keyReadyOps);
  final NIOConnection connection =
      selectionKeyHandler.getConnectionForKey(keyLocal);
  for (IOEvent ioEvent : ioEvents) {
    NIOConnection.notifyIOEventReady(connection, ioEvent);
    
    final int interest = ioEvent.getSelectionKeyInterest();
    keyReadyOps &= (~interest);
    if (selectionKeyHandler.onProcessInterest(keyLocal, interest)) {
      if (!ioStrategy.executeIoEvent(connection, ioEvent)) {
        return false;
      }
    }
  }
  return true;
}
origin: javaee/grizzly

  @Override
  public void completed(RegisterChannelResult result) {
    final TCPNIOTransport transport =
        (TCPNIOTransport) TCPNIOConnectorHandler.this.transport;
    transport.selectorRegistrationHandler.completed(result);
    final SelectionKey selectionKey = result.getSelectionKey();
    final SelectionKeyHandler selectionKeyHandler = transport.getSelectionKeyHandler();
    final TCPNIOConnection connection =
        (TCPNIOConnection) selectionKeyHandler.getConnectionForKey(selectionKey);
    try {
      connection.onConnect();
    } catch (Exception e) {
      LOGGER.log(Level.FINE, "Exception happened, when "
          + "trying to connect the channel", e);
    }
  }
}
org.glassfish.grizzly.nioSelectionKeyHandler

Javadoc

SelectionKeyHandler implementations are responsible for handling SelectionKey life cycle events.

Most used methods

  • cancel
  • getConnectionForKey
  • getIOEvents
  • onKeyDeregistered
  • onKeyRegistered
  • onProcessInterest

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JLabel (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now