Author: rob.stryker(a)jboss.com
Date: 2010-09-17 02:14:40 -0400 (Fri, 17 Sep 2010)
New Revision: 24973
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/bin/
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/bin/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java
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/RSEUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/console/ShowConsoleServerStateListener.java
Log:
Ongoing RSE cleanup / exceptions / etc.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java 2010-09-17
05:12:27 UTC (rev 24972)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSECorePlugin.java 2010-09-17
06:14:40 UTC (rev 24973)
@@ -20,6 +20,7 @@
public class RSECorePlugin implements BundleActivator {
private static BundleContext context;
+ public static final String PLUGIN_ID = "org.jboss.ide.eclipse.as.rse.core";
static BundleContext getContext() {
return context;
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-09-17
05:12:27 UTC (rev 24972)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2010-09-17
06:14:40 UTC (rev 24973)
@@ -15,8 +15,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -55,21 +57,28 @@
JBossServerBehavior beh =
LocalJBossServerStartupLaunchUtil.getServerBehavior(configuration);
beh.setServerStarting();
String command = configuration.getAttribute(RSE_STARTUP_COMMAND, (String)null);
- IShellService service = findShellService(beh);
+ IShellService service = null;
try {
- final IHostShell hs = service.runCommand("/", command, new String[]{}, new
NullProgressMonitor());
-
- // TODO clean this shit up. It works now, and this is great, but
- // lets handle the listener, make sure to remove it at the right time,
- // check output for obvious errors, launch a poller, etc
- hs.addOutputListener(new IHostShellOutputListener(){
- public void shellOutputChanged(IHostShellChangeEvent event) {
- IHostOutput[] out = event.getLines();
- for(int i = 0; i < out.length; i++ ) {
- System.out.println(out[i]);
- }
+ service = findShellService(beh);
+ } catch(CoreException ce) {
+ beh.setServerStopped();
+ throw ce;
+ }
+ IHostShell hs = null;
+ IHostShellOutputListener listener = null;
+ listener = new IHostShellOutputListener(){
+ public void shellOutputChanged(IHostShellChangeEvent event) {
+ IHostOutput[] out = event.getLines();
+ for(int i = 0; i < out.length; i++ ) {
+ // TODO listen here for obvious exceptions or failures
+ System.out.println(out[i]);
}
- });
+ }
+ };
+
+ try {
+ hs = service.runCommand("/", command, new String[]{}, new
NullProgressMonitor());
+ hs.addOutputListener(listener);
int x = 0;
while( x < 30000) {
x+=1000;
@@ -82,8 +91,19 @@
// Now launch ping thread
} catch(SystemMessageException sme) {
sme.printStackTrace();
+ } catch(RuntimeException re) {
+ String className = service.getClass().getName();
+ if(re instanceof NullPointerException &&
className.endsWith(".DStoreShellService")) {
+ beh.setServerStopped();
+ throw new CoreException(new Status(IStatus.ERROR,
org.jboss.ide.eclipse.as.rse.core.RSECorePlugin.PLUGIN_ID,
+ "no remote daemon installed. Please install a remote daemon or use an RSE
server configured for ssh rather than dstore"));
+ }
}
+ // Exiting the shell cancels the process. PROBLEM!!!
+// if( hs != null ) {
+// hs.exit();
+// }
beh.setServerStarted();
}
@@ -101,54 +121,60 @@
final String command = shutdown.toString() + rc.SPACE + rc.SHUTDOWN_STOP_ARG +
rc.SPACE
+ rc.SHUTDOWN_SERVER_ARG + rc.SPACE + hostname + rc.SPACE + rc.SHUTDOWN_USER_ARG
+ rc.SPACE + user + rc.SPACE + rc.SHUTDOWN_PASS_ARG + rc.SPACE + pass;
- IShellService service = findShellService(behaviour);
- if( service != null ) {
- final boolean[] saving = new boolean[1];
- saving[0] = false;
- final String[] output = new String[1];
- output[0] = null;
- try {
- final IHostShell hs = service.runCommand("/", command, new String[]{}, new
NullProgressMonitor());
- hs.addOutputListener(new IHostShellOutputListener(){
- public void shellOutputChanged(IHostShellChangeEvent event) {
- IHostOutput[] out = event.getLines();
- for(int i = 0; i < out.length; i++ ) {
- if( saving[0] ) {
- output[0] = out[i].getString();
- saving[0] = false;
- hs.exit();
- }
- /*
- * This is an extreme hack, because for some reason,
- * when the command line comes back, there's an extra space
- * "shutdown .sh"
- */
- String outNoSpace = out[i].getString().replaceAll(" ", "");
- String commandNoSpace = command.replaceAll(" ", "");
- boolean contains = outNoSpace.contains(commandNoSpace);
- if(!saving[0] && contains)
- saving[0] = true;
+
+ IShellService service = null;
+ try {
+ service = findShellService(behaviour);
+ } catch(CoreException ce) {
+ // TODO log and return
+ return;
+ }
+
+ final boolean[] saving = new boolean[1];
+ saving[0] = false;
+ final String[] output = new String[1];
+ output[0] = null;
+ try {
+ final IHostShell hs = service.runCommand("/", command, new String[]{}, new
NullProgressMonitor());
+ hs.addOutputListener(new IHostShellOutputListener(){
+ public void shellOutputChanged(IHostShellChangeEvent event) {
+ IHostOutput[] out = event.getLines();
+ for(int i = 0; i < out.length; i++ ) {
+ if( saving[0] ) {
+ output[0] = out[i].getString();
+ saving[0] = false;
+ hs.exit();
}
+ /*
+ * This is an extreme hack, because for some reason,
+ * when the command line comes back, there's an extra space
+ * "shutdown .sh"
+ */
+ String outNoSpace = out[i].getString().replaceAll(" ", "");
+ String commandNoSpace = command.replaceAll(" ", "");
+ boolean contains = outNoSpace.contains(commandNoSpace);
+ if(!saving[0] && contains)
+ saving[0] = true;
}
- });
-
- while(output[0] != null ) {
- try {
- Thread.sleep(200);
- } catch(InterruptedException ie) {
- }
}
- // can log the output somewhere?
- behaviour.setServerStopped();
-// if( output[0].contains("Exception in thread")) {
-// behaviour.setServerStopped();
-// } else {
-// // launch ping thread? Just mark it stopped and trust the server to figure it
out?
-// }
- } catch( SystemMessageException sme) {
- // TODO
- sme.printStackTrace();
+ });
+
+ while(output[0] != null ) {
+ try {
+ Thread.sleep(200);
+ } catch(InterruptedException ie) {
+ }
}
+ // can log the output somewhere?
+ behaviour.setServerStopped();
+ } catch( SystemMessageException sme) {
+ // TODO
+ sme.printStackTrace();
+ } catch( RuntimeException re ) {
+ if( re instanceof NullPointerException &&
service.getClass().getName().equals("DStoreShellService")) {
+ // remote server has no dstore shell service
+ behaviour.setServerStopped(); // behaviour.setServerStarted(); // failed
+ }
}
}
@@ -219,15 +245,19 @@
*/
}
- protected static IShellService findShellService(JBossServerBehavior behaviour) {
+ protected static IShellService findShellService(JBossServerBehavior behaviour) throws
CoreException {
String connectionName = RSEUtils.getRSEConnectionName(behaviour.getServer());
IHost host = RSEUtils.findHost(connectionName);
+ if( host == null ) {
+ throw new CoreException(new Status(IStatus.ERROR,
org.jboss.ide.eclipse.as.rse.core.RSECorePlugin.PLUGIN_ID,
+ "Host not found. Host may have been deleted or RSE model may not be completely
loaded"));
+ }
ISubSystem[] systems = RSECorePlugin.getTheSystemRegistry().getSubSystems(host);
for( int i = 0; i < systems.length; i++ ) {
if( systems[i] instanceof IShellServiceSubSystem)
return ((IShellServiceSubSystem)systems[i]).getShellService();
}
- return null;
+ throw new CoreException(new Status(IStatus.ERROR,
org.jboss.ide.eclipse.as.rse.core.RSECorePlugin.PLUGIN_ID, "No Shell Service
Found"));
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2010-09-17
05:12:27 UTC (rev 24972)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2010-09-17
06:14:40 UTC (rev 24973)
@@ -94,6 +94,7 @@
}
public static IHost findHost(String connectionName) {
+ // TODO ensure that all hosts are actually loaded, christ
IHost[] allHosts = RSECorePlugin.getTheSystemRegistry().getHosts();
for( int i = 0; i < allHosts.length; i++ ) {
if( allHosts[i].getAliasName().equals(connectionName))
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/console/ShowConsoleServerStateListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/console/ShowConsoleServerStateListener.java 2010-09-17
05:12:27 UTC (rev 24972)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/console/ShowConsoleServerStateListener.java 2010-09-17
06:14:40 UTC (rev 24973)
@@ -22,8 +22,10 @@
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public class ShowConsoleServerStateListener extends UnitedServerListener {
private static ShowConsoleServerStateListener instance;
@@ -42,7 +44,9 @@
if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
if( event.getServer().getServerState() == IServer.STATE_STARTING ) {
// do not launch console for remotes, for now
- IJBossServerPublishMethodType type =
DeploymentPreferenceLoader.getCurrentDeploymentMethodType(jbs.getServer());
+ DeployableServerBehavior beh =
ServerConverter.getDeployableServerBehavior(server);
+ IJBossServerPublishMethodType type =
beh.createPublishMethod().getPublishMethodType();
+ //IJBossServerPublishMethodType type =
DeploymentPreferenceLoader.getCurrentDeploymentMethodType(jbs.getServer());
if( !type.getId().equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD))
return;