org.apache.sling.bgservlets.impl

## Class SuspendableOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - org.apache.sling.bgservlets.impl.SuspendableOutputStream

All Implemented Interfaces:
  Closeable, Flushable, AutoCloseable, JobStatus

    public class SuspendableOutputStream
    extends FilterOutputStream
    implements JobStatus

Wraps an OutputStream with controls for suspending it or throwing an IOException next time it is written to. Used to suspend background servlets (by blocking the stream) or stop them (by throwing an exception).

### Nested Class Summary

Nested Classes
`static class` `SuspendableOutputStream.StreamStoppedException`

### Nested classes/interfaces inherited from interface org.apache.sling.bgservlets.JobStatus

`JobStatus.State`

### Field Summary

### Fields inherited from class java.io.FilterOutputStream

`out`

### Fields inherited from interface org.apache.sling.bgservlets.JobStatus

`STREAM_PATH_SUFFIX`

### Constructor Summary

Constructors
Constructor and Description
`SuspendableOutputStream(OutputStream os)`

### Method Summary

Methods
`void` `close()`
`JobStatus.State[]` `getAllowedHumanStateChanges()` Indicate which state changes a human user can currently request, based on our state.
`Date` `getCreationTime()` Not implemented
`String` `getPath()` Not implemented
`JobProgressInfo` `getProgressInfo()` Not implemented
`JobStatus.State` `getState()` Return the job's current state
`String` `getStreamPath()` Not implemented
`void` `requestStateChange(JobStatus.State s)` Only SUSPENDED, STOP, and RUNNING make sense here
`void` `write(byte[] b)`
`void` `write(byte[] b, int off, int len)`
`void` `write(int b)`

### Methods inherited from class java.io.FilterOutputStream

`flush`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SuspendableOutputStream

    public SuspendableOutputStream(OutputStream os)

### Method Detail

#### write

    public void write(byte[] b,
             int off,
             int len)
               throws IOException

Overrides:
  `write` in class `FilterOutputStream`
Throws:
  `IOException`

#### write

    public void write(byte[] b)
               throws IOException

Overrides:
  `write` in class `FilterOutputStream`
Throws:
  `IOException`

#### write

    public void write(int b)
               throws IOException

Overrides:
  `write` in class `FilterOutputStream`
Throws:
  `IOException`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Overrides:
  `close` in class `FilterOutputStream`
Throws:
  `IOException`

#### getState

    public JobStatus.State getState()

Description copied from interface: `JobStatus`
Return the job's current state

Specified by:
  `getState` in interface `JobStatus`

#### requestStateChange

    public void requestStateChange(JobStatus.State s)

Only SUSPENDED, STOP, and RUNNING make sense here

Specified by:
  `requestStateChange` in interface `JobStatus`

#### getAllowedHumanStateChanges

    public JobStatus.State[] getAllowedHumanStateChanges()

Description copied from interface: `JobStatus`
Indicate which state changes a human user can currently request, based on our state. For a human user, the only states that make sense to be requested are RUNNING, SUSPENDED and STOPPED, or a subset of those based on current state.

Specified by:
  `getAllowedHumanStateChanges` in interface `JobStatus`
Returns:
  empty array if no state change allowed

#### getPath

    public String getPath()

Not implemented

Specified by:
  `getPath` in interface `JobStatus`
Throws:
  `UnsupportedOperationException`

#### getStreamPath

    public String getStreamPath()

Not implemented

Specified by:
  `getStreamPath` in interface `JobStatus`
Throws:
  `UnsupportedOperationException`

#### getCreationTime

    public Date getCreationTime()

Not implemented

Specified by:
  `getCreationTime` in interface `JobStatus`
Throws:
  `UnsupportedOperationException`

#### getProgressInfo

    public JobProgressInfo getProgressInfo()

Not implemented

Specified by:
  `getProgressInfo` in interface `JobStatus`
Throws:
  `UnsupportedOperationException`