Author: rob.stryker(a)jboss.com
Date: 2010-10-05 07:01:05 -0400 (Tue, 05 Oct 2010)
New Revision: 25483
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java
Log:
JBIDE-7251 - remote launch should verify server state first
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java 2010-10-05
08:29:25 UTC (rev 25482)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/WebPortPoller.java 2010-10-05
11:01:05 UTC (rev 25483)
@@ -43,26 +43,41 @@
public void pollerRun() {
done = false;
- String url = "http://"+getServer().getHost(); //$NON-NLS-1$
- JBossServer jbs = ServerConverter.getJBossServer(server);
- int port = jbs.getJBossWebPort();
- url += ":" + port; //$NON-NLS-1$
-
+ String url = getURL(getServer());
while(!canceled && !done) {
- try {
- URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
- ((HttpURLConnection)conn).getResponseCode();
+ boolean up = onePing(url);
+ if( up ) {
done = true;
state = SERVER_UP;
- } catch( FileNotFoundException fnfe ) {
- done = true;
- state = SERVER_UP;
- } catch( Exception e) {
}
}
}
+ public static String getURL(IServer server) {
+ String url = "http://"+server.getHost(); //$NON-NLS-1$
+ JBossServer jbs = ServerConverter.getJBossServer(server);
+ int port = jbs.getJBossWebPort();
+ url += ":" + port; //$NON-NLS-1$
+ return url;
+ }
+
+ public static boolean onePing(IServer server) {
+ return onePing(getURL(server));
+ }
+
+ public static boolean onePing(String url) {
+ try {
+ URL pingUrl = new URL(url);
+ URLConnection conn = pingUrl.openConnection();
+ ((HttpURLConnection)conn).getResponseCode();
+ return true;
+ } catch( FileNotFoundException fnfe ) {
+ return true;
+ } catch( Exception e) {
+ }
+ return false;
+ }
+
public ServerStatePollerType getPollerType() {
return type;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2010-10-05
08:29:25 UTC (rev 25482)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2010-10-05
11:01:05 UTC (rev 25483)
@@ -34,6 +34,7 @@
import org.eclipse.rse.services.shells.IShellService;
import
org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.extensions.polling.WebPortPoller;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.AbstractJBossLaunchConfigType;
@@ -211,6 +212,13 @@
public boolean preLaunchCheck(ILaunchConfiguration configuration,
String mode, IProgressMonitor monitor) throws CoreException {
+ // ping if up
+ JBossServerBehavior beh =
LocalJBossServerStartupLaunchUtil.getServerBehavior(configuration);
+ boolean started = new WebPortPoller().onePing(beh.getServer());
+ if( started ) {
+ beh.setServerStarted();
+ return false;
+ }
return true;
}