public static JavascriptVmEmbedder.ConnectionToRemote connectToStandalone(String host, int port,
NamedConnectionLoggerFactory connectionLoggerFactory) {
SocketAddress address = new InetSocketAddress(host, port);
ConnectionLogger connectionLogger =
connectionLoggerFactory.createLogger(address.toString());
final StandaloneVm standaloneVm = BrowserFactory.getInstance().createStandalone(address,
connectionLogger);
return new JavascriptVmEmbedder.ConnectionToRemote() {
public JavascriptVmEmbedder.VmConnector selectVm() {
return new JavascriptVmEmbedder.VmConnector() {
public JavascriptVmEmbedder attach(JavascriptVmEmbedder.Listener embedderListener,
DebugEventListener debugEventListener)
throws CoreException {
embedderListener = null;
//+ @since 0.9 modified exception message string
String ERROR_STRING = "Nodeclipse/chromedevtools failed to connect to Standalone V8 VM "
+"( Check Help (F1) and Support http://www.nodeclipse.org/#support )\n. Info:";
try {
standaloneVm.attach(debugEventListener);
} catch (IOException e) {
throw newCoreException(ERROR_STRING, e);
} catch (UnsupportedVersionException e) {
throw newCoreException(ERROR_STRING, e);
}
return new JavascriptVmEmbedder() {
public JavascriptVm getJavascriptVm() {
return standaloneVm;
}
public String getTargetName() {
String embedderName = standaloneVm.getEmbedderName();
String vmVersion = standaloneVm.getVmVersion();
String disconnectReason = standaloneVm.getDisconnectReason();
String targetTitle;
if (embedderName == null) {
targetTitle = ""; //$NON-NLS-1$
} else {
targetTitle = MessageFormat.format(
Messages.JavascriptVmEmbedderFactory_TargetName0, embedderName, vmVersion);
}
boolean isAttached = standaloneVm.isAttached();
if (!isAttached) {
String disconnectMessage;
if (disconnectReason == null) {
disconnectMessage = Messages.JavascriptVmEmbedderFactory_Terminated;
} else {