Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.connecterra.ale.reader
Class DeviceChannel.AbstractOpenChannel

    java.lang.Object
      com.connecterra.ale.reader.DeviceChannel.AbstractOpenChannel

Enclosing class:
  DeviceChannel

    protected abstract class DeviceChannel.AbstractOpenChannel

extends Object

An instance of this class should be instantiated and returned by the channel when the channel is opened. If the channel accepts asynchronous input, it should invoke any callbacks by using this class's `DeviceChannel.AbstractOpenChannel.listenerExecute(java.lang.Runnable)` method when such data is available. This will ensure that the work is correctly passed to the associated ChannelManager's proxy, and ensure that stale input does not cause callback invocations after the channel has been closed.

Constructor Summary
`protected` | `DeviceChannel.AbstractOpenChannel()`

Method Summary
`protected void` | `listenerExecute(Runnable r)` Execute some driver business logic (represented by the Runnable) using the associated ChannelManager's proxy.
`protected abstract void` | `resumeListener()` Resume the blocking thread.
`protected abstract boolean` | `suspendListener()` This method should do whatever is necessary to ensure that the asynchronous input is ignored until resumeListener() is called.
`protected abstract void` | `terminate()` Makes a best-effort attempt to drop resources in use by the channel.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DeviceChannel.AbstractOpenChannel

    protected DeviceChannel.AbstractOpenChannel()

Method Detail

### terminate

    protected abstract void terminate()

  Makes a best-effort attempt to drop resources in use by the channel. It should also do what it needs to do as quickly as possible, and not take extra time or locks to keep state completely consistent. This method is separate from `close` because it may be invoked even while another thread is running a method on this object, so the implementation must take care if `close` and `terminate` are called at the same time.

### suspendListener

    protected abstract boolean suspendListener()

  This method should do whatever is necessary to ensure that the asynchronous input is ignored until resumeListener() is called. Without this, the condition could be noted repeatedly by the listener, and {ChannelManager.Proxy#listenerExecute} invoked repeatedly (for example, when a callback writes to a socket and reading the response, listenerExecute could be invoked unnecessarily when the response arrives at the socket. This method may be invoked even when another thread is running on the channel, because it will generally be called from a listener thread which is waiting for asynchronous I/O. Because of this, `close` can be called concurrently; if this happens and is detected, it should return false to indicate the channel has been closed.

  Returns:
    false if the blocking thread is no longer valid because the channel has been closed.

### resumeListener

    protected abstract void resumeListener()
                                    throws IOException

  Resume the blocking thread. This must undo whatever `DeviceChannel.AbstractOpenChannel.suspendListener()` did. Unlike that method, however, the implementation does not need to be reentrant.

  Throws:
    `IOException`

### listenerExecute

    protected void listenerExecute(Runnable r)

  Execute some driver business logic (represented by the Runnable) using the associated ChannelManager's proxy. This method may be called from any thread.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at ${DOCSWEBROOT} Copyright 2007 BEA Systems Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD