Verified Owner
Top Fields Constructors Methods
org.jabref.logic.remote.server

public Class RemoteListenerServer

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.BufferedInputStream, .IOException, .InputStream, .OutputStream, java.net.ServerSocket, .Socket, .SocketException, java.nio.charset.StandardCharsets, java.util.Arrays, javafx.util.Pair, org.jabref.logic.remote.Protocol, .RemoteMessage, .RemotePreferences, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final int
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final Logger
private final RemoteMessageHandler
private final ServerSocket
private static final int

Constructor Summary

AccessConstructor and Description
public
RemoteListenerServer(RemoteMessageHandler messageHandler, int port)

Method Summary

Modifier and TypeMethod and Description
public void
private void
private void
private void
handleMessage(Protocol protocol, RemoteMessage type, Object argument)

private boolean
isHealthCheck(BufferedInputStream input)

Probing must not consume anything on a non-match: Protocol deserializes from the same stream afterwards, so any partially matching prefix is un-read via mark/reset.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BACKLOGback to summary
private static final int BACKLOG
HEALTH_CHECK_PREFIXback to summary
private static final byte[] HEALTH_CHECK_PREFIX
HEALTH_CHECK_REMAINING_PREFIXback to summary
private static final byte[] HEALTH_CHECK_REMAINING_PREFIX
HEALTH_CHECK_REQUESTback to summary
private static final byte[] HEALTH_CHECK_REQUEST
HEALTH_CHECK_RESPONSEback to summary
private static final byte[] HEALTH_CHECK_RESPONSE
LOGGERback to summary
private static final Logger LOGGER
messageHandlerback to summary
private final RemoteMessageHandler messageHandler
serverSocketback to summary
private final ServerSocket serverSocket
TIMEOUTback to summary
private static final int TIMEOUT

Constructor Detail

RemoteListenerServerback to summary
public RemoteListenerServer(RemoteMessageHandler messageHandler, int port) throws IOException

Method Detail

closeServerSocketback to summary
public void closeServerSocket()
handleConnectionback to summary
private void handleConnection(Socket socket) throws IOException
handleHealthCheckback to summary
private void handleHealthCheck(InputStream input, OutputStream output) throws IOException
handleMessageback to summary
private void handleMessage(Protocol protocol, RemoteMessage type, Object argument) throws IOException
isHealthCheckback to summary
private boolean isHealthCheck(BufferedInputStream input) throws IOException

Probing must not consume anything on a non-match: Protocol deserializes from the same stream afterwards, so any partially matching prefix is un-read via mark/reset.

The full prefix is only read after the first byte matched. A serialized Protocol request starts with the object-stream header (0xAC...), of which the client initially sends only four bytes — blocking here for the full prefix length would deadlock both sides until the socket timeout.

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override