Class ForkChannel
- java.lang.Object
-
- org.apache.maven.surefire.extensions.ForkChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public abstract class ForkChannel extends java.lang.Object implements java.io.CloseableIt's a session object used only by a particular Thread in ForkStarter and communicates with a dedicated forked JVM. It represents a server.
It connects to a remote client bytryConnectToClient(), provides a connection stringgetForkNodeConnectionString()needed by the client in forked JVM, binds event handler and command reader. This object is called in one Thread.- Since:
- 3.0.0-M5
- Author:
- Tibor Digana (tibor17)
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedForkChannel(org.apache.maven.surefire.api.fork.ForkNodeArguments arguments)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidbindCommandReader(CommandReader commands, java.nio.channels.WritableByteChannel stdIn)Binds command handler to the channel.abstract voidbindEventHandler(EventHandler<org.apache.maven.surefire.api.event.Event> eventHandler, CountdownCloseable countdownCloseable, java.nio.channels.ReadableByteChannel stdOut)Starts a Thread reading the events.abstract voidclose()abstract voiddisable()protected org.apache.maven.surefire.api.fork.ForkNodeArgumentsgetArguments()abstract intgetCountdownCloseablePermits()the permits inCountdownCloseable.abstract java.lang.StringgetForkNodeConnectionString()This is server related class, which if binds to a TCP port, determines the connection string for the client.abstract voidtryConnectToClient()Asynchronously connects to the client.
-
-
-
Method Detail
-
tryConnectToClient
public abstract void tryConnectToClient() throws java.io.IOException, java.lang.InterruptedExceptionAsynchronously connects to the client.- Throws:
java.io.IOException- if stream failsjava.lang.InterruptedException- if interrupted thread
-
getForkNodeConnectionString
public abstract java.lang.String getForkNodeConnectionString()
This is server related class, which if binds to a TCP port, determines the connection string for the client.- Returns:
- a connection string utilized by the client in the fork JVM
-
getCountdownCloseablePermits
public abstract int getCountdownCloseablePermits()
the permits inCountdownCloseable.
-
bindCommandReader
public abstract void bindCommandReader(@Nonnull CommandReader commands, java.nio.channels.WritableByteChannel stdIn) throws java.io.IOException, java.lang.InterruptedExceptionBinds command handler to the channel. Starts a Thread streaming out the commands.- Parameters:
commands- command reader, seeCommandReader.readNextCommand()stdIn- optional standard input stream of the JVM to write the encoded commands into it- Throws:
java.io.IOException- if an error in the fork channeljava.lang.InterruptedException- channel interrupted
-
bindEventHandler
public abstract void bindEventHandler(@Nonnull EventHandler<org.apache.maven.surefire.api.event.Event> eventHandler, @Nonnull CountdownCloseable countdownCloseable, java.nio.channels.ReadableByteChannel stdOut) throws java.io.IOException, java.lang.InterruptedExceptionStarts a Thread reading the events.- Parameters:
eventHandler- event eventHandlercountdownCloseable- count down of the final call ofCloseable.close()stdOut- optional standard output stream of the JVM- Throws:
java.io.IOException- if an error in the fork channeljava.lang.InterruptedException- channel interrupted
-
getArguments
@Nonnull protected org.apache.maven.surefire.api.fork.ForkNodeArguments getArguments()
-
disable
public abstract void disable()
-
close
public abstract void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-