Class TcpServerOutput
- java.lang.Object
-
- org.jacoco.agent.rt.internal.output.TcpServerOutput
-
- All Implemented Interfaces:
IAgentOutput
public class TcpServerOutput extends java.lang.Object implements IAgentOutput
Output that opens TCP server socket. This controller uses the following agent options:- address
- port
-
-
Field Summary
Fields Modifier and Type Field Description private TcpConnectionconnectionprivate IExceptionLoggerloggerprivate java.net.ServerSocketserverSocketprivate java.lang.Threadworker
-
Constructor Summary
Constructors Constructor Description TcpServerOutput(IExceptionLogger logger)New controller instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.ServerSocketcreateServerSocket(AgentOptions options)Open a server socket based on the given configuration.protected java.net.InetAddressgetInetAddress(java.lang.String address)Returns theInetAddressobject to open the server socket on.voidshutdown()Shutdown the agent controller and clean up any resources it has created.voidstartup(AgentOptions options, RuntimeData data)Configure the agent controller with the supplied options and connect it to the coverage runtimevoidwriteExecutionData(boolean reset)Write all execution data in the runtime to a location determined by the agent controller.
-
-
-
Field Detail
-
connection
private TcpConnection connection
-
logger
private final IExceptionLogger logger
-
serverSocket
private java.net.ServerSocket serverSocket
-
worker
private java.lang.Thread worker
-
-
Constructor Detail
-
TcpServerOutput
public TcpServerOutput(IExceptionLogger logger)
New controller instance.- Parameters:
logger- logger to use in case of exceptions is spawned threads
-
-
Method Detail
-
startup
public void startup(AgentOptions options, RuntimeData data) throws java.io.IOException
Description copied from interface:IAgentOutputConfigure the agent controller with the supplied options and connect it to the coverage runtime- Specified by:
startupin interfaceIAgentOutput- Parameters:
options- Options used to configure the agent controllerdata- Execution data for this agent- Throws:
java.io.IOException
-
shutdown
public void shutdown() throws java.lang.ExceptionDescription copied from interface:IAgentOutputShutdown the agent controller and clean up any resources it has created.- Specified by:
shutdownin interfaceIAgentOutput- Throws:
java.lang.Exception- in case shutdown fails
-
writeExecutionData
public void writeExecutionData(boolean reset) throws java.io.IOExceptionDescription copied from interface:IAgentOutputWrite all execution data in the runtime to a location determined by the agent controller. This method should only be called by the Agent- Specified by:
writeExecutionDatain interfaceIAgentOutput- Parameters:
reset- iftrueexecution data is cleared afterwards- Throws:
java.io.IOException- in case writing fails
-
createServerSocket
protected java.net.ServerSocket createServerSocket(AgentOptions options) throws java.io.IOException
Open a server socket based on the given configuration.- Parameters:
options- address and port configuration- Returns:
- opened server socket
- Throws:
java.io.IOException
-
getInetAddress
protected java.net.InetAddress getInetAddress(java.lang.String address) throws java.net.UnknownHostExceptionReturns theInetAddressobject to open the server socket on.- Parameters:
address- address specified as a string- Returns:
- address to open the server socket
- Throws:
java.net.UnknownHostException
-
-