# AbstractService (sshj 0.4.1 API)
Date: 2011-06-19

## net.schmizz.sshj
Class AbstractService

    java.lang.Object
      net.schmizz.sshj.AbstractService

All Implemented Interfaces:
  ErrorNotifiable, SSHPacketHandler, Service

Direct Known Subclasses:
  ConnectionImpl, UserAuthImpl

    public abstract class AbstractService

extends Object
implements Service

An abstract class for `Service` that implements common or default functionality.

Nested Class Summary

Nested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
`ErrorNotifiable.Util`

Field Summary
`protected org.slf4j.Logger` `log` Logger
`protected String` `name` Assigned name of this service
`protected int` `timeout` Timeout for blocking operations
`protected Transport` `trans` Transport layer

Constructor Summary
`AbstractService(String name, Transport trans)`

Method Summary
`String` `getName()`
`int` `getTimeout()`
`void` `handle(Message msg, SSHPacket buf)` Delegate handling of some SSH packet to this object.
`void` `notifyError(SSHException error)` Notifies this object of an `error`.
`void` `notifyUnimplemented(long seqNum)` Notifies this service that a `SSH_MSG_UNIMPLEMENTED` was received for packet with given sequence number.
`void` `request()` Request and install this service with the associated transport.
`void` `setTimeout(int timeout)`

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

Field Detail

### log

    protected final org.slf4j.Logger log

  Logger

### name

    protected final String name

  Assigned name of this service

### trans

    protected final Transport trans

  Transport layer

### timeout

    protected int timeout

  Timeout for blocking operations

Constructor Detail

### AbstractService

    public AbstractService(String name,
                           Transport trans)

Method Detail

### getName

    public String getName()

  Specified by:
    `getName` in interface `Service`
  Returns:
    the assigned name for this SSH service.

### handle

    public void handle(Message msg,
                       SSHPacket buf)
                throws SSHException

  Description copied from interface: `SSHPacketHandler`
  Delegate handling of some SSH packet to this object.

  Specified by:
    `handle` in interface `SSHPacketHandler`
  Parameters:
    `msg` - the SSH `message identifier`
    `buf` - `SSHPacket` containing rest of the request
  Throws:
    `SSHException` - if there is a non-recoverable error

### notifyError

    public void notifyError(SSHException error)

  Description copied from interface: `ErrorNotifiable`
  Notifies this object of an `error`.

  Specified by:
    `notifyError` in interface `ErrorNotifiable`

### notifyUnimplemented

    public void notifyUnimplemented(long seqNum)
                             throws SSHException

  Description copied from interface: `Service`
  Notifies this service that a `SSH_MSG_UNIMPLEMENTED` was received for packet with given sequence number. Meant to be invoked as a callback by the transport layer.

  Specified by:
    `notifyUnimplemented` in interface `Service`
  Parameters:
    `seqNum` - sequence number of the packet which the server claims is unimplemented
  Throws:
    `SSHException` - if the packet is unexpected and may represent a disruption

### request

    public void request()
                 throws TransportException

  Description copied from interface: `Service`
  Request and install this service with the associated transport. Implementations should aim to make this method idempotent by first checking the `Transport.getService()` currently active service}.

  Specified by:
    `request` in interface `Service`
  Throws:
    `TransportException` - if there is an error sending the service request

### getTimeout

    public int getTimeout()

### setTimeout

    public void setTimeout(int timeout)

Copyright © 2009-2011. All Rights Reserved.