package com.google.sps.firebase;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import java.io.IOException;

// Only create app one time
public class FirebaseAppManager {
  private static FirebaseApp app = null;

  public static FirebaseApp getApp() throws IOException {
    if (app == null) {
      FirebaseOptions options =
          new FirebaseOptions.Builder()
              .setCredentials(GoogleCredentials.getApplicationDefault())
              .setDatabaseUrl("https://fulfillment-deco-step-2020.firebaseio.com")
              .setProjectId("fulfillment-deco-step-2020")
              .build();
      app = FirebaseApp.initializeApp(options);
    }
    return app;
  }
}

@@ -171,27 +171,196 @@
 ort 
-java.io.IOException
+com.google.firebase.ThreadManager;%0Aimport java.io.IOException;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.ThreadFactory
 ;%0A%0A/
@@ -771,16 +771,16 @@
 o.com%22)%0A
-
         
@@ -829,16 +829,915 @@
 -2020%22)%0A
+              .setThreadManager(%0A                  new ThreadManager() %7B%0A%0A                    @Override%0A                    protected void releaseExecutor(FirebaseApp app, ExecutorService executor) %7B%0A                      executor.shutdownNow();%0A                    %7D%0A%0A                    @Override%0A                    protected ThreadFactory getThreadFactory() %7B%0A                      // TODO Auto-generated method stub%0A                      return com.google.appengine.api.ThreadManager.backgroundThreadFactory();%0A                    %7D%0A%0A                    @Override%0A                    protected ExecutorService getExecutor(FirebaseApp app) %7B%0A                      // TODO Auto-generated method stub%0A                      return Executors.newCachedThreadPool(%0A                          com.google.appengine.api.ThreadManager.backgroundThreadFactory());%0A                    %7D%0A                  %7D)%0A
         

Configure firebase to use background threads from appengine.