Top Description Inners Fields Constructors Methods
org.apache.sshd.common.util.closeable

public abstract Class AbstractCloseable

extends IoBaseCloseable
Class Inheritance
Known Direct Subclasses
org.apache.sshd.common.util.closeable.AbstractInnerCloseable, org.apache.sshd.common.util.threads.SshThreadPoolExecutor.DelegateCloseable
Imports
java.util.concurrent.atomic.AtomicReference, org.apache.sshd.common.future.CloseFuture, .DefaultCloseFuture, .SshFuture, .SshFutureListener

Provides some default implementations for managing channel/connection open/close state
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
protected final CloseFuture
closeFuture

A future that will be set 'closed' when the object is actually closed

protected final Object
futureLock

Lock object for Future-s based on this closeable instance

protected final AtomicReference<AbstractCloseable.State>
state

State of this object

Constructor Summary

AccessConstructor and Description
protected
protected
AbstractCloseable(String discriminator)

Method Summary

Modifier and TypeMethod and Description
public void
addCloseFutureListener(SshFutureListener<CloseFuture>
The notification SshFutureListener - never null
listener
)

Implements org.apache.sshd.common.Closeable.addCloseFutureListener.

Pre-register a listener to be informed when resource is closed.

protected Builder
public final CloseFuture
close(boolean
true if the resource should be shut down abruptly, false for a graceful close
immediately
)

Implements org.apache.sshd.common.Closeable.close.

Close this resource asynchronously and return a future.

protected CloseFuture
protected void
doCloseImmediately()

doCloseImmediately is called once and only once with state == Immediate Overriding methods should always call the base implementation.

public Object
public final boolean
isClosed()

Implements org.apache.sshd.common.Closeable.isClosed.

Returns true if this object has been closed.

public final boolean
isClosing()

Implements org.apache.sshd.common.Closeable.isClosing.

Returns true if the close(boolean) method has been called.

protected void
preClose()

preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.

public void
removeCloseFutureListener(SshFutureListener<CloseFuture>
The register SshFutureListener - never null. Ignored if not registered or resource already closed
listener
)

Implements org.apache.sshd.common.Closeable.removeCloseFutureListener.

Remove a pre-registered close event listener

Field Detail

closeFutureback to summary
protected final CloseFuture closeFuture

A future that will be set 'closed' when the object is actually closed

futureLockback to summary
protected final Object futureLock

Lock object for Future-s based on this closeable instance

stateback to summary
protected final AtomicReference<AbstractCloseable.State> state

State of this object

Constructor Detail

AbstractCloseableback to summary
protected AbstractCloseable()
AbstractCloseableback to summary
protected AbstractCloseable(String discriminator)

Method Detail

addCloseFutureListenerback to summary
public void addCloseFutureListener(SshFutureListener<CloseFuture> listener)

Implements org.apache.sshd.common.Closeable.addCloseFutureListener.

Doc from org.apache.sshd.common.Closeable.addCloseFutureListener.

Pre-register a listener to be informed when resource is closed. If resource is already closed, the listener will be invoked immediately and not registered for future notification

Parameters
listener:SshFutureListener<CloseFuture>

The notification SshFutureListener - never null

Annotations
@Override
builderback to summary
protected Builder builder()
closeback to summary
public final CloseFuture close(boolean immediately)

Implements org.apache.sshd.common.Closeable.close.

Doc from org.apache.sshd.common.Closeable.close.

Close this resource asynchronously and return a future. Resources support two closing modes: a graceful mode which will cleanly close the resource and an immediate mode which will close the resources abruptly.

Parameters
immediately:boolean

true if the resource should be shut down abruptly, false for a graceful close

Returns:CloseFuture

a CloseFuture representing the close request

Annotations
@Override
doCloseGracefullyback to summary
protected CloseFuture doCloseGracefully()
doCloseImmediatelyback to summary
protected void doCloseImmediately()

doCloseImmediately is called once and only once with state == Immediate Overriding methods should always call the base implementation. It may be called concurrently while preClose() or doCloseGracefully is executing

getFutureLockback to summary
public Object getFutureLock()
isClosedback to summary
public final boolean isClosed()

Implements org.apache.sshd.common.Closeable.isClosed.

Doc from org.apache.sshd.common.Closeable.isClosed.

Returns true if this object has been closed.

Returns:boolean

true if closing

Annotations
@Override
isClosingback to summary
public final boolean isClosing()

Implements org.apache.sshd.common.Closeable.isClosing.

Doc from org.apache.sshd.common.Closeable.isClosing.

Returns true if the close(boolean) method has been called. Note that this method will return true even if this isClosed() returns true.

Returns:boolean

true if closing

Annotations
@Override
preCloseback to summary
protected void preClose()

preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true

removeCloseFutureListenerback to summary
public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener)

Implements org.apache.sshd.common.Closeable.removeCloseFutureListener.

Doc from org.apache.sshd.common.Closeable.removeCloseFutureListener.

Remove a pre-registered close event listener

Parameters
listener:SshFutureListener<CloseFuture>

The register SshFutureListener - never null. Ignored if not registered or resource already closed

Annotations
@Override
org.apache.sshd.common.util.closeable back to summary

public final Enum AbstractCloseable.State

extends Enum<AbstractCloseable.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final AbstractCloseable.State
Closed

Connection is closed

public static final AbstractCloseable.State
Graceful

Connection is being closed gracefully

public static final AbstractCloseable.State
Immediate

Connection is being terminated immediately

public static final AbstractCloseable.State
Opened

Connection is open

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractCloseable.State
public static AbstractCloseable.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Closedback to summary
public static final AbstractCloseable.State Closed

Connection is closed

Gracefulback to summary
public static final AbstractCloseable.State Graceful

Connection is being closed gracefully

Immediateback to summary
public static final AbstractCloseable.State Immediate

Connection is being terminated immediately

Openedback to summary
public static final AbstractCloseable.State Opened

Connection is open

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static AbstractCloseable.State valueOf(String name)
valuesback to summary
public static AbstractCloseable.State[] values()