Class SurefireForkChannel
java.lang.Object
org.apache.maven.surefire.extensions.ForkChannel
org.apache.maven.plugin.surefire.extensions.SurefireForkChannel
- All Implemented Interfaces:
Closeable,AutoCloseable
The TCP/IP server accepting only one client connection. The forked JVM connects to the server using the
The objects
The channel is closed after the forked JVM has finished normally or the shutdown hook is executed in the plugin.
connection string.
The main purpose of this class is to conect with tthe client, bind the
command reader to the internal socket's
InputStream, and bind the
event handler writing the event
objects to the event handler.
The objects
WritableByteChannel and ReadableByteChannel are forked process streams
(standard input and output). Both are ignored in this implementation but they are used in LegacyForkChannel.
The channel is closed after the forked JVM has finished normally or the shutdown hook is executed in the plugin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SurefireForkChannel.Bindingsprivate CloseableDaemonThreadprivate CloseableDaemonThreadprivate final Stringprivate final intprivate LineConsumerThreadprivate final AsynchronousServerSocketChannelprivate Future<AsynchronousSocketChannel>private final Stringprivate static final ExecutorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindCommandReader(CommandReader commands, WritableByteChannel stdIn) Binds command handler to the channel.voidbindEventHandler(EventHandler<Event> eventHandler, CountdownCloseable countdown, ReadableByteChannel stdOut) Starts a Thread reading the events.voidclose()voiddisable()private AsynchronousSocketChannelintthe permits inCountdownCloseable.This is server related class, which if binds to a TCP port, determines the connection string for the client.private final voidsetTrueOptions(SocketOption<Boolean>... options) voidAsynchronously connects to the client.private voidMethods inherited from class org.apache.maven.surefire.extensions.ForkChannel
getArguments
-
Field Details
-
THREAD_POOL
-
server
-
localHost
-
localPort
private final int localPort -
sessionId
-
bindings
-
session
-
out
-
commandReaderBindings
-
eventHandlerBindings
-
eventBindings
-
commandBindings
-
-
Constructor Details
-
SurefireForkChannel
SurefireForkChannel(@Nonnull ForkNodeArguments arguments) throws IOException - Throws:
IOException
-
-
Method Details
-
tryConnectToClient
public void tryConnectToClient()Description copied from class:ForkChannelAsynchronously connects to the client.- Specified by:
tryConnectToClientin classForkChannel
-
getForkNodeConnectionString
Description copied from class:ForkChannelThis is server related class, which if binds to a TCP port, determines the connection string for the client.- Specified by:
getForkNodeConnectionStringin classForkChannel- Returns:
- a connection string utilized by the client in the fork JVM
-
getCountdownCloseablePermits
public int getCountdownCloseablePermits()Description copied from class:ForkChannelthe permits inCountdownCloseable.- Specified by:
getCountdownCloseablePermitsin classForkChannel
-
bindCommandReader
public void bindCommandReader(@Nonnull CommandReader commands, WritableByteChannel stdIn) throws IOException, InterruptedException Description copied from class:ForkChannelBinds command handler to the channel. Starts a Thread streaming out the commands.- Specified by:
bindCommandReaderin classForkChannel- Parameters:
commands- command reader, seeCommandReader.readNextCommand()stdIn- optional standard input stream of the JVM to write the encoded commands into it- Throws:
IOException- if an error in the fork channelInterruptedException- channel interrupted
-
bindEventHandler
public void bindEventHandler(@Nonnull EventHandler<Event> eventHandler, @Nonnull CountdownCloseable countdown, ReadableByteChannel stdOut) throws IOException, InterruptedException Description copied from class:ForkChannelStarts a Thread reading the events.- Specified by:
bindEventHandlerin classForkChannel- Parameters:
eventHandler- event eventHandlercountdown- count down of the final call ofCloseable.close()stdOut- optional standard output stream of the JVM- Throws:
IOException- if an error in the fork channelInterruptedException- channel interrupted
-
disable
public void disable()- Specified by:
disablein classForkChannel
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classForkChannel- Throws:
IOException
-
verifySessionId
- Throws:
InterruptedExceptionIOException
-
setTrueOptions
- Throws:
IOException
-
getChannel
- Throws:
InterruptedExceptionIOException
-