Java Doc for AbstractInterruptibleChannel.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.spi.AbstractInterruptibleChannel

All known Subclasses:   java.nio.channels.SelectableChannel,  java.nio.channels.FileChannel,
AbstractInterruptibleChannel
abstract public class AbstractInterruptibleChannel implements Channel,InterruptibleChannel(Code)
Base implementation class for interruptible channels.

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

 boolean completed = false;
 try {
 begin();
 completed = ...;    // Perform blocking I/O operation
 return ...;         // Return result
 } finally {
 end(completed);
 }

The completed argument to the AbstractInterruptibleChannel.end end method tells whether or not the I/O operation actually completed, that is, whether it had any effect that would be visible to the invoker. In the case of an operation that reads bytes, for example, this argument should be true if, and only if, some bytes were actually transferred into the invoker's target buffer.

A concrete channel class must also implement the AbstractInterruptibleChannel.implCloseChannel implCloseChannel method in such a way that if it is invoked while another thread is blocked in a native I/O operation upon the channel then that operation will immediately return, either by throwing an exception or by returning normally. If a thread is interrupted or the channel upon which it is blocked is asynchronously closed then the channel's AbstractInterruptibleChannel.end end method will throw the appropriate exception.

This class performs the synchronization required to implement the java.nio.channels.Channel specification. Implementations of the AbstractInterruptibleChannel.implCloseChannel implCloseChannel method need not synchronize against other threads that might be attempting to close the channel.


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



Constructor Summary
protected  AbstractInterruptibleChannel()
     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 AbstractInterruptibleChannel.end end method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.

static  voidblockedOn(Interruptible intr)
    
final public  voidclose()
     Closes this channel.

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

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

This method should be invoked in tandem with the AbstractInterruptibleChannel.beginbegin method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.

abstract protected  voidimplCloseChannel()
     Closes this channel.

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

final public  booleanisOpen()
    


Constructor Detail
AbstractInterruptibleChannel
protected AbstractInterruptibleChannel()(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 AbstractInterruptibleChannel.end end method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.




blockedOn
static void blockedOn(Interruptible intr)(Code)



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

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


throws:
  IOException - If an I/O error occurs



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

This method should be invoked in tandem with the AbstractInterruptibleChannel.beginbegin method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.


Parameters:
  completed - true if, and only if, the I/O operation completedsuccessfully, that is, had some effect that would be visible tothe operation's invoker
throws:
  AsynchronousCloseException - If the channel was asynchronously closed
throws:
  ClosedByInterruptException - If the thread blocked in the I/O operation was interrupted



implCloseChannel
abstract protected void implCloseChannel() throws IOException(Code)
Closes this channel.

This method is invoked by the AbstractInterruptibleChannel.close close method in order to perform the actual work of closing the channel. This method is only invoked if the channel 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 an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.


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



isOpen
final public boolean isOpen()(Code)



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.