Code example for SelectionKey

Methods: attachattachment

0
		ChannelProcessor channelProcessor = (ChannelProcessor) key.attachment();
		channelProcessor.close(key);
	} 
 
	public void clear() { 
		ChannelProcessor channelProcessor = (ChannelProcessor) key.attachment();
		if (channelProcessor instanceof ClearableChannelProcessor) {
			((ClearableChannelProcessor) channelProcessor).clear(key);
		} 
	} 
 
	public void change(ChannelProcessor processor) {
		clear(); 
		key.attach(processor);
	} 
 
	public SelectionKey getKey() {
		return key;
	} 
}