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 anInputStreamasServerStreamwhich allows for keeping anInputStreamlocally and use it remotely.
-
-
Field Summary
Fields Modifier and Type Field Description protected longaliveTimeExtensionThe time in milliseconds the alive time is extended when accessing this stream.protected Map<Thread,AtomicInteger>busyThreadsThe threads which are currently accessing this server-side proxy (and and how often).protected Cleanup<IOException>cleanupThe 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 newServerInputStreamproviding the content of the designated stream incrementally on client side.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()InputStream.close()This additionally removes the skeleton in the communication framework.longgetCloseTime()booleanisBusy()voidmark(int readlimit)booleanmarkSupported()intread()byte[]read(int len)ResemblesInputStream.read(byte[])by reading the designated amount of bytes from the stream.voidreset()longsetCloseTime(long closeTime)longskip(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 newServerInputStreamproviding the content of the designated stream incrementally on client side. Note that this stream as well as the wrappedInputStreamwill 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 newServerInputStreamproviding the content of the designated stream incrementally on client side. Note that this stream as well as the wrappedInputStreamwill 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:
getCloseTimein interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
setCloseTime
public long setCloseTime(long closeTime)
- Specified by:
setCloseTimein interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
isBusy
public boolean isBusy()
- Specified by:
isBusyin interfacede.aristaflow.adept2.model.communication.TimeTrackingSsProxy
-
read
public int read() throws IOExceptionDescription copied from interface:ServerStream- Specified by:
readin interfaceServerStream- Throws:
IOException
-
read
public byte[] read(int len) throws IOExceptionDescription copied from interface:ServerStreamResemblesInputStream.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),nullwill be returned.- Specified by:
readin interfaceServerStream- Throws:
IOException
-
skip
public long skip(long n) throws IOExceptionDescription copied from interface:ServerStream- Specified by:
skipin interfaceServerStream- Throws:
IOException
-
available
public int available() throws IOExceptionDescription copied from interface:ServerStream- Specified by:
availablein interfaceServerStream- Throws:
IOException
-
close
public void close() throws IOExceptionDescription copied from interface:ServerStreamInputStream.close()This additionally removes the skeleton in the communication framework.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacede.aristaflow.adept2.model.communication.ServerSideProxy- Specified by:
closein interfaceServerStream- Throws:
IOException
-
mark
public void mark(int readlimit)
Description copied from interface:ServerStream- Specified by:
markin interfaceServerStream
-
reset
public void reset() throws IOExceptionDescription copied from interface:ServerStream- Specified by:
resetin interfaceServerStream- Throws:
IOException
-
markSupported
public boolean markSupported()
Description copied from interface:ServerStream- Specified by:
markSupportedin interfaceServerStream
-
-