/** Shutdown the agent again. */ public void shutdown() { try { if (options.getDumpOnExit()) { output.writeExecutionData(false); } output.shutdown(); if (options.getJmx()) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(JMX_NAME)); } } catch (final Exception e) { logger.logExeption(e); } }
/** Initializes this agent. */ public void startup() { try { String sessionId = options.getSessionId(); if (sessionId == null) { sessionId = createSessionId(); } data.setSessionId(sessionId); output = createAgentOutput(); output.startup(options, data); if (options.getJmx()) { ManagementFactory.getPlatformMBeanServer() .registerMBean(new StandardMBean(this, IAgent.class), new ObjectName(JMX_NAME)); } } catch (final Exception e) { logger.logExeption(e); } }
/** * Create output implementation as given by the agent options. * * @return configured controller implementation */ IAgentOutput createAgentOutput() { final OutputMode controllerType = options.getOutput(); switch (controllerType) { case file: return new FileOutput(); case tcpserver: return new TcpServerOutput(logger); case tcpclient: return new TcpClientOutput(logger); case none: return new NoneOutput(); default: throw new AssertionError(controllerType); } }
private AgentOptions createAgentOptions() { final AgentOptions agentOptions = new AgentOptions(); final String destPath = destFile.getAbsolutePath(); agentOptions.setDestfile(destPath); if (append != null) { agentOptions.setAppend(append.booleanValue()); } if (getIncludes() != null && !getIncludes().isEmpty()) { String agentIncludes = StringUtils.join(getIncludes().iterator(), ":"); agentOptions.setIncludes(agentIncludes); } if (getExcludes() != null && !getExcludes().isEmpty()) { String agentExcludes = StringUtils.join(getExcludes().iterator(), ":"); agentOptions.setExcludes(agentExcludes); } if (exclClassLoaders != null) { agentOptions.setExclClassloader(exclClassLoaders); } if (sessionId != null) { agentOptions.setSessionId(sessionId); } if (dumpOnExit != null) { agentOptions.setDumpOnExit(dumpOnExit.booleanValue()); } if (output != null) { agentOptions.setOutput(output); } if (address != null) { agentOptions.setAddress(address); } if (port != null) { agentOptions.setPort(port.intValue()); } return agentOptions; }