public void contextInitialized()

in appengine-java8/bigtable/src/main/java/com/example/bigtable/BigtableHelper.java [82:125]


  public void contextInitialized(ServletContextEvent event) {
    // This will be invoked as part of a warmup request, or the first user
    // request if no warmup request was invoked.

    if (event != null) {
      sc = event.getServletContext();
      if (PROJECT_ID == null) {
        PROJECT_ID = sc.getInitParameter("BIGTABLE_PROJECT");
      }
      if (INSTANCE_ID == null) {
        INSTANCE_ID = sc.getInitParameter("BIGTABLE_INSTANCE");
      }
    }

    if (PROJECT_ID != null && PROJECT_ID.startsWith("@")) {
      PROJECT_ID = null;
    }
    if (INSTANCE_ID != null && INSTANCE_ID.startsWith("@")) {
      INSTANCE_ID = null;
    }

    if (PROJECT_ID == null) {
      PROJECT_ID = System.getProperty("bigtable.projectID");
    }
    if (INSTANCE_ID == null) {
      INSTANCE_ID = System.getProperty("bigtable.instanceID");
    }

    try {
      connect();
    } catch (IOException e) {
      if (sc != null) {
        sc.log("BigtableHelper - connect ", e);
      }
    }
    if (connection == null) {
      if (sc != null) {
        sc.log("BigtableHelper-No Connection");
      }
    }
    if (sc != null) {
      sc.log("ctx Initialized: " + PROJECT_ID + " " + INSTANCE_ID);
    }
  }