Class ServerInputStream
- java.lang.Object
-
- de.aristaflow.adept2.model.common.communication.ServerInputStream
-
- All Implemented Interfaces:
ServerStream
,de.aristaflow.adept2.model.communication.ServerSideProxy
,de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
,Closeable
,AutoCloseable
- Direct Known Subclasses:
ServerUDTInputStream
public class ServerInputStream extends Object implements ServerStream
This is a simple wrapper for anInputStream
asServerStream
which allows for keeping anInputStream
locally and use it remotely.
-
-
Field Summary
Fields Modifier and Type Field Description protected long
aliveTimeExtension
The time in milliseconds the alive time is extended when accessing this stream.protected Map<Thread,AtomicInteger>
busyThreads
The threads which are currently accessing this server-side proxy (and and how often).protected Cleanup<IOException>
cleanup
The clean-up for closing the wrapped input stream as post-mortem action of thisServerInputStream
.
-
Constructor Summary
Constructors Constructor Description ServerInputStream(InputStream in)
Deprecated, for removal: This API element is subject to removal in a future version.UseServerInputStream(InputStream, long, long)
instead.ServerInputStream(InputStream in, long initialAliveTime, long aliveTimeExtension)
Creates a newServerInputStream
providing the content of the designated stream incrementally on client side.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
InputStream.close()
This additionally removes the skeleton in the communication framework.long
getCloseTime()
boolean
isBusy()
void
mark(int readlimit)
boolean
markSupported()
int
read()
byte[]
read(int len)
ResemblesInputStream.read(byte[])
by reading the designated amount of bytes from the stream.void
reset()
long
setCloseTime(long closeTime)
long
skip(long n)
-
-
-
Field Detail
-
aliveTimeExtension
protected final long aliveTimeExtension
The time in milliseconds the alive time is extended when accessing this stream.
-
busyThreads
protected final Map<Thread,AtomicInteger> busyThreads
The threads which are currently accessing this server-side proxy (and and how often). This is used to avoid closing a currently active server-side proxy.
-
cleanup
protected final Cleanup<IOException> cleanup
The clean-up for closing the wrapped input stream as post-mortem action of thisServerInputStream
.
-
-
Constructor Detail
-
ServerInputStream
@Deprecated(since="15.0.0", forRemoval=true) public ServerInputStream(InputStream in)
Deprecated, for removal: This API element is subject to removal in a future version.UseServerInputStream(InputStream, long, long)
instead.Creates a newServerInputStream
providing the content of the designated stream incrementally on client side. Note that this stream as well as the wrappedInputStream
will be closed by the remote site. Therefore you should only close this stream (or the wrappedInputStream
) if you are sure that the remote side has not closed it and will not close it, for instance since it disconnected abruptly.- Parameters:
in
- The stream of which the content will be provided incrementally on client side. This stream will be closed by the remote side.
-
ServerInputStream
public ServerInputStream(InputStream in, long initialAliveTime, long aliveTimeExtension)
Creates a newServerInputStream
providing the content of the designated stream incrementally on client side. Note that this stream as well as the wrappedInputStream
will be closed by the remote site. Therefore you should only close this stream (or the wrappedInputStream
) if you are sure that the remote side has not closed it and will not close it, for instance since it disconnected abruptly.- Parameters:
in
- The stream of which the content will be provided incrementally on client side. This stream will be closed by the remote side.initialAliveTime
- The initial time in milliseconds this server stream remains open before automatically being closed.aliveTimeExtension
- The time in milliseconds to extend the alive time when accessing this server stream.
-
-
Method Detail
-
getCloseTime
public long getCloseTime()
- Specified by:
getCloseTime
in interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
setCloseTime
public long setCloseTime(long closeTime)
- Specified by:
setCloseTime
in interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
isBusy
public boolean isBusy()
- Specified by:
isBusy
in interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
read
public int read() throws IOException
Description copied from interface:ServerStream
- Specified by:
read
in interfaceServerStream
- Throws:
IOException
-
read
public byte[] read(int len) throws IOException
Description copied from interface:ServerStream
ResemblesInputStream.read(byte[])
by reading the designated amount of bytes from the stream. If there are less bytes remaining in the stream, the returned byte array will be correspondingly shorter. If no bytes remain (java.io.InputStream#read(byte[])
returns -1),null
will be returned.- Specified by:
read
in interfaceServerStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
Description copied from interface:ServerStream
- Specified by:
skip
in interfaceServerStream
- Throws:
IOException
-
available
public int available() throws IOException
Description copied from interface:ServerStream
- Specified by:
available
in interfaceServerStream
- Throws:
IOException
-
close
public void close() throws IOException
Description copied from interface:ServerStream
InputStream.close()
This additionally removes the skeleton in the communication framework.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacede.aristaflow.adept2.model.communication.ServerSideProxy
- Specified by:
close
in interfaceServerStream
- Throws:
IOException
-
mark
public void mark(int readlimit)
Description copied from interface:ServerStream
- Specified by:
mark
in interfaceServerStream
-
reset
public void reset() throws IOException
Description copied from interface:ServerStream
- Specified by:
reset
in interfaceServerStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
Description copied from interface:ServerStream
- Specified by:
markSupported
in interfaceServerStream
-
-