Author: adietish
Date: 2011-07-04 10:28:09 -0400 (Mon, 04 Jul 2011)
New Revision: 32552
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java
Log:
[JBIDE-9054] deprecated #findServer (replaced by using util method
ServerConverter#checkedFindJBossServer)
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 2011-07-04
14:23:37 UTC (rev 32551)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSELaunchDelegate.java 2011-07-04
14:28:09 UTC (rev 32552)
@@ -9,9 +9,10 @@
* Red Hat, Inc. - initial API and implementation
*
* TODO: Logging and Progress Monitors
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.rse.core;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -36,70 +37,83 @@
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.server.internal.JBossServerBehavior;
+import
org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior.JBossBehaviourDelegate;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.IStartLaunchSetupParticipant;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
+import
org.jboss.ide.eclipse.as.core.server.internal.launch.configuration.JBossLaunchConfigProperties;
import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.ide.eclipse.as.rse.core.RSEHostShellModel.ServerShellModel;
public class RSELaunchDelegate implements StartLaunchDelegate,
IStartLaunchSetupParticipant {
-
public void actualLaunch(
JBossServerStartupLaunchConfiguration launchConfig,
ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor) throws CoreException {
JBossServerBehavior beh = JBossServerBehaviorUtils.getServerBehavior(configuration);
- if(LaunchCommandPreferences.ignoreLaunchCommand(beh.getServer())) {
+ if (LaunchCommandPreferences.ignoreLaunchCommand(beh.getServer())) {
beh.setServerStarting();
beh.setServerStarted();
return;
}
beh.setServerStarting();
- String command = RSELaunchConfigUtils.getStartupCommand(configuration);
+ String command = RSELaunchConfigProperties.getStartupCommand(configuration);
try {
ServerShellModel model = RSEHostShellModel.getInstance().getModel(beh.getServer());
- IHostShell shell = model.createStartupShell("/", command, new String[]{},
new NullProgressMonitor());
+ IHostShell shell = model.createStartupShell("/", command, new String[] {},
new NullProgressMonitor());
addShellOutputListener(shell);
launchPingThread(beh);
- } catch(SystemMessageException sme) {
- beh.setServerStopped(); // Not sure when this comes, but we should try to keep track
- throw new CoreException(new Status(IStatus.ERROR,
org.jboss.ide.eclipse.as.rse.core.RSECorePlugin.PLUGIN_ID,
- sme.getMessage(), sme));
- }
+ } catch (SystemMessageException sme) {
+ beh.setServerStopped(); // Not sure when this comes, but we should
+ // try to keep track
+ throw new CoreException(new Status(IStatus.ERROR,
+ org.jboss.ide.eclipse.as.rse.core.RSECorePlugin.PLUGIN_ID,
+ sme.getMessage(), sme));
+ }
}
-
+
private void launchPingThread(DeployableServerBehavior beh) {
// TODO do it properly here
RSEHostShellModel.delay(30000);
beh.setServerStarted();
}
-
-
+
// Only for debugging
private void addShellOutputListener(IHostShell shell) {
IHostShellOutputListener listener = null;
- listener = new IHostShellOutputListener(){
+ listener = new IHostShellOutputListener() {
public void shellOutputChanged(IHostShellChangeEvent event) {
IHostOutput[] out = event.getLines();
- for(int i = 0; i < out.length; i++ ) {
+ for (int i = 0; i < out.length; i++) {
// TODO listen here for obvious exceptions or failures
// System.out.println(out[i]);
}
}
};
- //shell.addOutputListener(listener);
+ // shell.addOutputListener(listener);
}
-
+
+ /**
+ *
+ * @deprecated
+ * This was called from {@link RSEBehaviourDelegate#stop(boolean)
+ * WTP keeps launching in launch configs and stopping in
+ * the server behavior. We should not change that and offer
+ * stopping-functionalities in launch delegates.
+ *
+ * @param behaviour
+ */
+ @Deprecated
public static void launchStopServerCommand(JBossServerBehavior behaviour) {
- if( LaunchCommandPreferences.ignoreLaunchCommand(behaviour.getServer())) {
+ if (LaunchCommandPreferences.ignoreLaunchCommand(behaviour.getServer())) {
behaviour.setServerStopping();
behaviour.setServerStopped();
return;
@@ -110,26 +124,25 @@
config = behaviour.getServer().getLaunchConfiguration(false, new
NullProgressMonitor());
String defaultCmd = getDefaultStopCommand(behaviour.getServer(), true);
command2 = config == null ? defaultCmd :
- RSELaunchConfigUtils.getShutdownCommand(config, defaultCmd);
+ RSELaunchConfigProperties.getShutdownCommand(config, defaultCmd);
behaviour.setServerStopping();
ServerShellModel model =
RSEHostShellModel.getInstance().getModel(behaviour.getServer());
- model.executeRemoteCommand("/", command2, new String[]{}, new
NullProgressMonitor(), 10000, true);
- if( model.getStartupShell() != null && model.getStartupShell().isActive())
+ model.executeRemoteCommand("/", command2, new String[] {}, new
NullProgressMonitor(), 10000, true);
+ if (model.getStartupShell() != null && model.getStartupShell().isActive())
model.getStartupShell().writeToShell("exit");
behaviour.setServerStopped();
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
behaviour.setServerStarted();
ServerLogger.getDefault().log(behaviour.getServer(), ce.getStatus());
}
}
-
-
+
public boolean preLaunchCheck(ILaunchConfiguration configuration,
String mode, IProgressMonitor monitor) throws CoreException {
- // ping if up
+ // ping if up
final JBossServerBehavior beh =
JBossServerBehaviorUtils.getServerBehavior(configuration);
boolean started = WebPortPoller.onePing(beh.getServer());
- if( started ) {
+ if (started) {
beh.setServerStarting();
beh.setServerStarted();
return false;
@@ -148,56 +161,58 @@
public void setupLaunchConfiguration(
ILaunchConfigurationWorkingCopy workingCopy, IServer server)
throws CoreException {
- boolean detectStartupCommand = RSELaunchConfigUtils.isDetectStartupCommand(workingCopy,
true);
- String currentStartupCmd = RSELaunchConfigUtils.getStartupCommand(workingCopy);
- if( detectStartupCommand || currentStartupCmd == null ||
"".equals(currentStartupCmd)) {
- RSELaunchConfigUtils.setStartupCommand(getDefaultLaunchCommand(workingCopy),
workingCopy);
- }
-
- boolean detectShutdownCommand =
RSELaunchConfigUtils.isDetectShutdownCommand(workingCopy, true);
- String currentStopCmd = RSELaunchConfigUtils.getShutdownCommand(workingCopy);
- if( detectShutdownCommand || currentStopCmd == null ||
"".equals(currentStopCmd)) {
- RSELaunchConfigUtils.setShutdownCommand(getDefaultStopCommand(server), workingCopy);
- }
+ new RSELaunchConfigurator(getDefaultLaunchCommand(workingCopy),
getDefaultStopCommand(server))
+ .configure(workingCopy);
/*
- * /usr/lib/jvm/jre/bin/java -Dprogram.name=run.sh -server -Xms1530M -Xmx1530M
- * -XX:PermSize=425M -XX:MaxPermSize=425M -Dorg.jboss.resolver.warning=true
- * -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
- * -Djboss.partition.udpGroup=228.1.2.3 -Djboss.webpartition.mcast_port=45577
- * -Djboss.hapartition.mcast_port=45566 -Djboss.ejb3entitypartition.mcast_port=43333
- * -Djboss.ejb3sfsbpartition.mcast_port=45551 -Djboss.jvmRoute=node-10.209.183.100
- * -Djboss.gossip_port=12001 -Djboss.gossip_refresh=5000 -Djava.awt.headless=true
- * -Djava.net.preferIPv4Stack=true
- * -Djava.endorsed.dirs=/opt/jboss-eap-5.1.0.Beta/jboss-as/lib/endorsed
- * -classpath /opt/jboss-eap-5.1.0.Beta/jboss-as/bin/run.jar org.jboss.Main
- * -c default -b 10.209.183.100
+ * /usr/lib/jvm/jre/bin/java -Dprogram.name=run.sh -server -Xms1530M
+ * -Xmx1530M -XX:PermSize=425M -XX:MaxPermSize=425M
+ * -Dorg.jboss.resolver.warning=true
+ * -Dsun.rmi.dgc.client.gcInterval=3600000
+ * -Dsun.rmi.dgc.server.gcInterval=3600000
+ * -Djboss.partition.udpGroup=228.1.2.3
+ * -Djboss.webpartition.mcast_port=45577
+ * -Djboss.hapartition.mcast_port=45566
+ * -Djboss.ejb3entitypartition.mcast_port=43333
+ * -Djboss.ejb3sfsbpartition.mcast_port=45551
+ * -Djboss.jvmRoute=node-10.209.183.100 -Djboss.gossip_port=12001
+ * -Djboss.gossip_refresh=5000 -Djava.awt.headless=true
+ * -Djava.net.preferIPv4Stack=true
+ * -Djava.endorsed.dirs=/opt/jboss-eap-5.1.0.Beta/jboss-as/lib/endorsed
+ * -classpath /opt/jboss-eap-5.1.0.Beta/jboss-as/bin/run.jar
+ * org.jboss.Main -c default -b 10.209.183.100
*/
}
-
+
+ @Deprecated
public static String getDefaultStopCommand(IServer server) {
try {
return getDefaultStopCommand(server, false);
- } catch(CoreException ce) {/* ignore, INTENTIONAL */}
+ } catch (CoreException ce) {/* ignore, INTENTIONAL */
+ }
return null;
}
-
+
+ @Deprecated
public static String getDefaultStopCommand(IServer server, boolean errorOnFail) throws
CoreException {
String rseHome = null;
rseHome = RSEUtils.getRSEHomeDir(server, errorOnFail);
JBossServer jbs = ServerConverter.getJBossServer(server);
-
+
String stop = new Path(rseHome)
- .append(IJBossRuntimeResourceConstants.BIN)
- .append(IJBossRuntimeResourceConstants.SHUTDOWN_SH).toString()
- + IJBossRuntimeConstants.SPACE;
-
+ .append(IJBossRuntimeResourceConstants.BIN)
+ .append(IJBossRuntimeResourceConstants.SHUTDOWN_SH).toString()
+ + IJBossRuntimeConstants.SPACE;
+
// Pull args from single utility method
- stop += StopLaunchConfiguration.getDefaultArgs(jbs);
+ // stop += StopLaunchConfiguration.getDefaultArgs(jbs);
+ JBossBehaviourDelegate delegate = ServerUtil.checkedGetBehaviorDelegate(server);
+ stop += delegate.getDefaultStopArguments();
return stop;
}
+ @Deprecated
public static IServer findServer(ILaunchConfiguration config) throws CoreException {
- String serverId = config.getAttribute("server-id", (String)null);
+ String serverId = config.getAttribute("server-id", (String) null);
JBossServer jbs = ServerConverter.findJBossServer(serverId);
if (jbs == null) {
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
@@ -205,31 +220,31 @@
}
return jbs.getServer();
}
-
+
public static String getDefaultLaunchCommand(ILaunchConfiguration config) throws
CoreException {
- IServer server = findServer(config);
- String rseHome = server.getAttribute(RSEUtils.RSE_SERVER_HOME_DIR, "");
+ String serverId = JBossLaunchConfigProperties.getServerId(config);
+ JBossServer jbossServer = ServerConverter.checkedFindJBossServer(serverId);
+ String rseHome = jbossServer.getServer().getAttribute(RSEUtils.RSE_SERVER_HOME_DIR,
"");
// initialize startup command to something reasonable
String currentArgs =
config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
""); //$NON-NLS-1$
String currentVMArgs =
config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
//$NON-NLS-1$
-
- currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
+
+ currentVMArgs = ArgsUtil.setArg(currentVMArgs, null,
IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
new Path(rseHome).append(
IJBossRuntimeResourceConstants.LIB).append(
- IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
+ IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
String libPath = new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN)
.append(IJBossRuntimeResourceConstants.NATIVE).toOSString();
- currentVMArgs= ArgsUtil.setArg(currentVMArgs, null,
+ currentVMArgs = ArgsUtil.setArg(currentVMArgs, null,
IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH,
libPath, true);
-
- String cmd = "java " + currentVMArgs + " -classpath " +
- new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(
- IJBossRuntimeResourceConstants.START_JAR).toString() + IJBossRuntimeConstants.SPACE
+
- IJBossRuntimeConstants.START_MAIN_TYPE + IJBossRuntimeConstants.SPACE + currentArgs
+ "&";
+ String cmd = "java " + currentVMArgs + " -classpath " +
+ new Path(rseHome).append(IJBossRuntimeResourceConstants.BIN).append(
+ IJBossRuntimeResourceConstants.START_JAR).toString() + IJBossRuntimeConstants.SPACE
+
+ IJBossRuntimeConstants.START_MAIN_TYPE + IJBossRuntimeConstants.SPACE + currentArgs +
"&";
return cmd;
}
}