Package org.jacoco.agent.rt.internal
Class Agent
- java.lang.Object
-
- org.jacoco.agent.rt.internal.Agent
-
-
Field Summary
Fields Modifier and Type Field Description private RuntimeData
data
private java.util.concurrent.Callable<java.lang.Void>
jmxRegistration
private IExceptionLogger
logger
private AgentOptions
options
private IAgentOutput
output
private static Agent
singleton
-
Constructor Summary
Constructors Constructor Description Agent(AgentOptions options, IExceptionLogger logger)
Creates a new agent with the given agent options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) IAgentOutput
createAgentOutput()
Create output implementation as given by the agent options.private java.lang.String
createSessionId()
void
dump(boolean reset)
Triggers a dump of the current execution data through the configured output.RuntimeData
getData()
Returns the runtime data object created by this agentbyte[]
getExecutionData(boolean reset)
Returns current execution data.static Agent
getInstance()
Returns a global instance which is already started.static Agent
getInstance(AgentOptions options)
Returns a global instance which is already started.java.lang.String
getSessionId()
Returns current a session identifier.java.lang.String
getVersion()
Returns version of JaCoCo.void
reset()
Resets all coverage information.void
setSessionId(java.lang.String id)
Sets a session identifier.void
shutdown()
Shutdown the agent again.void
startup()
Initializes this agent.
-
-
-
Field Detail
-
singleton
private static Agent singleton
-
options
private final AgentOptions options
-
logger
private final IExceptionLogger logger
-
data
private final RuntimeData data
-
output
private IAgentOutput output
-
jmxRegistration
private java.util.concurrent.Callable<java.lang.Void> jmxRegistration
-
-
Constructor Detail
-
Agent
Agent(AgentOptions options, IExceptionLogger logger)
Creates a new agent with the given agent options.- Parameters:
options
- agent optionslogger
- logger used by this agent
-
-
Method Detail
-
getInstance
public static Agent getInstance(AgentOptions options) throws java.lang.Exception
Returns a global instance which is already started. If the method is called the first time the instance is created with the given options.- Parameters:
options
- options to configure the instance- Returns:
- global instance
- Throws:
java.lang.Exception
- in case something cannot be initialized
-
getInstance
public static Agent getInstance() throws java.lang.IllegalStateException
Returns a global instance which is already started. If a agent has not been initialized before this method will fail.- Returns:
- global instance
- Throws:
java.lang.IllegalStateException
- if no Agent has been started yet
-
getData
public RuntimeData getData()
Returns the runtime data object created by this agent- Returns:
- runtime data for this agent instance
-
startup
public void startup() throws java.lang.Exception
Initializes this agent.- Throws:
java.lang.Exception
- in case something cannot be initialized
-
shutdown
public void shutdown()
Shutdown the agent again.
-
createAgentOutput
IAgentOutput createAgentOutput()
Create output implementation as given by the agent options.- Returns:
- configured controller implementation
-
createSessionId
private java.lang.String createSessionId()
-
getVersion
public java.lang.String getVersion()
Description copied from interface:IAgent
Returns version of JaCoCo.- Specified by:
getVersion
in interfaceIAgent
- Returns:
- version of JaCoCo
-
getSessionId
public java.lang.String getSessionId()
Description copied from interface:IAgent
Returns current a session identifier.- Specified by:
getSessionId
in interfaceIAgent
- Returns:
- current session identifier
-
setSessionId
public void setSessionId(java.lang.String id)
Description copied from interface:IAgent
Sets a session identifier.- Specified by:
setSessionId
in interfaceIAgent
- Parameters:
id
- new session identifier
-
reset
public void reset()
Description copied from interface:IAgent
Resets all coverage information.
-
getExecutionData
public byte[] getExecutionData(boolean reset)
Description copied from interface:IAgent
Returns current execution data.- Specified by:
getExecutionData
in interfaceIAgent
- Parameters:
reset
- iftrue
the current execution data is cleared afterwards- Returns:
- dump of current execution data in JaCoCo binary format
-
dump
public void dump(boolean reset) throws java.io.IOException
Description copied from interface:IAgent
Triggers a dump of the current execution data through the configured output.
-
-