diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-12-20 13:54:19 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-12-23 10:10:34 +0100 |
commit | 27e32e433ba0ac1fdec9290d3454d5b369c969cc (patch) | |
tree | 1adebfbede651e008e1857d15cca0ca3c6ebffdd /org.jacoco.agent.rt | |
parent | 67e237ef923d0daa581ba9129a7e06072d990486 (diff) | |
download | jacoco-27e32e433ba0ac1fdec9290d3454d5b369c969cc.tar.gz |
Separate session data from IRuntime.
Diffstat (limited to 'org.jacoco.agent.rt')
7 files changed, 34 insertions, 32 deletions
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/JacocoAgent.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/JacocoAgent.java index a2f9b521..1f858b5c 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/JacocoAgent.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/JacocoAgent.java @@ -25,6 +25,7 @@ import org.jacoco.core.runtime.AgentOptions; import org.jacoco.core.runtime.AgentOptions.OutputMode; import org.jacoco.core.runtime.IRuntime; import org.jacoco.core.runtime.ModifiedSystemClassRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * The agent which is referred as the <code>Premain-Class</code>. @@ -72,15 +73,16 @@ public class JacocoAgent { */ public void init(final Instrumentation inst) throws Exception { final IRuntime runtime = createRuntime(inst); + final RuntimeData data = new RuntimeData(); String sessionId = options.getSessionId(); if (sessionId == null) { sessionId = createSessionId(); } - runtime.setSessionId(sessionId); - runtime.startup(); + data.setSessionId(sessionId); + runtime.startup(data); inst.addTransformer(new CoverageTransformer(runtime, options, logger)); controller = createAgentController(); - controller.startup(options, runtime); + controller.startup(options, data); } /** diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/IAgentController.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/IAgentController.java index c8dde9fa..9d99ffcd 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/IAgentController.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/IAgentController.java @@ -12,7 +12,7 @@ package org.jacoco.agent.rt.controller; import org.jacoco.core.runtime.AgentOptions; -import org.jacoco.core.runtime.IRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * Common interface for different implementations that control execution data @@ -26,12 +26,12 @@ public interface IAgentController { * * @param options * Options used to configure the agent controller - * @param runtime - * Coverage runtime this agent controller will be connected to + * @param data + * Execution data for this agent * @throws Exception * in case startup fails */ - public void startup(final AgentOptions options, final IRuntime runtime) + public void startup(final AgentOptions options, final RuntimeData data) throws Exception; /** diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/LocalController.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/LocalController.java index 5f7d405d..64c7c659 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/LocalController.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/LocalController.java @@ -19,7 +19,7 @@ import java.io.OutputStream; import org.jacoco.core.data.ExecutionDataWriter; import org.jacoco.core.runtime.AgentOptions; -import org.jacoco.core.runtime.IRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * Local only agent controller that will write coverage data to the filesystem. @@ -31,13 +31,13 @@ import org.jacoco.core.runtime.IRuntime; */ public class LocalController implements IAgentController { - private IRuntime runtime; + private RuntimeData data; private OutputStream output; - public final void startup(final AgentOptions options, final IRuntime runtime) + public final void startup(final AgentOptions options, final RuntimeData data) throws IOException { - this.runtime = runtime; + this.data = data; final File destFile = new File(options.getDestfile()).getAbsoluteFile(); final File folder = destFile.getParentFile(); if (folder != null) { @@ -49,7 +49,7 @@ public class LocalController implements IAgentController { public void writeExecutionData() throws IOException { final ExecutionDataWriter writer = new ExecutionDataWriter(output); - runtime.collect(writer, writer, false); + data.collect(writer, writer, false); } public void shutdown() throws IOException { diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/MBeanController.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/MBeanController.java index c947c6e7..699b2b7a 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/MBeanController.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/MBeanController.java @@ -21,7 +21,7 @@ import javax.management.StandardMBean; import org.jacoco.core.JaCoCo; import org.jacoco.core.data.ExecutionDataWriter; import org.jacoco.core.runtime.AgentOptions; -import org.jacoco.core.runtime.IRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * Controller that registers MBean. This controller does not use agent options. @@ -30,11 +30,11 @@ public class MBeanController implements IAgentController, IRuntimeMBean { private static final String OBJECT_NAME = "org.jacoco:type=Runtime"; - private IRuntime runtime; + private RuntimeData data; - public void startup(final AgentOptions options, final IRuntime runtime) + public void startup(final AgentOptions options, final RuntimeData data) throws Exception { - this.runtime = runtime; + this.data = data; ManagementFactory.getPlatformMBeanServer().registerMBean( new StandardMBean(this, IRuntimeMBean.class), new ObjectName(OBJECT_NAME)); @@ -56,22 +56,22 @@ public class MBeanController implements IAgentController, IRuntimeMBean { } public String getSessionId() { - return runtime.getSessionId(); + return data.getSessionId(); } public void setSessionId(final String id) { - runtime.setSessionId(id); + data.setSessionId(id); } public byte[] dump(final boolean reset) throws IOException { final ByteArrayOutputStream output = new ByteArrayOutputStream(); final ExecutionDataWriter writer = new ExecutionDataWriter(output); - runtime.collect(writer, writer, reset); + data.collect(writer, writer, reset); return output.toByteArray(); } public void reset() { - runtime.reset(); + data.reset(); } } diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpClientController.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpClientController.java index e59c4abd..8447a14e 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpClientController.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpClientController.java @@ -16,7 +16,7 @@ import java.net.Socket; import org.jacoco.agent.rt.IExceptionLogger; import org.jacoco.core.runtime.AgentOptions; -import org.jacoco.core.runtime.IRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * Controller that connects to a TCP port. This controller uses the following @@ -44,10 +44,10 @@ public class TcpClientController implements IAgentController { this.logger = logger; } - public void startup(final AgentOptions options, final IRuntime runtime) + public void startup(final AgentOptions options, final RuntimeData data) throws IOException { final Socket socket = createSocket(options); - connection = new TcpConnection(socket, runtime); + connection = new TcpConnection(socket, data); connection.init(); worker = new Thread(new Runnable() { public void run() { diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpConnection.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpConnection.java index 348eeec0..ba409f29 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpConnection.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpConnection.java @@ -16,16 +16,16 @@ import java.net.Socket; import java.net.SocketException; import org.jacoco.core.runtime.IRemoteCommandVisitor; -import org.jacoco.core.runtime.IRuntime; import org.jacoco.core.runtime.RemoteControlReader; import org.jacoco.core.runtime.RemoteControlWriter; +import org.jacoco.core.runtime.RuntimeData; /** * Handler for a single socket based remote connection. */ class TcpConnection implements IRemoteCommandVisitor { - private final IRuntime runtime; + private final RuntimeData data; private final Socket socket; @@ -35,9 +35,9 @@ class TcpConnection implements IRemoteCommandVisitor { private boolean initialized; - public TcpConnection(final Socket socket, final IRuntime runtime) { + public TcpConnection(final Socket socket, final RuntimeData data) { this.socket = socket; - this.runtime = runtime; + this.data = data; this.initialized = false; } @@ -97,10 +97,10 @@ class TcpConnection implements IRemoteCommandVisitor { public void visitDumpCommand(final boolean dump, final boolean reset) throws IOException { if (dump) { - runtime.collect(writer, writer, reset); + data.collect(writer, writer, reset); } else { if (reset) { - runtime.reset(); + data.reset(); } } writer.sendCmdOk(); diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpServerController.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpServerController.java index 3538b087..784015dd 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpServerController.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/controller/TcpServerController.java @@ -18,7 +18,7 @@ import java.net.UnknownHostException; import org.jacoco.agent.rt.IExceptionLogger; import org.jacoco.core.runtime.AgentOptions; -import org.jacoco.core.runtime.IRuntime; +import org.jacoco.core.runtime.RuntimeData; /** * Controller that opens TCP server socket. This controller uses the following @@ -48,7 +48,7 @@ public class TcpServerController implements IAgentController { this.logger = logger; } - public void startup(final AgentOptions options, final IRuntime runtime) + public void startup(final AgentOptions options, final RuntimeData data) throws IOException { serverSocket = createServerSocket(options); worker = new Thread(new Runnable() { @@ -57,7 +57,7 @@ public class TcpServerController implements IAgentController { try { synchronized (serverSocket) { connection = new TcpConnection( - serverSocket.accept(), runtime); + serverSocket.accept(), data); } connection.init(); connection.run(); |