package com.rollbar.example;

import static com.rollbar.notifier.config.ConfigBuilder.withAccessToken;

import com.rollbar.api.payload.Payload;
import com.rollbar.notifier.Rollbar;
import com.rollbar.notifier.config.Config;
import com.rollbar.notifier.provider.Provider;
import com.rollbar.notifier.sender.Result;
import com.rollbar.notifier.sender.Sender;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Application example using rollbar-java notifier.
 */
public class Application {

  private Greeting greeting;

  private Rollbar rollbar;

  /**
   * Constructor.
   */
  public Application() {
    this.greeting = new Greeting();
    Config config = withAccessToken(System.getenv("ROLLBAR_ACCESSTOKEN"))
        .environment("development")
        .codeVersion("1.0.0")
        .language("java")
        .build();
    this.rollbar = Rollbar.init(config);
    this.rollbar.handleUncaughtErrors();
  }

  /**
   * Main method.
   * @param args the args.
   */
  public static void main(String[] args) {
    Application app = new Application();
    app.execute();

    throw new RuntimeException("Exception finishing execution.");
  }

  private void execute() {
    ExecutorService executor = Executors.newFixedThreadPool(3);
    List<Callable<Void>> callableTasks = new ArrayList<>();

    for (int i = 0; i < 20; i++) {
      callableTasks.add(new GreetingTask(i + 1, rollbar, greeting));
    }

    try {
      executor.invokeAll(callableTasks);
    } catch (InterruptedException e) {
      rollbar.error(e, "Unexpectedly the execution was interrupted.");
    } finally {
      executor.shutdown();
    }
  }

  private static final class GreetingTask implements Callable<Void> {

    private final int taskNumber;

    private final Rollbar rollbar;

    private final Greeting greeting;

    public GreetingTask(int taskNumber, Rollbar rollbar, Greeting greeting) {
      this.taskNumber = taskNumber;
      this.rollbar = rollbar;
      this.greeting = greeting;
    }

    @Override
    public Void call() throws Exception {
      try {
        printGreeting();
      } catch (Exception e) {
        rollbar.error(e, "Error in task: " + taskNumber);
      }
      return null;
    }

    private void printGreeting() {
      System.out.println(greeting.greeting());
    }
  }
}
@@ -101,48 +101,8 @@
 n;%0A%0A
-import com.rollbar.api.payload.Payload;%0A
 impo
@@ -209,25 +209,29 @@
 ier.
-provider.Provider
+sender.SenderCallback
 ;%0Aim
@@ -267,14 +267,18 @@
 der.
-Result
+SyncSender
 ;%0Aim
@@ -310,22 +310,29 @@
 .sender.
-Sender
+result.Result
 ;%0Aimport
@@ -357,34 +357,8 @@
 st;%0A
-import java.util.HashMap;%0A
 impo
@@ -380,30 +380,8 @@
 st;%0A
-import java.util.Map;%0A
 impo
@@ -414,16 +414,63 @@
 llable;%0A
+import java.util.concurrent.ConcurrentHashMap;%0A
 import j
@@ -544,16 +544,66 @@
 ecutors;
+%0Aimport java.util.concurrent.atomic.AtomicInteger;
 %0A%0A/**%0A *
@@ -977,34 +977,8 @@
 0%22)%0A
-        .language(%22java%22)%0A
     
@@ -1036,49 +1036,8 @@
 g);%0A
-    this.rollbar.handleUncaughtErrors();%0A
   %7D%0A

Update rollbar-java example