package net.ghostlab.instrumentation;
/**
 * Copyright 2015 The instrumentation Authors
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.health.HealthCheckRegistry;
import net.ghostlab.instrumentation.application.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

public class ApplicationMain {
  public static final HealthCheckRegistry healthChecks = new HealthCheckRegistry();
  public static final MetricRegistry metrics = new MetricRegistry();
  private static final Logger LOG = LoggerFactory.getLogger(ApplicationMain.class);

  public static void main(String args[]) {
    Integer mainPort = 8080;
    Integer adminPort = mainPort + 1;
    LOG.info("Server Configured to listen on port " + mainPort);

    LOG.debug("Initializing Metrics");
    startReport();

    LOG.info("Creating Jetty Server");
    Application webapp = new Application();

    LOG.info("Configuring Jetty Server");
    webapp.setAdminPort(adminPort);
    webapp.setApplicationPort(mainPort);

    LOG.info("Starting Jetty Server");
    webapp.start();

    LOG.info("We're done!");
 }

  static void startReport() {
    ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
    reporter.start(30, TimeUnit.SECONDS);
  }
}

@@ -1297,12 +1297,64 @@
 t = 
+Integer.parseInt(System.getProperty(%22mainPort%22, %22
 8080
+%22))
 ;%0A  
@@ -1379,42 +1379,157 @@
 t = 
-mainPort + 1;%0A    LOG.info(%22Server
+Integer.parseInt(System.getProperty(%22adminPort%22, %228081%22));%0A%0A    LOG.info(%22Application Configured to listen on port %22 + mainPort);%0A    LOG.info(%22Admin
  Con
@@ -1550,34 +1550,35 @@
 ten on port %22 + 
-m
 a
+dm
 inPort);%0A%0A    LO
@@ -1788,24 +1788,24 @@
 adminPort);%0A
-
     webapp.s
@@ -1824,32 +1824,118 @@
 nPort(mainPort);
+%0A    webapp.setApplicationPath(System.getProperty(%22applicationPath%22, %22/application%22));
 %0A%0A    LOG.info(%22

Make application path and ports configurable