Example #1
0
 /** 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);
   }
 }
Example #2
0
 /** 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);
   }
 }
Example #3
0
 /**
  * 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);
   }
 }
Example #4
0
 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;
 }