package com.google.slurp.servlets;

import java.io.IOException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;

/**
 * Servlet context listener that is looked for whenever the backend server
 * receives a startup or shutdown request.
 */
@WebListener
public class ServerListener implements ServletContextListener {
  /**
   * {@inheritDoc}
   *
   * Initialize the Firebase Admin app for the server.
   */
  @Override
  public void contextInitialized(ServletContextEvent event) {
    System.out.println("Server initialized and starting up...");

    try {
      FirebaseOptions options = new FirebaseOptions.Builder()
                                    .setCredentials(GoogleCredentials.getApplicationDefault())
                                    .build();

      FirebaseApp.initializeApp(options);
    } catch (IOException error) {
      System.err.println("Error obtaining the Application Default Credentials:");
      error.printStackTrace();
    }
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void contextDestroyed(ServletContextEvent event) {
    System.out.println("Server destroyed and shutting down...");
  }
}

@@ -29,16 +29,149 @@
 vlets;%0A%0A
+import com.google.auth.oauth2.GoogleCredentials;%0Aimport com.google.firebase.FirebaseApp;%0Aimport com.google.firebase.FirebaseOptions;%0A
 import j
@@ -327,142 +327,8 @@
 r;%0A%0A
-import com.google.auth.oauth2.GoogleCredentials;%0Aimport com.google.firebase.FirebaseApp;%0Aimport com.google.firebase.FirebaseOptions;%0A%0A
 /**%0A

Fix import statements