AsynchToSynchChannelServerAdapter (ActiveIO 1.0 API)
Keywords: org.activeio.adapter.AsynchToSynchChannelServerAdapter class

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

## org.activeio.adapter
Class AsynchToSynchChannelServerAdapter

    java.lang.Object
      org.activeio.adapter.AsynchToSynchChannelServerAdapter

All Implemented Interfaces:
  AcceptListener, Channel, ChannelServer, Disposable, Service, SynchChannelServer

public final class AsynchToSynchChannelServerAdapter
extends java.lang.Object
implements SynchChannelServer, AcceptListener

Adapts a `AsynchChannelServer` so that it provides an `SynchChannelServer` interface. This object buffers asynchronous accepts from the `AsynchChannelServer` abs buffers them in a `Channel` util the client accepts the connection.

Version:
  $Revision$

Field Summary

Fields inherited from interface org.activeio.SynchChannelServer
`NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT`

Constructor Summary
`AsynchToSynchChannelServerAdapter(AsynchChannelServer asynchChannelServer)` Deprecated. `adapt(ChannelServer)`
`AsynchToSynchChannelServerAdapter(AsynchChannelServer asynchChannelServer, EDU.oswego.cs.dl.util.concurrent.Channel acceptBuffer)` Deprecated. `adapt(ChannelServer, EDU.oswego.cs.dl.util.concurrent.Channel)`

Method Summary
`Channel` | `accept(long timeout)`
`static SynchChannelServer` | `adapt(ChannelServer channel)`
`static SynchChannelServer` | `adapt(ChannelServer channel, EDU.oswego.cs.dl.util.concurrent.Channel upPacketChannel)`
`void` | `dispose()` This method should not throw any exceptions.
`AsynchChannelServer` | `getAsynchChannelServer()`
`java.net.URI` | `getBindURI()` The URI that was used when the channel was bound.
`java.net.URI` | `getConnectURI()` Once bound, the channel may be able to construct a URI that is more sutible for when a client needs to connect to the server.
`java.lang.Object` | `narrow(java.lang.Class target)` Since a Channel may be composed from a chain of other Channel obejcts, this method allows you to query the chain for the specified interface.
`void` | `onAccept(Channel channel)` A `AsynchChannelServer` will call this method to when a new channel connection has been accepted.
`void` | `onAcceptError(java.io.IOException error)` A `AsynchChannelServer` will call this method when a async failure occurs when accepting a connection.
`void` | `start()` Starts the channel.
`void` | `stop(long timeout)` Stops the channel.
`java.lang.String` | `toString()`

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

Constructor Detail

### AsynchToSynchChannelServerAdapter

    public AsynchToSynchChannelServerAdapter(AsynchChannelServer asynchChannelServer)

  Deprecated. `adapt(ChannelServer)`

### AsynchToSynchChannelServerAdapter

    public AsynchToSynchChannelServerAdapter(AsynchChannelServer asynchChannelServer,
                                             EDU.oswego.cs.dl.util.concurrent.Channel acceptBuffer)

  Deprecated. `adapt(ChannelServer, EDU.oswego.cs.dl.util.concurrent.Channel)`

Method Detail

### adapt

    public static SynchChannelServer adapt(ChannelServer channel)

### adapt

    public static SynchChannelServer adapt(ChannelServer channel,
                                           EDU.oswego.cs.dl.util.concurrent.Channel upPacketChannel)

### accept

    public Channel accept(long timeout)
                   throws java.io.IOException

  Specified by:
    `accept` in interface `SynchChannelServer`
  Throws:
    `java.io.IOException`
  See Also:
    `SynchChannelServer.accept(long)`

### dispose

    public void dispose()

  Description copied from interface: `Disposable`
  This method should not throw any exceptions. Cleaning up a Disposable object should be easy of an end user therefore do not make him have to handle an Exception.

  Specified by:
    `dispose` in interface `Disposable`
  See Also:
    `Disposable.dispose()`

### start

    public void start()
               throws java.io.IOException

  Description copied from interface: `Service`
  Starts the channel. Once started, the channel is in the running state.

  Specified by:
    `start` in interface `Service`
  Throws:
    `java.io.IOException`
  See Also:
    `Service.start()`

### stop

    public void stop(long timeout)
              throws java.io.IOException

  Description copied from interface: `Service`
  Stops the channel. Once stopped, the channel is in the stopped state.

  Specified by:
    `stop` in interface `Service`
  Parameters:
    `timeout` - The amount of time the channel is allowed to take to gracefully stop. If the timeout is exceeded, the channel should do a forcefull stop.
  Throws:
    `java.io.IOException`
  See Also:
    `Service.stop(long)`

### getBindURI

    public java.net.URI getBindURI()

  Description copied from interface: `ChannelServer`
  The URI that was used when the channel was bound. This could be different than what is used by a client to connect to the ChannelServer. For example, the bind URI might be tcp://localhost:0 which means the channel should bind to an anonymous port.

  Specified by:
    `getBindURI` in interface `ChannelServer`
  Returns:
    The URI that was used when the channel was bound

### getConnectURI

    public java.net.URI getConnectURI()

  Description copied from interface: `ChannelServer`
  Once bound, the channel may be able to construct a URI that is more sutible for when a client needs to connect to the server. For examle the port of the URI may be updated to reflect the actual local port that the channel server is listening on.

  Specified by:
    `getConnectURI` in interface `ChannelServer`
  Returns:
    a URI that a client can use to connect to the server or null if the channel cannot construct the URI.

### onAccept

    public void onAccept(Channel channel)

  Description copied from interface: `AcceptListener`
  A `AsynchChannelServer` will call this method to when a new channel connection has been accepted.

  Specified by:
    `onAccept` in interface `AcceptListener`
  See Also:
    `AcceptListener.onAccept(org.activeio.Channel)`

### onAcceptError

    public void onAcceptError(java.io.IOException error)

  Description copied from interface: `AcceptListener`
  A `AsynchChannelServer` will call this method when a async failure occurs when accepting a connection.

  Specified by:
    `onAcceptError` in interface `AcceptListener`
  Parameters:
    `error` - the exception that describes the failure.
  See Also:
    `AcceptListener.onAcceptError(java.io.IOException)`

### getAsynchChannelServer

    public AsynchChannelServer getAsynchChannelServer()

### narrow

    public java.lang.Object narrow(java.lang.Class target)

  Description copied from interface: `Channel`
  Since a Channel may be composed from a chain of other Channel obejcts, this method allows you to query the chain for the specified interface. The first Channel in the chain the implments the requested interface will be return an implementing object. If no Channel in the chain implements the requested class, then null is returned.

  Specified by:
    `narrow` in interface `Channel`

### toString

    public java.lang.String toString()

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

Copyright © -2005 The ActiveIO Project. All Rights Reserved.