package com.continuuity.gateway.runtime;

import com.continuuity.common.conf.CConfiguration;
import com.continuuity.common.metrics.OverlordMetricsReporter;
import com.continuuity.data.runtime.DataFabricModules;
import com.continuuity.gateway.Gateway;
import com.google.inject.Guice;
import com.google.inject.Injector;

import java.util.concurrent.TimeUnit;

/**
 * Main is a simple class that allows us to launch the Gateway as a standalone
 * program. This is also where we do our runtime injection.
 * <p/>
 * TODO: Prolly should look to wrap this in some sort of Daemon framework
 */
public class Main {

  /**
   * Our main method
   *
   * @param args Our command line options
   */
  public static void main(String[] args) {

    // Set up our Guice injections
    Injector injector = Guice.createInjector(
        new GatewayModules().getDistributedModules(),
        new DataFabricModules().getDistributedModules());

    // Get our fully wired Gateway
    Gateway theGateway = injector.getInstance(Gateway.class);

    // Now, initialize the Gateway
    try {

      // Load our configuration from our resource files
      CConfiguration configuration = CConfiguration.create();

      // enable metrics for this JVM. Note this may only be done once
      // per JVM, hence we do it only in the gateway.Main.
      OverlordMetricsReporter.enable(1, TimeUnit.SECONDS, configuration);

      // Start the gateway!
      theGateway.start(null, configuration);

    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }

  }

} // End of Main


@@ -35,16 +35,64 @@
 ntime;%0A%0A
+import com.continuuity.app.guice.BigMamaModule;%0A
 import c
@@ -771,16 +771,130 @@
  args) %7B
+%0A    // Load our configuration from our resource files%0A    CConfiguration configuration = CConfiguration.create();
 %0A%0A    //
@@ -1077,16 +1077,67 @@
 odules()
+,%0A        new BigMamaModule(configuration)%0A        
 );%0A%0A    
@@ -1261,24 +1261,24 @@
 the Gateway%0A
+
     try %7B%0A%0A 
@@ -1280,127 +1280,8 @@
  %7B%0A%0A
-      // Load our configuration from our resource files%0A      CConfiguration configuration = CConfiguration.create();%0A%0A
     

fix for cloud edition