Java Doc for AbstractSelector.java in  » 6.0-JDK-Core » io-nio » java » nio » channels » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » io nio » java.nio.channels.spi 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.nio.channels.Selector
      java.nio.channels.spi.AbstractSelector

AbstractSelector
abstract public class AbstractSelector extends Selector (Code)
Base implementation class for selectors.

This class encapsulates the low-level machinery required to implement the interruption of selection operations. A concrete selector class must invoke the AbstractSelector.begin begin and AbstractSelector.end end methods before and after, respectively, invoking an I/O operation that might block indefinitely. In order to ensure that the AbstractSelector.end end method is always invoked, these methods should be used within a try ... finally block:

 try {
 begin();
 // Perform blocking I/O operation here
 ...
 } finally {
 end();
 }

This class also defines methods for maintaining a selector's cancelled-key set and for removing a key from its channel's key set, and declares the abstract AbstractSelector.register register method that is invoked by a selectable channel's AbstractSelectableChannel.register register method in order to perform the actual work of registering a channel.


author:
   Mark Reinhold
author:
   JSR-51 Expert Group
version:
   1.27, 07/05/05
since:
   1.4



Constructor Summary
protected  AbstractSelector(SelectorProvider provider)
     Initializes a new instance of this class.

Method Summary
final protected  voidbegin()
     Marks the beginning of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the AbstractSelector.end end method, using a try ... finally block as shown above, in order to implement interruption for this selector.

Invoking this method arranges for the selector's Selector.wakeup wakeup method to be invoked if a thread's Thread.interrupt interrupt method is invoked while the thread is blocked in an I/O operation upon the selector.

 voidcancel(SelectionKey k)
    
final protected  Set<SelectionKey>cancelledKeys()
     Retrieves this selector's cancelled-key set.

This set should only be used while synchronized upon it.

final public  voidclose()
     Closes this selector.

If the selector has already been closed then this method returns immediately.

final protected  voidderegister(AbstractSelectionKey key)
     Removes the given key from its channel's key set.

This method must be invoked by the selector for each channel that it deregisters.

final protected  voidend()
     Marks the end of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the AbstractSelector.begin begin method, using a try ... finally block as shown above, in order to implement interruption for this selector.

abstract protected  voidimplCloseSelector()
     Closes this selector.

This method is invoked by the AbstractSelector.close close method in order to perform the actual work of closing the selector.

final public  booleanisOpen()
    
final public  SelectorProviderprovider()
     Returns the provider that created this channel.
abstract protected  SelectionKeyregister(AbstractSelectableChannel ch, int ops, Object att)
     Registers the given channel with this selector.

This method is invoked by a channel's AbstractSelectableChannel.register register method in order to perform the actual work of registering the channel with this selector.



Constructor Detail
AbstractSelector
protected AbstractSelector(SelectorProvider provider)(Code)
Initializes a new instance of this class.





Method Detail
begin
final protected void begin()(Code)
Marks the beginning of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the AbstractSelector.end end method, using a try ... finally block as shown above, in order to implement interruption for this selector.

Invoking this method arranges for the selector's Selector.wakeup wakeup method to be invoked if a thread's Thread.interrupt interrupt method is invoked while the thread is blocked in an I/O operation upon the selector.




cancel
void cancel(SelectionKey k)(Code)



cancelledKeys
final protected Set<SelectionKey> cancelledKeys()(Code)
Retrieves this selector's cancelled-key set.

This set should only be used while synchronized upon it.

The cancelled-key set



close
final public void close() throws IOException(Code)
Closes this selector.

If the selector has already been closed then this method returns immediately. Otherwise it marks the selector as closed and then invokes the AbstractSelector.implCloseSelector implCloseSelector method in order to complete the close operation.


throws:
  IOException - If an I/O error occurs



deregister
final protected void deregister(AbstractSelectionKey key)(Code)
Removes the given key from its channel's key set.

This method must be invoked by the selector for each channel that it deregisters.


Parameters:
  key - The selection key to be removed



end
final protected void end()(Code)
Marks the end of an I/O operation that might block indefinitely.

This method should be invoked in tandem with the AbstractSelector.begin begin method, using a try ... finally block as shown above, in order to implement interruption for this selector.




implCloseSelector
abstract protected void implCloseSelector() throws IOException(Code)
Closes this selector.

This method is invoked by the AbstractSelector.close close method in order to perform the actual work of closing the selector. This method is only invoked if the selector has not yet been closed, and it is never invoked more than once.

An implementation of this method must arrange for any other thread that is blocked in a selection operation upon this selector to return immediately as if by invoking the java.nio.channels.Selector.wakeup wakeup method.


throws:
  IOException - If an I/O error occurs while closing the selector



isOpen
final public boolean isOpen()(Code)



provider
final public SelectorProvider provider()(Code)
Returns the provider that created this channel. The provider that created this channel



register
abstract protected SelectionKey register(AbstractSelectableChannel ch, int ops, Object att)(Code)
Registers the given channel with this selector.

This method is invoked by a channel's AbstractSelectableChannel.register register method in order to perform the actual work of registering the channel with this selector.


Parameters:
  ch - The channel to be registered
Parameters:
  ops - The initial interest set, which must be valid
Parameters:
  att - The initial attachment for the resulting key A new key representing the registration of the given channelwith this selector



Methods inherited from java.nio.channels.Selector
abstract public void close() throws IOException(Code)(Java Doc)
abstract public boolean isOpen()(Code)(Java Doc)
abstract public Set<SelectionKey> keys()(Code)(Java Doc)
public static Selector open() throws IOException(Code)(Java Doc)
abstract public SelectorProvider provider()(Code)(Java Doc)
abstract public int select(long timeout) throws IOException(Code)(Java Doc)
abstract public int select() throws IOException(Code)(Java Doc)
abstract public int selectNow() throws IOException(Code)(Java Doc)
abstract public Set<SelectionKey> selectedKeys()(Code)(Java Doc)
abstract public Selector wakeup()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.