Package com.onpositive.gae.tools

Source Code of com.onpositive.gae.tools.GetLocalRunningServer

package com.onpositive.gae.tools;

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.internal.core.LaunchManager;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;

public class GetLocalRunningServer {

 
  public static String connectionString(){
    IDebugTarget[] debugTargets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets();
    for (IDebugTarget t:debugTargets){
      try {
        if (t instanceof IJavaDebugTarget){
          IJavaDebugTarget tr=(IJavaDebugTarget) t;
         
          IThread[] threads = tr.getThreads();
          for (IThread ta:threads){
            String name = ta.getName();
            if (name.indexOf("SelectChannelConnector")!=-1){
              int lastIndexOf = name.lastIndexOf(':');
              if (lastIndexOf!=-1){
                int port=Integer.parseInt(name.substring(lastIndexOf));
                return "http://localhost:"+port+"/";
              }
            }           
          }
//          IProcess process = tr.getProcess();
//          String attribute = process.getAttribute(IProcess.ATTR_CMDLINE);
//          if (attribute.indexOf("com.google.appengine.tools.development.gwt.AppEngineLauncher ")!=-1){
//           
//          }
        }
        //System.out.println(t.getName());
      } catch (DebugException e) {
        e.printStackTrace();
        // TODO Auto-generated catch block
        //e.printStackTrace();
      }
      //System.out.println(t.getModelIdentifier());
    }
    return "";
  }
}
TOP

Related Classes of com.onpositive.gae.tools.GetLocalRunningServer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.