Author: rob.stryker(a)jboss.com
Date: 2007-09-06 00:52:37 -0400 (Thu, 06 Sep 2007)
New Revision: 3467
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/AbstractJBossLaunchConfigType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/DeployableLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/IJBossServerLaunchDefaults.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/JBossServerStartupLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/ServerLaunchDefaults.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/StopLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLauncher.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/IJBossServerLaunchDefaults.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/ServerLaunchDefaults.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ASLaunchConfigurationConverter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
Log:
Refactor of launch configurations. Specifically:
Each type (start, stop, twiddle) now have their own launch configuration type, now
decoupled.
UI code was simplified immensely
TwiddleDialog and TwiddleLauncher refactored to use new launch type
"Stop" method of ServerBehavior classes modified to use new launches
Fixed classpath bug where users could not modify classpath properly
JBIDE-400
JBIDE-786
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2007-09-06
04:52:32 UTC (rev 3466)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2007-09-06
04:52:37 UTC (rev 3467)
@@ -22,6 +22,8 @@
org.apache.ant
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.as.core,
+ org.jboss.ide.eclipse.as.core.client,
+ org.jboss.ide.eclipse.as.core.launch,
org.jboss.ide.eclipse.as.core.model,
org.jboss.ide.eclipse.as.core.model.descriptor,
org.jboss.ide.eclipse.as.core.packages,
@@ -33,6 +35,7 @@
org.jboss.ide.eclipse.as.core.server,
org.jboss.ide.eclipse.as.core.server.attributes,
org.jboss.ide.eclipse.as.core.server.stripped,
+ org.jboss.ide.eclipse.as.core.server.xpl,
org.jboss.ide.eclipse.as.core.singledeployable,
org.jboss.ide.eclipse.as.core.util
Bundle-ClassPath: dom4j-1.6.1.jar,
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/AbstractJBossLaunchConfigType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/AbstractJBossLaunchConfigType.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/AbstractJBossLaunchConfigType.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,184 @@
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+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.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.ExecutionArguments;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+public abstract class AbstractJBossLaunchConfigType extends
AbstractJavaLaunchConfigurationDelegate {
+ protected static final String SERVER_ID = "server-id";
+
+ protected void preLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) {
+ // override me
+ }
+ protected void postLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) {
+ // override me
+ }
+
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ preLaunch(configuration, mode, launch, monitor);
+ actualLaunch(configuration, mode, launch, monitor);
+ postLaunch(configuration, mode, launch, monitor);
+ }
+
+ protected void actualLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ // And off we go!
+ IVMInstall vm = verifyVMInstall(configuration);
+ IVMRunner runner = vm.getVMRunner(mode);
+
+ File workingDir = verifyWorkingDirectory(configuration);
+ String workingDirName = null;
+ if (workingDir != null)
+ workingDirName = workingDir.getAbsolutePath();
+
+ // Program & VM args
+ String pgmArgs = getProgramArguments(configuration);
+ String vmArgs = getVMArguments(configuration);
+ ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
+
+ // VM-specific attributes
+ Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
+
+ // Classpath
+ String[] classpath = getClasspath(configuration);
+
+ // Create VM config
+ String mainType = getMainTypeName(configuration);
+ VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainType, classpath);
+ runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
+ runConfig.setVMArguments(execArgs.getVMArgumentsArray());
+ runConfig.setWorkingDirectory(workingDirName);
+ runConfig.setVMSpecificAttributesMap(vmAttributesMap);
+
+ // Bootpath
+ String[] bootpath = getBootpath(configuration);
+ if (bootpath != null && bootpath.length > 0)
+ runConfig.setBootClassPath(bootpath);
+
+ setDefaultSourceLocator(launch, configuration);
+
+ // Launch the configuration
+ runner.run(runConfig, launch, monitor);
+ }
+
+
+ protected static JBossServer findJBossServer(String serverId) throws CoreException {
+ if( serverId == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"No server specified"));
+
+ IServer s = ServerCore.findServer(serverId);
+ if( s == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Server Not Found"));
+
+ JBossServer jbs = ServerConverter.getJBossServer(s);
+ if( jbs == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Server Not Found"));
+
+ return jbs;
+ }
+
+ protected static IJBossServerRuntime findJBossServerRuntime(IServer server) throws
CoreException {
+ IRuntime rt = server.getRuntime();
+ IJBossServerRuntime jbrt = null;
+ if( rt != null )
+ jbrt = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ if( jbrt == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime Not Found"));
+ return jbrt;
+ }
+
+ protected static void addCPEntry(ArrayList list, JBossServer jbs, String relative) {
+ list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new
Path(getServerHome(jbs)).append(relative)));
+ }
+
+ protected static ArrayList convertClasspath(ArrayList cp, IVMInstall vmInstall) {
+ if (vmInstall != null) {
+ try {
+ cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
+ new Path(JavaRuntime.JRE_CONTAINER).append(
+ "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
+ .append(vmInstall.getName()),
+ IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
+ } catch (Exception e) {
+ // ignore
+ }
+
+ IPath jrePath = new Path(vmInstall.getInstallLocation()
+ .getAbsolutePath());
+ if (jrePath != null) {
+ IPath toolsPath = jrePath.append("lib").append("tools.jar");
+ if (toolsPath.toFile().exists()) {
+ cp.add(JavaRuntime
+ .newArchiveRuntimeClasspathEntry(toolsPath));
+ }
+ }
+ }
+
+ Iterator cpi = cp.iterator();
+ ArrayList list = new ArrayList();
+ while (cpi.hasNext()) {
+ IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) cpi.next();
+ try {
+ list.add(entry.getMemento());
+ } catch (Exception e) {
+ // Trace.trace(Trace.SEVERE, "Could not resolve classpath entry:
+ // " + entry, e);
+ }
+ }
+
+ return list;
+ }
+
+ protected static void addDirectory(String serverHome, ArrayList classpath,
+ String dirName) {
+ String libPath = serverHome + File.separator + dirName;
+ File libDir = new File(libPath);
+ File libs[] = libDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return (name != null && name.endsWith("jar"));
+ }
+ });
+
+ if (libs == null)
+ return;
+
+ for (int i = 0; i < libs.length; i++) {
+ classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(
+ libPath + File.separator + libs[i].getName())));
+ }
+ } // end method
+
+
+ public static String getServerHome(JBossServer jbs) {
+ return jbs.getServer().getRuntime().getLocation().toOSString();
+ }
+}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/DeployableLaunchConfiguration.java
(from rev 3446,
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/DeployableLaunchConfiguration.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/DeployableLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,34 @@
+package org.jboss.ide.eclipse.as.core.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.core.server.JBossServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.stripped.DeployableServerBehavior;
+
+public class DeployableLaunchConfiguration implements
+ ILaunchConfigurationDelegate {
+
+ public static final String ACTION_KEY =
"org.jboss.ide.eclipse.as.core.server.stripped.DeployableLaunchConfiguration.Action";
+ public static final String START = "_START_";
+ public static final String STOP = "_STOP_";
+
+ public static DeployableServerBehavior getServerBehavior(ILaunchConfiguration
configuration) throws CoreException {
+ IServer server = ServerUtil.getServer(configuration);
+ DeployableServerBehavior jbossServerBehavior = (DeployableServerBehavior)
server.getAdapter(DeployableServerBehavior.class);
+ return jbossServerBehavior;
+ }
+
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ String action = configuration.getAttribute(ACTION_KEY, START);
+ DeployableServerBehavior behavior = getServerBehavior(configuration);
+ if( START.equals(action)) behavior.setServerStarted();
+ if( STOP.equals(action)) behavior.setServerStopped();
+ }
+}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/IJBossServerLaunchDefaults.java
(from rev 3446,
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/IJBossServerLaunchDefaults.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/IJBossServerLaunchDefaults.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/IJBossServerLaunchDefaults.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+
+/**
+ * Setting launch defaults. Each server can have it's own implementation
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public interface IJBossServerLaunchDefaults {
+ public String getStartArgs();
+ public String getStopArgs();
+ public String getVMArgs();
+ public List getRuntimeClasspath(String action);
+ public String getStartJar();
+ public String getShutdownJar();
+ public String getStartMainType();
+ public String getStopMainType();
+
+ public void fillDefaults(ILaunchConfigurationWorkingCopy wc) throws CoreException;
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/JBossServerStartupLaunchConfiguration.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/JBossServerStartupLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,167 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerType;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.JBossServerBehavior;
+
+public class JBossServerStartupLaunchConfiguration extends AbstractJBossLaunchConfigType
{
+
+ protected static final char[] INVALID_CHARS = new char[] {'\\', '/',
':', '*', '?', '"', '<', '>',
'|', '\0', '@', '&'};
+
+ private static final String LAUNCH_TYPE =
"org.jboss.ide.eclipse.as.core.server.startupConfiguration";
+ private static final String DEFAULTS_SET = "jboss.defaults.been.set";
+ private static final String START_JAR_LOC = "bin" + Path.SEPARATOR +
"run.jar";
+ private static final String START_MAIN_TYPE = "org.jboss.Main";
+
+
+ public static ILaunchConfigurationWorkingCopy setupLaunchConfiguration(IServer server,
String action) throws CoreException {
+ ILaunchConfigurationWorkingCopy config = createLaunchConfiguration(server);
+ setupLaunchConfiguration(config, server);
+ return config;
+ }
+
+ public static void setupLaunchConfiguration(
+ ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
+ ensureDefaultsSet(workingCopy, server);
+ }
+
+ public static void ensureDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server)
throws CoreException {
+ if( wc.getAttribute(DEFAULTS_SET, (String)null ) == null ) {
+ JBossServer jbs = findJBossServer(server.getId());
+ IJBossServerRuntime jbrt = findJBossServerRuntime(server);
+ String serverHome = getServerHome(jbs);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType(LAUNCH_TYPE);
+
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
START_MAIN_TYPE);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
+ ArrayList classpath = new ArrayList();
+ addCPEntry(classpath, jbs, START_JAR_LOC);
+ ArrayList runtimeClassPaths = convertClasspath(classpath, jbrt.getVM());
+ String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
+ wc.setAttribute(cpKey, runtimeClassPaths);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ wc.setAttribute(DEFAULTS_SET, true);
+ }
+ }
+
+ public static String getDefaultArgs(JBossServer jbs) throws CoreException {
+ IJBossServerRuntime rt = findJBossServerRuntime(jbs.getServer());
+ if (rt != null) {
+ return "--configuration=" + rt.getJBossConfiguration();
+ }
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime not found"));
+ }
+
+
+ public void postLaunch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) {
+ try {
+ IProcess[] processes = launch.getProcesses();
+ JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
+ jbsBehavior.setProcess(processes[0]);
+ jbsBehavior.serverStarting();
+ } catch( CoreException ce ) {
+ // report
+ }
+ }
+
+ public static JBossServerBehavior getServerBehavior(ILaunchConfiguration configuration)
throws CoreException {
+ IServer server = ServerUtil.getServer(configuration);
+ JBossServerBehavior jbossServerBehavior = (JBossServerBehavior)
server.getAdapter(JBossServerBehavior.class);
+ return jbossServerBehavior;
+ }
+
+ protected static String getValidLaunchConfigurationName(String s) {
+ if (s == null || s.length() == 0)
+ return "1";
+ int size = INVALID_CHARS.length;
+ for (int i = 0; i < size; i++) {
+ s = s.replace(INVALID_CHARS[i], '_');
+ }
+ return s;
+ }
+
+ /**
+ * Will create a launch configuration for the server
+ * if one does not already exist.
+ */
+ public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
+ ILaunchConfigurationType launchConfigType =
+ ((ServerType) server.getServerType()).getLaunchConfigurationType();
+ if (launchConfigType == null)
+ return null;
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfiguration[] launchConfigs = null;
+ try {
+ launchConfigs = launchManager.getLaunchConfigurations(launchConfigType);
+ } catch (CoreException e) {
+ // ignore
+ }
+
+ if (launchConfigs != null) {
+ int size = launchConfigs.length;
+ for (int i = 0; i < size; i++) {
+ try {
+ String serverId = launchConfigs[i].getAttribute(SERVER_ID, (String) null);
+ if (server.getId().equals(serverId)) {
+ ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy();
+ return wc;
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ // create a new launch configuration
+ String launchName = getValidLaunchConfigurationName(server.getName());
+ launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
+ wc.setAttribute(SERVER_ID, server.getId());
+ return wc;
+ }
+
+}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/ServerLaunchDefaults.java
(from rev 3446,
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/ServerLaunchDefaults.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/ServerLaunchDefaults.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/ServerLaunchDefaults.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,302 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+
+/**
+ * A class of launch defaults including how to start, stop, and twiddle a
+ * server.
+ *
+ * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
+ *
+ */
+public class ServerLaunchDefaults implements IJBossServerLaunchDefaults {
+
+ @Override
+ public void fillDefaults(ILaunchConfigurationWorkingCopy wc)
+ throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List getRuntimeClasspath(String action) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getShutdownJar() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStartArgs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStartJar() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStartMainType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStopArgs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getStopMainType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getVMArgs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+// /*
+// * Can be overwritten by subclasses
+// */
+// protected String startMainType = "org.jboss.Main";
+// protected String defaultShutdownArgs = "-S";
+// protected String runJar = "bin" + File.separator + "run.jar";
+// protected IServer server;
+// protected IJBossServerRuntime runtime;
+// protected JBossServer jbServer;
+//
+// public ServerLaunchDefaults(IServer server) {
+// this.server = server;
+// }
+//
+// protected JBossServer getJBServer() {
+// if (jbServer == null) {
+// try {
+// jbServer = (JBossServer) server.loadAdapter(JBossServer.class,
+// new NullProgressMonitor());
+// } catch (Exception e) {
+// }
+// }
+// return jbServer;
+// }
+//
+// protected IJBossServerRuntime getRuntime() {
+// if (runtime == null) {
+// try {
+// runtime = (IJBossServerRuntime) server.getRuntime()
+// .loadAdapter(IJBossServerRuntime.class,
+// new NullProgressMonitor());
+// } catch (Exception e) {
+// }
+// }
+// return runtime;
+// }
+//
+// public void fillDefaults(ILaunchConfigurationWorkingCopy workingCopy)
+// throws CoreException {
+// IJBossServerRuntime runtime = getRuntime();
+// String argsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS;
+// String vmArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS;
+//
+// String START_SUFFIX = JBossServerStartupLaunchConfiguration.PRGM_ARGS_START_SUFFIX;
+// String STOP_SUFFIX = JBossServerStartupLaunchConfiguration.PRGM_ARGS_STOP_SUFFIX;
+//
+// // START items
+// workingCopy.setAttribute(argsKey + START_SUFFIX, getStartArgs());
+// workingCopy.setAttribute(vmArgsKey + START_SUFFIX, getVMArgs());
+//
+// // STOP items
+// workingCopy.setAttribute(argsKey + STOP_SUFFIX, getStopArgs());
+// workingCopy.setAttribute(vmArgsKey + STOP_SUFFIX, getVMArgs());
+//
+// /* Now add in the main types */
+// String mainKey = IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME;
+// workingCopy.setAttribute(mainKey + START_SUFFIX, getStartMainType());
+// workingCopy.setAttribute(mainKey + STOP_SUFFIX, getStopMainType());
+//
+// String wdKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY;
+// String wdVal = getServerHome() + Path.SEPARATOR + "bin";
+// workingCopy.setAttribute(wdKey + START_SUFFIX, wdVal);
+// workingCopy.setAttribute(wdKey + STOP_SUFFIX, wdVal);
+//
+// workingCopy
+// .setAttribute(
+// IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
+// false);
+// String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
+// workingCopy.setAttribute(cpKey + START_SUFFIX,
+// getRuntimeClasspath(JBossServerStartupLaunchConfiguration.START));
+// workingCopy.setAttribute(cpKey + STOP_SUFFIX,
+// getRuntimeClasspath(JBossServerStartupLaunchConfiguration.STOP));
+// }
+//
+// public String getStartArgs() {
+// IJBossServerRuntime rt = getRuntime();
+// if (rt != null) {
+// return "--configuration=" + rt.getJBossConfiguration();
+// }
+// return "";
+// }
+//
+// public String getServerHome() {
+// return server.getRuntime().getLocation().toOSString();
+// }
+//
+// public String getConfigurationPath() {
+// try {
+// return getServerHome() + Path.SEPARATOR + "server" + Path.SEPARATOR
+// + getRuntime().getJBossConfiguration();
+// } catch (Exception e) {
+// }
+// return "";
+// }
+//
+// public String getStartJar() {
+// return getServerHome() + Path.SEPARATOR + runJar;
+// }
+//
+// public String getShutdownJar() {
+// return getServerHome() + Path.SEPARATOR + shutdownJar;
+// }
+//
+// public String getStartMainType() {
+// return startMainType;
+// }
+//
+// public String getStopMainType() {
+// return stopMainType;
+// }
+//
+// public String getStopArgs() {
+// return defaultShutdownArgs;
+// }
+//
+// public String getVMArgs() {
+// return defaultVMArgs;
+// }
+//
+// public List getRuntimeClasspath(String action) {
+// String serverHome = getServerHome();
+// ArrayList classpath = new ArrayList();
+//
+// if (action.equals(JBossServerStartupLaunchConfiguration.START)) {
+// classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(
+// getStartJar())));
+// } else if (action.equals(JBossServerStartupLaunchConfiguration.STOP)) {
+// classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(
+// getShutdownJar())));
+// }
+// ArrayList runtimeClassPaths = convertClasspath(classpath, runtime
+// .getVM());
+// return runtimeClassPaths;
+// }
+//
+// private ArrayList convertClasspath(ArrayList cp, IVMInstall vmInstall) {
+// if (vmInstall != null) {
+// try {
+// cp
+// .add(JavaRuntime
+// .newRuntimeContainerClasspathEntry(
+// new Path(JavaRuntime.JRE_CONTAINER)
+// .append(
+// "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
+// .append(vmInstall.getName()),
+// IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
+// } catch (Exception e) {
+// // ignore
+// }
+//
+// IPath jrePath = new Path(vmInstall.getInstallLocation()
+// .getAbsolutePath());
+// if (jrePath != null) {
+// IPath toolsPath = jrePath.append("lib").append("tools.jar");
+// if (toolsPath.toFile().exists()) {
+// cp.add(JavaRuntime
+// .newArchiveRuntimeClasspathEntry(toolsPath));
+// }
+// }
+// }
+//
+// Iterator cpi = cp.iterator();
+// ArrayList list = new ArrayList();
+// while (cpi.hasNext()) {
+// IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) cpi.next();
+// try {
+// list.add(entry.getMemento());
+// } catch (Exception e) {
+// // Trace.trace(Trace.SEVERE, "Could not resolve classpath entry:
+// // " + entry, e);
+// }
+// }
+//
+// return list;
+// }
+//
+// private void addDirectory(String serverHome, ArrayList classpath,
+// String dirName) {
+// String libPath = serverHome + File.separator + dirName;
+// File libDir = new File(libPath);
+// File libs[] = libDir.listFiles(new FilenameFilter() {
+// public boolean accept(File dir, String name) {
+// return (name != null && name.endsWith("jar"));
+// }
+// });
+//
+// if (libs == null)
+// return;
+//
+// for (int i = 0; i < libs.length; i++) {
+// classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(
+// libPath + File.separator + libs[i].getName())));
+// }
+// } // end method
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/StopLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/StopLaunchConfiguration.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/StopLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,76 @@
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+
+
+public class StopLaunchConfiguration extends AbstractJBossLaunchConfigType {
+
+ public static final String STOP_LAUNCH_TYPE =
"org.jboss.ide.eclipse.as.core.server.stopLaunchConfiguration";
+ public static final String STOP_MAIN_TYPE = "org.jboss.Shutdown";
+ public static final String STOP_JAR_LOC = "bin" + File.separator +
"shutdown.jar";
+
+ public static void stop(IServer server) {
+ try {
+ ILaunchConfigurationWorkingCopy wc = createLaunchConfiguration(server);
+ wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ // report it from here
+ }
+ }
+
+ protected void preLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) {
+ }
+
+
+ public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
+ JBossServer jbs = findJBossServer(server.getId());
+ IJBossServerRuntime jbrt = findJBossServerRuntime(server);
+ String serverHome = getServerHome(jbs);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType(STOP_LAUNCH_TYPE);
+
+ String launchName = TwiddleLaunchConfiguration.class.getName();
+ launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
+ wc.setAttribute(SERVER_ID, server.getId());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
STOP_MAIN_TYPE);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
+ ArrayList classpath = new ArrayList();
+ addCPEntry(classpath, jbs, STOP_JAR_LOC);
+ ArrayList runtimeClassPaths = convertClasspath(classpath, jbrt.getVM());
+ String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
+ wc.setAttribute(cpKey, runtimeClassPaths);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+
+ return wc;
+ }
+
+ public static String getDefaultArgs(JBossServer jbs) throws CoreException {
+ String args = "-S ";
+ if( jbs.getUsername() != null )
+ args += "-u " + jbs.getUsername() + " ";
+ if( jbs.getPassword() != null )
+ args += "-p " + jbs.getPassword() + " ";
+ return args;
+ }
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLaunchConfiguration.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,68 @@
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.JBossServer;
+
+public class TwiddleLaunchConfiguration extends AbstractJBossLaunchConfigType {
+
+ public static final String TWIDDLE_LAUNCH_TYPE =
"org.jboss.ide.eclipse.as.core.server.twiddleConfiguration";
+
+ protected static final String TWIDDLE_MAIN_TYPE =
"org.jboss.console.twiddle.Twiddle";
+ protected static final String TWIDDLE_JAR_LOC = "bin" + File.separator +
"twiddle.jar";
+
+ public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
+ return createLaunchConfiguration(server, getDefaultArgs(server));
+ }
+
+ public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server,
String args) throws CoreException {
+ JBossServer jbs = findJBossServer(server.getId());
+ IJBossServerRuntime jbrt = findJBossServerRuntime(server);
+ String serverHome = getServerHome(jbs);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType(TWIDDLE_LAUNCH_TYPE);
+
+ String launchName = TwiddleLaunchConfiguration.class.getName();
+ launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
TWIDDLE_MAIN_TYPE);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
+
+ ArrayList classpath = new ArrayList();
+ addCPEntry(classpath, jbs, TWIDDLE_JAR_LOC);
+ // Twiddle requires more classes and I'm too lazy to actually figure OUT which ones
it needs.
+ addDirectory (serverHome, classpath, "lib");
+ addDirectory (serverHome, classpath, "lib" + File.separator +
"endorsed");
+ addDirectory (serverHome, classpath, "client");
+ ArrayList runtimeClassPaths = convertClasspath(classpath, jbrt.getVM());
+ String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
+ wc.setAttribute(cpKey, runtimeClassPaths);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+
+ return wc;
+ }
+
+ public static String getDefaultArgs(IServer server) throws CoreException {
+ JBossServer jbs = findJBossServer(server.getId());
+ String twiddleArgs = "-s " + jbs.getServer().getHost() + ":"
+ + jbs.getJNDIPort() + " -a jmx/rmi/RMIAdaptor ";
+ if( jbs.getUsername() != null )
+ twiddleArgs += "-u " + jbs.getUsername() + " ";
+ if( jbs.getPassword() != null )
+ twiddleArgs += "-p " + jbs.getPassword() + " ";
+ return twiddleArgs;
+ }
+
+}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLauncher.java
(from rev 3446,
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLauncher.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/launch/TwiddleLauncher.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -0,0 +1,210 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.core.launch;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.IStreamListener;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+
+public class TwiddleLauncher {
+
+ /**
+ * Create one launch for each String of arguments.
+ * Each element in the array is a COMPLETE LIST of arguments.
+ * For example:
+ * twiddleArgs[0] = "-s localhost:1099 -a jmx/rmi/RMIAdaptor get
\"whatever\""
+ * twiddleArgs[1] = "-s localhost:1099 -a jmx/rmi/RMIAdaptor get
\"whatever2\""
+ *
+ * @param twiddleArgs
+ * @param jbServer
+ * @param seed
+ * @return
+ */
+ public static ProcessData[] launchTwiddles(String[] twiddleArgs, IServer server, boolean
addPrefix) throws CoreException {
+ ILaunchConfigurationWorkingCopy wc;
+ ArrayList list = new ArrayList();
+ for( int i = 0; i < twiddleArgs.length; i++ ) {
+ String args2 = addPrefix ? TwiddleLaunchConfiguration.getDefaultArgs(server) +
twiddleArgs[i] : twiddleArgs[i];
+ wc = TwiddleLaunchConfiguration.createLaunchConfiguration(server, args2);
+ ILaunch launch = wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor(), false,
false);
+ list.addAll(Arrays.asList(toProcessDatas(launch.getProcesses())));
+ }
+
+ ProcessData[] ret = new ProcessData[list.size()];
+ list.toArray(ret);
+
+ return ret;
+ }
+
+ protected static ProcessData[] toProcessDatas(IProcess[] processes) {
+ ProcessData[] datas = new ProcessData[processes.length];
+ for( int i = 0; i < processes.length; i++ ) {
+ datas[i] = new ProcessData(processes[i], "");
+ datas[i].startListening();
+ }
+ return datas;
+ }
+
+ private boolean canceled = false;
+ private int delay = 500;
+
+ public void setCanceled() {
+ canceled = true;
+ }
+
+ public ProcessData[] getTwiddleResults(IServer server, String args, boolean addPrefix )
{
+ ProcessData[] processes;
+ try {
+ processes = TwiddleLauncher.launchTwiddles(new String[] { args }, server, addPrefix);
+ } catch( CoreException ce ) {
+ return new ProcessData[0];
+ }
+ waitForThreadsToTerminate(processes);
+
+ // stop listening
+ for( int i = 0; i < processes.length; i++ ) {
+ processes[i].stopListening();
+ if( canceled ) {
+ try {
+ // if canceled, terminate all twiddle processes
+ processes[i].getProcess().terminate();
+ } catch( Exception e ) {}
+ }
+ }
+
+ return processes;
+ }
+
+ protected void waitForThreadsToTerminate(ProcessData[] processes) {
+ boolean allTerminated = false;
+ while( !allTerminated && !canceled) {
+ allTerminated = true;
+ for( int i = 0; i < processes.length; i++ ) {
+ if( processes[i].getProcess().isTerminated() == false ) {
+ allTerminated = false;
+ }
+ }
+ if( !allTerminated ) {
+ // sleep
+ try {
+ Thread.sleep(delay);
+ } catch( InterruptedException ie ) {
+ }
+ }
+ }
+ }
+
+ public static class ProcessData implements IStreamListener {
+ private String args;
+ private String processType;
+
+ private IProcess process;
+ private IStreamMonitor outMonitor;
+ private IStreamMonitor errMonitor;
+
+ private String out, err;
+
+ public ProcessData(IProcess process, String processType) {
+ this(null, process, processType);
+ try {
+ this.args = process.getLaunch().getLaunchConfiguration().
+ getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
(String)null);
+ } catch( CoreException ce ) {
+ }
+
+ }
+
+ public ProcessData(String args, IProcess process, String processType) {
+ this.args = args;
+ this.process = process;
+ this.processType = processType;
+
+ //ASDebug.p("process is " + process, this);
+ //ASDebug.p("Stream Proxy is " + process.getStreamsProxy(), this);
+ this.outMonitor = process.getStreamsProxy().getOutputStreamMonitor();
+ this.errMonitor = process.getStreamsProxy().getErrorStreamMonitor();
+
+ out = "";
+ err = "";
+ }
+
+ public void startListening() {
+ outMonitor.addListener(this);
+ errMonitor.addListener(this);
+ }
+
+ public void stopListening() {
+ outMonitor.removeListener(this);
+ errMonitor.removeListener(this);
+ }
+
+ public void resetStrings() {
+ out = "";
+ err = "";
+ }
+
+ public void destroy() {
+ stopListening();
+ resetStrings();
+ }
+
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ if( monitor == outMonitor ) {
+ out += text;
+ } else if( monitor == errMonitor ) {
+ err += text;
+ }
+ }
+
+ public String getArgs() {
+ return args;
+ }
+
+ public String getErr() {
+ return err;
+ }
+
+ public String getOut() {
+ return out;
+ }
+
+ public String getProcesType() {
+ return processType;
+ }
+
+ public IProcess getProcess() {
+ return process;
+ }
+
+ }
+
+}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/IJBossServerLaunchDefaults.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/IJBossServerLaunchDefaults.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/IJBossServerLaunchDefaults.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.runtime;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-
-/**
- * Setting launch defaults. Each server can have it's own implementation
- * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
- *
- */
-public interface IJBossServerLaunchDefaults {
- public String getStartArgs();
- public String getStopArgs();
- public String getVMArgs();
- public List getRuntimeClasspath(String action);
- public String getStartJar();
- public String getShutdownJar();
- public String getTwiddleJar();
- public String getStartMainType();
- public String getStopMainType();
- public String getTwiddleMainType();
-
-
- public void fillDefaults(ILaunchConfigurationWorkingCopy wc) throws CoreException;
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/ServerLaunchDefaults.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/ServerLaunchDefaults.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/ServerLaunchDefaults.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -1,276 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.runtime.server;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.runtime.IJBossServerLaunchDefaults;
-import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.JBossServer;
-import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
-
-/**
- * A class of launch defaults including how to start, stop, and twiddle
- * a server.
- * @author <a href="rob.stryker(a)redhat.com">Rob Stryker</a>
- *
- */
-public class ServerLaunchDefaults implements IJBossServerLaunchDefaults {
-
- /*
- * Can be overwritten by subclasses
- */
- protected String startMainType = "org.jboss.Main";
- protected String stopMainType = "org.jboss.Shutdown";
- protected String twiddleMainType = "org.jboss.console.twiddle.Twiddle";
-
- protected String defaultShutdownArgs = "-S";
- protected String defaultVMArgs = "";
-
- protected String runJar = "bin" + File.separator + "run.jar";
- protected String shutdownJar = "bin" + File.separator +
"shutdown.jar";
- protected String twiddleJar = "bin" + File.separator +
"twiddle.jar";
-
-
-
- protected IServer server;
- protected IJBossServerRuntime runtime;
- protected JBossServer jbServer;
-
- public ServerLaunchDefaults(IServer server) {
- this.server = server;
- }
-
- protected JBossServer getJBServer() {
- if( jbServer == null ) {
- try {
- jbServer = (JBossServer)server.loadAdapter(JBossServer.class, new
NullProgressMonitor());
- } catch( Exception e) {
- }
- }
- return jbServer;
- }
- protected IJBossServerRuntime getRuntime() {
- if( runtime == null ) {
- try {
- runtime = (IJBossServerRuntime) server.getRuntime()
- .loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- } catch( Exception e ) {
- }
- }
- return runtime;
- }
-
- public void fillDefaults(ILaunchConfigurationWorkingCopy workingCopy) throws
CoreException {
- IJBossServerRuntime runtime = getRuntime();
- String argsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS;
- String vmArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS;
-
- String START_SUFFIX = JBossServerLaunchConfiguration.PRGM_ARGS_START_SUFFIX;
- String STOP_SUFFIX = JBossServerLaunchConfiguration.PRGM_ARGS_STOP_SUFFIX;
- String TWIDDLE_SUFFIX = JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX;
-
-
-
- // START items
- workingCopy.setAttribute(argsKey + START_SUFFIX, getStartArgs());
- workingCopy.setAttribute(vmArgsKey + START_SUFFIX, getVMArgs());
-
- // STOP items
- workingCopy.setAttribute(argsKey + STOP_SUFFIX, getStopArgs());
- workingCopy.setAttribute(vmArgsKey + STOP_SUFFIX, getVMArgs());
-
-
- int jndiPort = getJBServer().getJNDIPort();
- String host = server.getHost();
- String twiddleArgs = "-s " + host + ":" + jndiPort + " -a
jmx/rmi/RMIAdaptor ";
-
- workingCopy.setAttribute(argsKey + TWIDDLE_SUFFIX, twiddleArgs);
- workingCopy.setAttribute(vmArgsKey + TWIDDLE_SUFFIX, "");
-
-
-
- /* Now add in the main types */
- String mainKey = IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME;
- workingCopy.setAttribute(mainKey + START_SUFFIX, getStartMainType());
- workingCopy.setAttribute(mainKey + STOP_SUFFIX, getStopMainType());
- workingCopy.setAttribute(mainKey + TWIDDLE_SUFFIX, twiddleMainType);
-
- String wdKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY;
- String wdVal = getServerHome() + Path.SEPARATOR + "bin";
- workingCopy.setAttribute( wdKey + START_SUFFIX, wdVal);
- workingCopy.setAttribute( wdKey + STOP_SUFFIX, wdVal);
- workingCopy.setAttribute( wdKey + TWIDDLE_SUFFIX, wdVal);
-
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
false);
- String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
- workingCopy.setAttribute(cpKey + START_SUFFIX,
getRuntimeClasspath(JBossServerLaunchConfiguration.START));
- workingCopy.setAttribute(cpKey + STOP_SUFFIX,
getRuntimeClasspath(JBossServerLaunchConfiguration.STOP));
- workingCopy.setAttribute(cpKey + TWIDDLE_SUFFIX,
getRuntimeClasspath(JBossServerLaunchConfiguration.TWIDDLE));
- }
-
-
- public String getStartArgs() {
- IJBossServerRuntime rt = getRuntime();
- if( rt != null ) {
- return "--configuration=" + rt.getJBossConfiguration();
- }
- return "";
- }
-
-
- public String getServerHome() {
- return server.getRuntime().getLocation().toOSString();
- }
-
- public String getConfigurationPath() {
- try {
- return getServerHome() + Path.SEPARATOR + "server" + Path.SEPARATOR +
getRuntime().getJBossConfiguration();
- } catch( Exception e ) {
- }
- return "";
- }
-
- public String getStartJar() {
- return getServerHome() + Path.SEPARATOR + runJar;
- }
-
- public String getShutdownJar() {
- return getServerHome() + Path.SEPARATOR + shutdownJar;
- }
-
- public String getTwiddleJar() {
- return getServerHome() + Path.SEPARATOR + twiddleJar;
- }
-
- public String getStartMainType() {
- return startMainType;
- }
-
- public String getStopMainType() {
- return stopMainType;
- }
-
- public String getTwiddleMainType() {
- return twiddleMainType;
- }
-
- public String getStopArgs() {
- return defaultShutdownArgs;
- }
-
- public String getVMArgs() {
- return defaultVMArgs;
- }
-
-
- public List getRuntimeClasspath(String action) {
- String serverHome = getServerHome();
- ArrayList classpath = new ArrayList();
-
- if( action.equals(JBossServerLaunchConfiguration.START)) {
- classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(getStartJar())));
- } else if( action.equals(JBossServerLaunchConfiguration.STOP)) {
- classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new
Path(getShutdownJar())));
- } else if( action.equals(JBossServerLaunchConfiguration.TWIDDLE)) {
-
- // Twiddle requires more classes and I'm too lazy to actually figure OUT which
ones it needs.
- classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new
Path(getTwiddleJar())));
- addDirectory (serverHome, classpath, "lib");
- addDirectory (serverHome, classpath, "lib" + File.separator +
"endorsed");
- addDirectory (serverHome, classpath, "client");
- addDirectory (getConfigurationPath(), classpath, "lib");
- }
-
- ArrayList runtimeClassPaths = convertClasspath(classpath, runtime.getVM());
- return runtimeClassPaths;
- }
-
- private ArrayList convertClasspath(ArrayList cp, IVMInstall vmInstall) {
- if (vmInstall != null) {
- try {
- cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
- new Path(JavaRuntime.JRE_CONTAINER)
- .append("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
- .append(vmInstall.getName()), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
- } catch (Exception e) {
- // ignore
- }
-
- IPath jrePath = new Path(vmInstall.getInstallLocation().getAbsolutePath());
- if (jrePath != null) {
- IPath toolsPath = jrePath.append("lib").append("tools.jar");
- if (toolsPath.toFile().exists()) {
- cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(toolsPath));
- }
- }
- }
-
- Iterator cpi = cp.iterator();
- ArrayList list = new ArrayList();
- while (cpi.hasNext()) {
- IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) cpi.next();
- try {
- list.add(entry.getMemento());
- } catch (Exception e) {
- //Trace.trace(Trace.SEVERE, "Could not resolve classpath entry: " + entry,
e);
- }
- }
-
- return list;
- }
-
- private void addDirectory (String serverHome, ArrayList classpath, String dirName) {
- String libPath = serverHome + File.separator + dirName;
- File libDir = new File(libPath);
- File libs[] = libDir.listFiles(new FilenameFilter(){
- public boolean accept(File dir, String name)
- {
- return (name != null && name.endsWith("jar"));
- }
- });
-
- if( libs == null ) return;
-
- for (int i = 0; i < libs.length; i++)
- {
- classpath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(libPath +
File.separator + libs[i].getName())));
- }
- } // end method
-
-
-
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/JMXPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/JMXPoller.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/JMXPoller.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -47,12 +47,9 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
@@ -164,23 +161,12 @@
try {
ILaunchConfiguration lc = server.getLaunchConfiguration(true,
new NullProgressMonitor());
- String twiddleArgs = lc
- .getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS
- + JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX,
- (String) null);
-
// get user from the IServer, but override with launch configuration
String user = ServerConverter.getJBossServer(server).getUsername();
- String userLaunch = ArgsUtil.getValue(twiddleArgs, "-u",
"--user");
- user = userLaunch == null ? user : userLaunch;
// get password from the IServer, but override with launch configuration
String pass = ServerConverter.getJBossServer(server).getPassword();
- String passwordLaunch = ArgsUtil.getValue(twiddleArgs, "-p",
"--password");
- pass = passwordLaunch == null ? pass : passwordLaunch;
-
// get our methods
Class simplePrincipal = Thread.currentThread()
.getContextClassLoader().loadClass(
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -44,11 +44,12 @@
import org.eclipse.wst.server.core.model.IURLProvider;
import org.eclipse.wst.server.core.model.ServerDelegate;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.launch.IJBossServerLaunchDefaults;
+import org.jboss.ide.eclipse.as.core.launch.JBossServerStartupLaunchConfiguration;
+import org.jboss.ide.eclipse.as.core.launch.ServerLaunchDefaults;
import org.jboss.ide.eclipse.as.core.model.descriptor.XPathModel;
import org.jboss.ide.eclipse.as.core.model.descriptor.XPathQuery;
-import org.jboss.ide.eclipse.as.core.runtime.IJBossServerLaunchDefaults;
import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.runtime.server.ServerLaunchDefaults;
import org.jboss.ide.eclipse.as.core.server.attributes.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.attributes.IServerStartupParameters;
import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
@@ -76,11 +77,6 @@
public void configurationChanged() {
}
-
- public IJBossServerLaunchDefaults getLaunchDefaults() {
- return new ServerLaunchDefaults(getServer());
- }
-
/*
* Abstracts to implement
@@ -153,8 +149,10 @@
try {
Server s = (Server)getServer();
ILaunchConfiguration lc = s.getLaunchConfiguration(true, new NullProgressMonitor());
- String startArgs =
lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS
- + JBossServerLaunchConfiguration.PRGM_ARGS_START_SUFFIX, (String)null);
+ // TODO FIX
+// String startArgs =
lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS
+// + JBossServerStartupLaunchConfiguration.PRGM_ARGS_START_SUFFIX, (String)null);
+ String startArgs = "";
Map map = ArgsUtil.getSystemProperties(startArgs);
if( map.get(JBOSS_SERVER_HOME_DIR) != null )
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -23,20 +23,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.launch.JBossServerStartupLaunchConfiguration;
+import org.jboss.ide.eclipse.as.core.launch.StopLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.model.EventLogModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.runtime.server.polling.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.runtime.server.polling.PollThread;
-import org.jboss.ide.eclipse.as.core.runtime.server.polling.JMXPoller;
import org.jboss.ide.eclipse.as.core.server.stripped.DeployableServerBehavior;
public class JBossServerBehavior extends DeployableServerBehavior {
@@ -61,18 +59,10 @@
return;
}
- Thread t = new Thread() {
- public void run() {
- // Otherwise execute a shutdown attempt
- try {
- // Set up our launch configuration for a STOP call (to shutdown.jar)
- ILaunchConfiguration wc =
JBossServerLaunchConfiguration.setupLaunchConfiguration(getServer(),
JBossServerLaunchConfiguration.STOP);
- wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- } catch( Exception e ) {
- }
- }
- };
- t.start();
+ new Thread() {public void run() {
+ serverStopping();
+ StopLaunchConfiguration.stop(getServer());
+ }}.start();
}
public void forceStop() {
@@ -105,7 +95,7 @@
}
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy,
IProgressMonitor monitor) throws CoreException {
- JBossServerLaunchConfiguration.setupLaunchConfiguration(workingCopy, getServer(),
JBossServerLaunchConfiguration.START);
+ JBossServerStartupLaunchConfiguration.setupLaunchConfiguration(workingCopy,
getServer());
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -1,305 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.server;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
-import org.eclipse.jdt.launching.ExecutionArguments;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.IVMRunner;
-import org.eclipse.jdt.launching.VMRunnerConfiguration;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.ServerType;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
-
-public class JBossServerLaunchConfiguration extends
AbstractJavaLaunchConfigurationDelegate {
-
- public static final String START = "_START_";
- public static final String STOP = "_STOP_";
- public static final String TWIDDLE = "_TWIDDLE_";
-
- public static final String CURRENT_ACTION =
"org.jboss.ide.eclipse.as.core.server.currentAction";
- public static final String DEFAULT_SETTINGS =
"org.jboss.ide.eclipse.as.core.server.defaultsSet";
-
-
- protected static final char[] INVALID_CHARS = new char[] {'\\', '/',
':', '*', '?', '"', '<', '>',
'|', '\0', '@', '&'};
- public static final String PRGM_ARGS_START_SUFFIX =
"org.jboss.ide.eclipse.as.core.server.start_suffix";
- public static final String PRGM_ARGS_STOP_SUFFIX =
"org.jboss.ide.eclipse.as.core.server.stop_suffix";
- public static final String PRGM_ARGS_TWIDDLE_SUFFIX =
"org.jboss.ide.eclipse.as.core.server.twiddle_suffix";
-
-
-
- public static JBossServerBehavior getServerBehavior(ILaunchConfiguration configuration)
throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- JBossServerBehavior jbossServerBehavior = (JBossServerBehavior)
server.getAdapter(JBossServerBehavior.class);
- return jbossServerBehavior;
- }
-
- public static JBossServer getJBossServer(ILaunchConfiguration configuration) throws
CoreException {
- // Get access to some important structures
- return getJBossServer(ServerUtil.getServer(configuration));
- }
-
- public static JBossServer getJBossServer(IServer server) {
- if( server == null ) return null;
- JBossServer jbServer = (JBossServer)server.getAdapter(JBossServer.class);
- if (jbServer == null) {
- jbServer = (JBossServer) server.loadAdapter(JBossServer.class, new
NullProgressMonitor());
- }
- return jbServer;
- }
-
-
- public static ILaunchConfigurationWorkingCopy setupLaunchConfiguration(IServer server,
String action) throws CoreException {
- ILaunchConfigurationWorkingCopy config = createLaunchConfiguration(server);
- setupLaunchConfiguration(config, server, action);
- return config;
- }
-
- public static void ensureDefaultsSet(ILaunchConfigurationWorkingCopy workingCopy,
IServer server ) {
- if( !defaultsBeenSet(workingCopy, server) ) {
- try {
- getJBossServer(server).getLaunchDefaults().fillDefaults(workingCopy);
- workingCopy.setAttribute(DEFAULT_SETTINGS, true);
- } catch( CoreException ce ) {}
- }
- }
-
- public static void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy,
- IServer server, String action) throws CoreException {
-
- ensureDefaultsSet(workingCopy, server);
-
- // Now that defaults have all been set, set it up for the action (start, stop, twiddle
etc)
- String argsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS;
- String vmArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS;
- workingCopy.setAttribute(CURRENT_ACTION, action);
-
- String suffix;
- if( START.equals(action)) {
- suffix = PRGM_ARGS_START_SUFFIX;
- } else if( STOP.equals(action)) {
- suffix = PRGM_ARGS_STOP_SUFFIX;
- } else if( TWIDDLE.equals(action)) {
- suffix = PRGM_ARGS_TWIDDLE_SUFFIX;
- } else {
- throw new CoreException(null);
- }
-
- try {
- String pgArgs = workingCopy.getAttribute(argsKey + suffix, (String)null);
- workingCopy.setAttribute(argsKey,pgArgs);
-
-
- String vmArgs = workingCopy.getAttribute(vmArgsKey + suffix, (String)null);
- workingCopy.setAttribute(vmArgsKey, vmArgs);
-
- String main =
workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME + suffix,
(String)null);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
main);
-
- String workingDir =
workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY +
suffix, (String)null);
- workingCopy.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir);
-
-
- List classpath =
workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH + suffix, new
ArrayList());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
classpath);
-
- if( STOP.equals(action) || TWIDDLE.equals(action))
- addCredentials(workingCopy, getJBossServer(workingCopy));
-
- } catch( Exception e ) {
- e.printStackTrace();
- }
-
- }
-
-
- protected static void addCredentials(ILaunchConfigurationWorkingCopy configuration,
JBossServer server) {
- try {
- String argsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS;
- String args = configuration.getAttribute(argsKey, (String)null);
- String user = ArgsUtil.getValue(args, "-u", "--user");
- String pass = ArgsUtil.getValue(args, "-p", "--password");
- if( user == null && server.getUsername() != null &&
!server.getUsername().equals(""))
- args = args + " -u " + server.getUsername();
- if( pass == null && server.getPassword() != null &&
!server.getPassword().equals(""))
- args = args + " -p " + server.getPassword();
-
- configuration.setAttribute(argsKey, args);
- } catch( CoreException ce ) {
- ce.printStackTrace();
- }
- }
-
-
- // Have the defaults been set for this launch config yet? ever?
- public static boolean defaultsBeenSet(ILaunchConfiguration workingCopy, IServer server)
{
- try {
- return workingCopy.getAttribute(DEFAULT_SETTINGS, false);
- } catch( CoreException ce ) {
- }
- return false;
- }
-
-
- /**
- * Will create a launch configuration for the server
- * if one does not already exist.
- */
- public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
- ILaunchConfigurationType launchConfigType =
- ((ServerType) server.getServerType()).getLaunchConfigurationType();
- if (launchConfigType == null)
- return null;
-
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfiguration[] launchConfigs = null;
- try {
- launchConfigs = launchManager.getLaunchConfigurations(launchConfigType);
- } catch (CoreException e) {
- // ignore
- }
-
- if (launchConfigs != null) {
- int size = launchConfigs.length;
- for (int i = 0; i < size; i++) {
- try {
- String serverId = launchConfigs[i].getAttribute("server-id", (String)
null);
- if (server.getId().equals(serverId)) {
- ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy();
- return wc;
- }
- } catch (CoreException e) {
- }
- }
- }
-
- // create a new launch configuration
- String launchName = getValidLaunchConfigurationName(server.getName());
- launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
- ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
- wc.setAttribute("server-id", server.getId());
- return wc;
- }
-
- protected static String getValidLaunchConfigurationName(String s) {
- if (s == null || s.length() == 0)
- return "1";
- int size = INVALID_CHARS.length;
- for (int i = 0; i < size; i++) {
- s = s.replace(INVALID_CHARS[i], '_');
- }
- return s;
- }
-
-
- public void launch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
-
- try {
- String action = configuration.getAttribute(CURRENT_ACTION, START);
-
- IProcess[] processes = new IProcess[0];
- JBossServerBehavior jbossServerBehavior = getServerBehavior(configuration);
- String serverID = jbossServerBehavior.getServer().getId();
- if( action.equals(START)) {
- processes = launchConfiguration(configuration, launch, monitor, mode);
- jbossServerBehavior.setProcess(processes[0]);
- jbossServerBehavior.serverStarting();
- } else if( action.equals(STOP)) {
- processes = launchConfiguration(configuration, launch, monitor, mode);
- jbossServerBehavior.serverStopping();
- } else if( action.equals(TWIDDLE)) {
- processes = launchConfiguration(configuration, launch, monitor, mode);
- }
- } catch( Exception e ) {
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
IStatus.ERROR, "Error launching twiddle", e));
- }
- }
-
- public IProcess[] launchConfiguration(ILaunchConfiguration configuration, ILaunch
launch,
- IProgressMonitor monitor, String mode) throws CoreException {
-
- // And off we go!
- IVMInstall vm = verifyVMInstall(configuration);
- IVMRunner runner = vm.getVMRunner(mode);
-
- File workingDir = verifyWorkingDirectory(configuration);
- String workingDirName = null;
- if (workingDir != null)
- workingDirName = workingDir.getAbsolutePath();
-
- // Program & VM args
- String pgmArgs = getProgramArguments(configuration);
- String vmArgs = getVMArguments(configuration);
-
-
- ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
-
- // VM-specific attributes
- Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
-
- // Classpath
- String[] classpath = getClasspath(configuration);
-
- // Create VM config
- String mainType = getMainTypeName(configuration);
- VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainType, classpath);
- runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
- runConfig.setVMArguments(execArgs.getVMArgumentsArray());
- runConfig.setWorkingDirectory(workingDirName);
- runConfig.setVMSpecificAttributesMap(vmAttributesMap);
-
- // Bootpath
- String[] bootpath = getBootpath(configuration);
- if (bootpath != null && bootpath.length > 0)
- runConfig.setBootClassPath(bootpath);
-
- setDefaultSourceLocator(launch, configuration);
-
- // Launch the configuration
- runner.run(runConfig, launch, monitor);
-
- return launch.getProcesses();
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/TwiddleLauncher.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -1,227 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.server;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.wst.server.core.IServer;
-
-public class TwiddleLauncher {
-
- /**
- * Create one launch for each String of arguments.
- * Each element in the array is a COMPLETE LIST of arguments.
- * For example:
- * twiddleArgs[0] = "-s localhost:1099 -a jmx/rmi/RMIAdaptor get
\"whatever\""
- * twiddleArgs[1] = "-s localhost:1099 -a jmx/rmi/RMIAdaptor get
\"whatever2\""
- *
- * @param twiddleArgs
- * @param jbServer
- * @param seed
- * @return
- */
- public static ProcessData[] launchTwiddles(String[] twiddleArgs, IServer server, boolean
addPrefix) throws CoreException {
- ILaunchConfigurationWorkingCopy wc;
- ArrayList list = new ArrayList();
- for( int i = 0; i < twiddleArgs.length; i++ ) {
- wc = createTwiddleLaunch(server, twiddleArgs[i], addPrefix);
- ILaunch launch = wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor(), false,
false);
- list.addAll(Arrays.asList(toProcessDatas(launch.getProcesses())));
- }
-
- ProcessData[] ret = new ProcessData[list.size()];
- list.toArray(ret);
-
- return ret;
- }
-
- protected static ProcessData[] toProcessDatas(IProcess[] processes) {
- ProcessData[] datas = new ProcessData[processes.length];
- for( int i = 0; i < processes.length; i++ ) {
- datas[i] = new ProcessData(processes[i], "");
- datas[i].startListening();
- }
- return datas;
- }
-
- public static ILaunchConfigurationWorkingCopy createTwiddleLaunch(IServer server,
- String args, boolean addPrefix) throws CoreException {
-
- ILaunchConfigurationWorkingCopy workingCopy =
- JBossServerLaunchConfiguration.setupLaunchConfiguration(server,
JBossServerLaunchConfiguration.TWIDDLE);
-
- // If we have to use the prefix from the launch config, throw it in front.
- if( addPrefix ) {
- String a2 = workingCopy.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS
- + JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX, "");
- args = a2 + " " + args;
- }
-
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
args);
- return workingCopy;
- }
-
- private boolean canceled = false;
- private int delay = 500;
-
- public void setCanceled() {
- canceled = true;
- }
-
- public ProcessData[] getTwiddleResults(IServer server, String args, boolean addPrefix )
{
- ProcessData[] processes;
- try {
- processes = TwiddleLauncher.launchTwiddles(new String[] { args }, server, addPrefix);
- } catch( CoreException ce ) {
- return new ProcessData[0];
- }
- waitForThreadsToTerminate(processes);
-
- // stop listening
- for( int i = 0; i < processes.length; i++ ) {
- processes[i].stopListening();
- if( canceled ) {
- try {
- // if canceled, terminate all twiddle processes
- processes[i].getProcess().terminate();
- } catch( Exception e ) {}
- }
- }
-
- return processes;
- }
-
- protected void waitForThreadsToTerminate(ProcessData[] processes) {
- boolean allTerminated = false;
- while( !allTerminated && !canceled) {
- allTerminated = true;
- for( int i = 0; i < processes.length; i++ ) {
- if( processes[i].getProcess().isTerminated() == false ) {
- allTerminated = false;
- }
- }
- if( !allTerminated ) {
- // sleep
- try {
- Thread.sleep(delay);
- } catch( InterruptedException ie ) {
- }
- }
- }
- }
-
- public static class ProcessData implements IStreamListener {
- private String args;
- private String processType;
-
- private IProcess process;
- private IStreamMonitor outMonitor;
- private IStreamMonitor errMonitor;
-
- private String out, err;
-
- public ProcessData(IProcess process, String processType) {
- this(null, process, processType);
- try {
- this.args = process.getLaunch().getLaunchConfiguration().
- getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
(String)null);
- } catch( CoreException ce ) {
- }
-
- }
-
- public ProcessData(String args, IProcess process, String processType) {
- this.args = args;
- this.process = process;
- this.processType = processType;
-
- //ASDebug.p("process is " + process, this);
- //ASDebug.p("Stream Proxy is " + process.getStreamsProxy(), this);
- this.outMonitor = process.getStreamsProxy().getOutputStreamMonitor();
- this.errMonitor = process.getStreamsProxy().getErrorStreamMonitor();
-
- out = "";
- err = "";
- }
-
- public void startListening() {
- outMonitor.addListener(this);
- errMonitor.addListener(this);
- }
-
- public void stopListening() {
- outMonitor.removeListener(this);
- errMonitor.removeListener(this);
- }
-
- public void resetStrings() {
- out = "";
- err = "";
- }
-
- public void destroy() {
- stopListening();
- resetStrings();
- }
-
- public void streamAppended(String text, IStreamMonitor monitor) {
- if( monitor == outMonitor ) {
- out += text;
- } else if( monitor == errMonitor ) {
- err += text;
- }
- }
-
- public String getArgs() {
- return args;
- }
-
- public String getErr() {
- return err;
- }
-
- public String getOut() {
- return out;
- }
-
- public String getProcesType() {
- return processType;
- }
-
- public IProcess getProcess() {
- return process;
- }
-
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableLaunchConfiguration.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -1,33 +0,0 @@
-package org.jboss.ide.eclipse.as.core.server.stripped;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.jboss.ide.eclipse.as.core.server.JBossServerBehavior;
-
-public class DeployableLaunchConfiguration implements
- ILaunchConfigurationDelegate {
-
- public static final String ACTION_KEY =
"org.jboss.ide.eclipse.as.core.server.stripped.DeployableLaunchConfiguration.Action";
- public static final String START = "_START_";
- public static final String STOP = "_STOP_";
-
- public static DeployableServerBehavior getServerBehavior(ILaunchConfiguration
configuration) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- DeployableServerBehavior jbossServerBehavior = (DeployableServerBehavior)
server.getAdapter(DeployableServerBehavior.class);
- return jbossServerBehavior;
- }
-
- public void launch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- String action = configuration.getAttribute(ACTION_KEY, START);
- DeployableServerBehavior behavior = getServerBehavior(configuration);
- if( START.equals(action)) behavior.setServerStarted();
- if( STOP.equals(action)) behavior.setServerStopped();
- }
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerBehavior.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/stripped/DeployableServerBehavior.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -17,6 +17,7 @@
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.model.PublishOperation;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.jboss.ide.eclipse.as.core.launch.DeployableLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.model.EventLogModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.packages.PackageModuleFactory;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ASLaunchConfigurationConverter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ASLaunchConfigurationConverter.java 2007-09-06
04:52:32 UTC (rev 3466)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ASLaunchConfigurationConverter.java 2007-09-06
04:52:37 UTC (rev 3467)
@@ -66,9 +66,9 @@
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.internal.ServerType;
+import org.jboss.ide.eclipse.as.core.launch.JBossServerStartupLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.runtime.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.runtime.server.AbstractJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -84,345 +84,346 @@
*/
public class ASLaunchConfigurationConverter {
-
- public TempLaunchConfiguration[] getConvertableConfigurations() {
- TempLaunchConfiguration[] cfgs = getAllLaunchConfigurations();
- ArrayList result = new ArrayList();
- try {
- for( int i = 0; i < cfgs.length; i++ ) {
- int type = cfgs[i].getLaunchType();
- // If it only has the private key and the type key, its a stub
- if( type != -1 && cfgs[i].getAttributes().keySet().size() > 2) {
- result.add(cfgs[i]);
- }
- }
- } catch( CoreException ce) {
- ce.printStackTrace();
- }
- return (TempLaunchConfiguration[]) result.toArray(new
TempLaunchConfiguration[result.size()]);
- }
-
-
- public void convertConfiguration(TempLaunchConfiguration configuration,
- String runtimeName, String serverName) throws CoreException {
- int type = configuration.getLaunchType();
-
- // need name, directory, jre, configuration
- String homeDir = configuration.getAttribute(TempLaunchConfiguration.HOME_DIR_KEY,
(String)null);
- String configName =
configuration.getAttribute(TempLaunchConfiguration.CONFIGURATION_KEY, (String)null);
- IVMInstall vm = configuration.getJVMItem();
-
- IRuntimeType runtimeType = getRuntimeType(type);
- IServerType serverType = getServerType(type);
-
- try {
- IServerWorkingCopy newServerWC = serverType.createServer(null, null, null, null);
- IRuntimeWorkingCopy newRuntimeWC = runtimeType.createRuntime("", null);
-
- newRuntimeWC.setName(runtimeName);
- newRuntimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_ID,
vm.getId());
- ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_TYPE_ID,
vm.getVMInstallType().getId());
- ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
configName);
- IRuntime runtime = newRuntimeWC.save(true, null);
-
- AbstractJBossServerRuntime newJBRuntime = (AbstractJBossServerRuntime)newRuntimeWC
- .loadAdapter(AbstractJBossServerRuntime.class, null);
- newJBRuntime.setVMInstall(vm);
-
-
- newServerWC.setRuntime(runtime);
-
- IFolder configFolder = ServerType.getServerProject().getFolder(serverName);
- if( !configFolder.exists() ) {
- configFolder.create(true, true, null);
- }
-
- newServerWC.setServerConfiguration(configFolder);
- newServerWC.setName(serverName);
-
- IServer savedServer = newServerWC.save(true, null);
-
- ILaunchConfiguration launchConfig =
- ((Server)savedServer).getLaunchConfiguration(true, new NullProgressMonitor());
- ILaunchConfigurationWorkingCopy lcwc = launchConfig.getWorkingCopy();
-
- // now lets set some launch config properties
- String startSuffix = JBossServerLaunchConfiguration.PRGM_ARGS_START_SUFFIX;
- String stopSuffix = JBossServerLaunchConfiguration.PRGM_ARGS_STOP_SUFFIX;
- String twiddleSuffix = JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX;
-
- String startArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
startSuffix;
- String startVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
startSuffix;
- String startWorkingDirKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY +
startSuffix;
-
- String stopArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
stopSuffix;
- String stopVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
stopSuffix;
- String stopWorkingDirKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY +
stopSuffix;
-
- String twiddleArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
twiddleSuffix;
- String twiddleVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
twiddleSuffix;
- String twiddleWorkingDirKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY
+ twiddleSuffix;
-
- String startArgs =
configuration.getAttribute("org.rocklet.launcher.userProgramArgs",
(String)null);
- String startVMArgs =
configuration.getAttribute("org.rocklet.launcher.UserVMArgs", (String)null);
-
- String shutdownArgs =
configuration.getAttribute("org.rocklet.launcher.userShutdownProgramArgs",
(String)null);
- String shutdownVMArgs =
configuration.getAttribute("org.rocklet.launcher.userShutdownVMArgs",
(String)null);
-
- String sourceMementoKey="org.eclipse.debug.core.source_locator_memento";
- String sourceLocatorKey="org.eclipse.debug.core.source_locator_id";
- String sourceMemento=configuration.getAttribute(sourceMementoKey, (String)null);
- String sourceLocator=configuration.getAttribute(sourceLocatorKey,
"org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector");
-
- lcwc.setAttribute(startArgsKey, startArgs);
- lcwc.setAttribute(startVMArgsKey, startVMArgs);
- lcwc.setAttribute(stopArgsKey, shutdownArgs);
- lcwc.setAttribute(stopVMArgsKey, shutdownVMArgs);
- lcwc.setAttribute(sourceMementoKey, sourceMemento);
- lcwc.setAttribute(sourceLocatorKey, sourceLocator);
-
- lcwc.doSave();
-
-
- } catch( CoreException ce) {
- ce.printStackTrace();
- }
- }
-
-
- private IRuntimeType getRuntimeType(int version) {
- String runtimeKey = "org.jboss.ide.eclipse.as.runtime." + version;
- return ServerCore.findRuntimeType(runtimeKey);
- }
-
- private IServerType getServerType(int version) {
- String serverKey = "org.jboss.ide.eclipse.as." + version;
- return ServerCore.findServerType(serverKey);
- }
-
-
-
- protected TempLaunchConfiguration[] getAllLaunchConfigurations() {
- IPath containerPath =
- DebugPlugin.getDefault().getStateLocation().append(".launches");
-
- List configs = new ArrayList(10);
- final File directory = containerPath.toFile();
- if (directory.isDirectory()) {
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return dir.equals(directory) &&
- name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
- }
- };
- String[] files = directory.list(filter);
- for (int i = 0; i < files.length; i++) {
- TempLaunchConfiguration config = new
TempLaunchConfiguration(containerPath.append(files[i]));
- configs.add(config);
- }
- }
-
- return (TempLaunchConfiguration[]) configs.toArray(new
TempLaunchConfiguration[configs.size()]);
- }
-
- public class TempLaunchConfiguration extends LaunchConfiguration {
- public static final String JBOSS_32_CONFIG =
"org.jboss.ide.eclipse.launcher.configuration.jboss.JBoss32xLaunchConfigurationDelegate";
- public static final String JBOSS_40_CONFIG =
"org.jboss.ide.eclipse.launcher.configuration.jboss.JBoss40xLaunchConfigurationDelegate";
- public static final String LAUNCH_CONFIG_TYPE = "_LAUNCH_CONFIG_TYPE_";
-
- public static final String HOME_DIR_KEY = "org.jboss.rocklet.HomeDir";
- public static final String CONFIGURATION_KEY =
"org.jboss.rocklet.ServerConfiguration";
-
-
- private TempLaunchConfigurationInfo info = null;
-
- protected TempLaunchConfiguration(IPath location) {
- super(location);
- }
-
- protected LaunchConfigurationInfo getInfo() throws CoreException {
- return managerGetInfo(this);
- }
-
- // returns 32, 40, or -1
- public int getLaunchType() {
- try {
- if( info == null ) managerGetInfo(this);
-
- String type = getAttribute(LAUNCH_CONFIG_TYPE, (String)null);
- if( type == null ) return -1;
-
- if( type.equals(JBOSS_32_CONFIG)) return 32;
- if( type.equals(JBOSS_40_CONFIG)) return 40;
- } catch( Exception e ) {
- }
- return -1;
- }
-
- public IVMInstall getJVMItem() throws CoreException {
- List cp = getAttribute("org.rocklet.launcher.JDKClasspath", (List)null);
- ArrayList vms = new ArrayList();
- IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
- for( int i = 0; i < vmTypes.length; i++ ) {
- vms.addAll(Arrays.asList(vmTypes[i].getVMInstalls()));
- }
- IVMInstall[] vms2 = (IVMInstall[]) vms.toArray(new IVMInstall[vms.size()]);
-
- Iterator i = cp.iterator();
- while(i.hasNext()) {
- Path cpItemPath = new Path((String)i.next());
- for( int j = 0; j < vms2.length; j++ ) {
- try {
- Path vmPath = new Path(vms2[j].getInstallLocation().toURL().getPath());
- IPath vmPath2 = vmPath.append("lib").append("tools.jar");
- if( cpItemPath.equals(vmPath2) ) {
- return vms2[j];
- }
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-
- return JavaRuntime.getDefaultVMInstall();
- }
-
-
- protected LaunchConfigurationInfo managerGetInfo(ILaunchConfiguration config) throws
CoreException {
- if (info == null) {
- if (config.exists()) {
- InputStream stream = null;
- try {
- if (config.isLocal()) {
- IPath path = config.getLocation();
- File file = path.toFile();
- stream = new FileInputStream(file);
- } else {
- IFile file = ((LaunchConfiguration) config).getFile();
- if (file == null) {
- throw
createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_30, new String[]
{config.getName()}), null);
- }
- stream = file.getContents();
- }
- info = (TempLaunchConfigurationInfo)createInfoFromXML(stream);
- } catch (FileNotFoundException e) {
- throwException(config, e);
- } catch (SAXException e) {
- throwException(config, e);
- } catch (ParserConfigurationException e) {
- throwException(config, e);
- } catch (IOException e) {
- throwException(config, e);
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- throwException(config, e);
- }
- }
- }
-
- } else {
- throw createDebugException(
- MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new
String[]{config.getName(), config.getLocation().toOSString()}), null);
- }
- }
- return info;
- }
-
- private void throwException(ILaunchConfiguration config, Throwable e) throws
DebugException {
- IPath path = config.getLocation();
- throw
createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1,
new String[]{e.toString(), path.toOSString()}), e);
- }
-
- protected DebugException createDebugException(String message, Throwable throwable) {
- return new DebugException(
- new Status(
- IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, message, throwable
- )
- );
- }
-
-
- protected LaunchConfigurationInfo createInfoFromXML(InputStream stream) throws
CoreException,
- ParserConfigurationException,
- IOException,
- SAXException {
- Element root = null;
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- parser.setErrorHandler(new DefaultHandler());
- root = parser.parse(new InputSource(stream)).getDocumentElement();
- TempLaunchConfigurationInfo info = new TempLaunchConfigurationInfo();
- info.initializeFromXML(root);
- return info;
- }
-
-
- }
-
- protected class TempLaunchConfigurationInfo extends LaunchConfigurationInfo {
-
- protected void initializeFromXML(Element root) throws CoreException {
-
-
-// boolean val = true;
-// if( val ) {
-// super.initializeFromXML(root);
-// return;
+//
+// public TempLaunchConfiguration[] getConvertableConfigurations() {
+// TempLaunchConfiguration[] cfgs = getAllLaunchConfigurations();
+// ArrayList result = new ArrayList();
+// try {
+// for( int i = 0; i < cfgs.length; i++ ) {
+// int type = cfgs[i].getLaunchType();
+// // If it only has the private key and the type key, its a stub
+// if( type != -1 && cfgs[i].getAttributes().keySet().size() > 2) {
+// result.add(cfgs[i]);
+// }
// }
-
-
- if (!root.getNodeName().equalsIgnoreCase("launchConfiguration")) {
//$NON-NLS-1$
- throw getInvalidFormatDebugException();
- }
-
- // read type
- String id = root.getAttribute("type"); //$NON-NLS-1$
- if (id == null) {
- throw getInvalidFormatDebugException();
- }
-
- // Commenting out as it causes an exception. (Configuration type not found)
-// ILaunchConfigurationType type =
DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(id);
-// if (type == null) {
-// String message=
MessageFormat.format(DebugCoreMessages.LaunchConfigurationInfo_missing_type, new
Object[]{id});
-// throw new DebugException(
+// } catch( CoreException ce) {
+// ce.printStackTrace();
+// }
+// return (TempLaunchConfiguration[]) result.toArray(new
TempLaunchConfiguration[result.size()]);
+// }
+//
+//
+// public void convertConfiguration(TempLaunchConfiguration configuration,
+// String runtimeName, String serverName) throws CoreException {
+// int type = configuration.getLaunchType();
+//
+// // need name, directory, jre, configuration
+// String homeDir = configuration.getAttribute(TempLaunchConfiguration.HOME_DIR_KEY,
(String)null);
+// String configName =
configuration.getAttribute(TempLaunchConfiguration.CONFIGURATION_KEY, (String)null);
+// IVMInstall vm = configuration.getJVMItem();
+//
+// IRuntimeType runtimeType = getRuntimeType(type);
+// IServerType serverType = getServerType(type);
+//
+// try {
+// IServerWorkingCopy newServerWC = serverType.createServer(null, null, null, null);
+// IRuntimeWorkingCopy newRuntimeWC = runtimeType.createRuntime("", null);
+//
+// newRuntimeWC.setName(runtimeName);
+// newRuntimeWC.setLocation(new Path(homeDir));
+// ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_ID,
vm.getId());
+// ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_VM_TYPE_ID,
vm.getVMInstallType().getId());
+// ((RuntimeWorkingCopy)newRuntimeWC).setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
configName);
+// IRuntime runtime = newRuntimeWC.save(true, null);
+//
+// AbstractJBossServerRuntime newJBRuntime = (AbstractJBossServerRuntime)newRuntimeWC
+// .loadAdapter(AbstractJBossServerRuntime.class, null);
+// newJBRuntime.setVMInstall(vm);
+//
+//
+// newServerWC.setRuntime(runtime);
+//
+// IFolder configFolder = ServerType.getServerProject().getFolder(serverName);
+// if( !configFolder.exists() ) {
+// configFolder.create(true, true, null);
+// }
+//
+// newServerWC.setServerConfiguration(configFolder);
+// newServerWC.setName(serverName);
+//
+// IServer savedServer = newServerWC.save(true, null);
+//
+// ILaunchConfiguration launchConfig =
+// ((Server)savedServer).getLaunchConfiguration(true, new NullProgressMonitor());
+// ILaunchConfigurationWorkingCopy lcwc = launchConfig.getWorkingCopy();
+//
+// // now lets set some launch config properties
+// String startSuffix =
JBossServerStartupLaunchConfiguration.PRGM_ARGS_START_SUFFIX;
+// String stopSuffix =
JBossServerStartupLaunchConfiguration.PRGM_ARGS_STOP_SUFFIX;
+// //String twiddleSuffix = JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX;
+// String twiddleSuffix = "";
+//
+// String startArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
startSuffix;
+// String startVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
startSuffix;
+// String startWorkingDirKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY
+ startSuffix;
+//
+// String stopArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
stopSuffix;
+// String stopVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
stopSuffix;
+// String stopWorkingDirKey = IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY
+ stopSuffix;
+//
+// String twiddleArgsKey = IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS +
twiddleSuffix;
+// String twiddleVMArgsKey = IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS +
twiddleSuffix;
+// String twiddleWorkingDirKey =
IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY + twiddleSuffix;
+//
+// String startArgs =
configuration.getAttribute("org.rocklet.launcher.userProgramArgs",
(String)null);
+// String startVMArgs =
configuration.getAttribute("org.rocklet.launcher.UserVMArgs", (String)null);
+//
+// String shutdownArgs =
configuration.getAttribute("org.rocklet.launcher.userShutdownProgramArgs",
(String)null);
+// String shutdownVMArgs =
configuration.getAttribute("org.rocklet.launcher.userShutdownVMArgs",
(String)null);
+//
+// String sourceMementoKey="org.eclipse.debug.core.source_locator_memento";
+// String sourceLocatorKey="org.eclipse.debug.core.source_locator_id";
+// String sourceMemento=configuration.getAttribute(sourceMementoKey, (String)null);
+// String sourceLocator=configuration.getAttribute(sourceLocatorKey,
"org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector");
+//
+// lcwc.setAttribute(startArgsKey, startArgs);
+// lcwc.setAttribute(startVMArgsKey, startVMArgs);
+// lcwc.setAttribute(stopArgsKey, shutdownArgs);
+// lcwc.setAttribute(stopVMArgsKey, shutdownVMArgs);
+// lcwc.setAttribute(sourceMementoKey, sourceMemento);
+// lcwc.setAttribute(sourceLocatorKey, sourceLocator);
+//
+// lcwc.doSave();
+//
+//
+// } catch( CoreException ce) {
+// ce.printStackTrace();
+// }
+// }
+//
+//
+// private IRuntimeType getRuntimeType(int version) {
+// String runtimeKey = "org.jboss.ide.eclipse.as.runtime." + version;
+// return ServerCore.findRuntimeType(runtimeKey);
+// }
+//
+// private IServerType getServerType(int version) {
+// String serverKey = "org.jboss.ide.eclipse.as." + version;
+// return ServerCore.findServerType(serverKey);
+// }
+//
+//
+//
+// protected TempLaunchConfiguration[] getAllLaunchConfigurations() {
+// IPath containerPath =
+// DebugPlugin.getDefault().getStateLocation().append(".launches");
+//
+// List configs = new ArrayList(10);
+// final File directory = containerPath.toFile();
+// if (directory.isDirectory()) {
+// FilenameFilter filter = new FilenameFilter() {
+// public boolean accept(File dir, String name) {
+// return dir.equals(directory) &&
+// name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
+// }
+// };
+// String[] files = directory.list(filter);
+// for (int i = 0; i < files.length; i++) {
+// TempLaunchConfiguration config = new
TempLaunchConfiguration(containerPath.append(files[i]));
+// configs.add(config);
+// }
+// }
+//
+// return (TempLaunchConfiguration[]) configs.toArray(new
TempLaunchConfiguration[configs.size()]);
+// }
+//
+// public class TempLaunchConfiguration extends LaunchConfiguration {
+// public static final String JBOSS_32_CONFIG =
"org.jboss.ide.eclipse.launcher.configuration.jboss.JBoss32xLaunchConfigurationDelegate";
+// public static final String JBOSS_40_CONFIG =
"org.jboss.ide.eclipse.launcher.configuration.jboss.JBoss40xLaunchConfigurationDelegate";
+// public static final String LAUNCH_CONFIG_TYPE = "_LAUNCH_CONFIG_TYPE_";
+//
+// public static final String HOME_DIR_KEY = "org.jboss.rocklet.HomeDir";
+// public static final String CONFIGURATION_KEY =
"org.jboss.rocklet.ServerConfiguration";
+//
+//
+// private TempLaunchConfigurationInfo info = null;
+//
+// protected TempLaunchConfiguration(IPath location) {
+// super(location);
+// }
+//
+// protected LaunchConfigurationInfo getInfo() throws CoreException {
+// return managerGetInfo(this);
+// }
+//
+// // returns 32, 40, or -1
+// public int getLaunchType() {
+// try {
+// if( info == null ) managerGetInfo(this);
+//
+// String type = getAttribute(LAUNCH_CONFIG_TYPE, (String)null);
+// if( type == null ) return -1;
+//
+// if( type.equals(JBOSS_32_CONFIG)) return 32;
+// if( type.equals(JBOSS_40_CONFIG)) return 40;
+// } catch( Exception e ) {
+// }
+// return -1;
+// }
+//
+// public IVMInstall getJVMItem() throws CoreException {
+// List cp = getAttribute("org.rocklet.launcher.JDKClasspath", (List)null);
+// ArrayList vms = new ArrayList();
+// IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
+// for( int i = 0; i < vmTypes.length; i++ ) {
+// vms.addAll(Arrays.asList(vmTypes[i].getVMInstalls()));
+// }
+// IVMInstall[] vms2 = (IVMInstall[]) vms.toArray(new IVMInstall[vms.size()]);
+//
+// Iterator i = cp.iterator();
+// while(i.hasNext()) {
+// Path cpItemPath = new Path((String)i.next());
+// for( int j = 0; j < vms2.length; j++ ) {
+// try {
+// Path vmPath = new Path(vms2[j].getInstallLocation().toURL().getPath());
+// IPath vmPath2 = vmPath.append("lib").append("tools.jar");
+// if( cpItemPath.equals(vmPath2) ) {
+// return vms2[j];
+// }
+// } catch( Exception e ) {
+// e.printStackTrace();
+// }
+// }
+// }
+//
+// return JavaRuntime.getDefaultVMInstall();
+// }
+//
+//
+// protected LaunchConfigurationInfo managerGetInfo(ILaunchConfiguration config) throws
CoreException {
+// if (info == null) {
+// if (config.exists()) {
+// InputStream stream = null;
+// try {
+// if (config.isLocal()) {
+// IPath path = config.getLocation();
+// File file = path.toFile();
+// stream = new FileInputStream(file);
+// } else {
+// IFile file = ((LaunchConfiguration) config).getFile();
+// if (file == null) {
+// throw
createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager_30, new String[]
{config.getName()}), null);
+// }
+// stream = file.getContents();
+// }
+// info = (TempLaunchConfigurationInfo)createInfoFromXML(stream);
+// } catch (FileNotFoundException e) {
+// throwException(config, e);
+// } catch (SAXException e) {
+// throwException(config, e);
+// } catch (ParserConfigurationException e) {
+// throwException(config, e);
+// } catch (IOException e) {
+// throwException(config, e);
+// } finally {
+// if (stream != null) {
+// try {
+// stream.close();
+// } catch (IOException e) {
+// throwException(config, e);
+// }
+// }
+// }
+//
+// } else {
+// throw createDebugException(
+// MessageFormat.format(DebugCoreMessages.LaunchManager_does_not_exist, new
String[]{config.getName(), config.getLocation().toOSString()}), null);
+// }
+// }
+// return info;
+// }
+//
+// private void throwException(ILaunchConfiguration config, Throwable e) throws
DebugException {
+// IPath path = config.getLocation();
+// throw
createDebugException(MessageFormat.format(DebugCoreMessages.LaunchManager__0__occurred_while_reading_launch_configuration_file__1___1,
new String[]{e.toString(), path.toOSString()}), e);
+// }
+//
+// protected DebugException createDebugException(String message, Throwable throwable) {
+// return new DebugException(
// new Status(
// IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
-// DebugException.MISSING_LAUNCH_CONFIGURATION_TYPE, message, null)
+// DebugException.REQUEST_FAILED, message, throwable
+// )
// );
+// }
+//
+//
+// protected LaunchConfigurationInfo createInfoFromXML(InputStream stream) throws
CoreException,
+// ParserConfigurationException,
+// IOException,
+// SAXException {
+// Element root = null;
+// DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+// parser.setErrorHandler(new DefaultHandler());
+// root = parser.parse(new InputSource(stream)).getDocumentElement();
+// TempLaunchConfigurationInfo info = new TempLaunchConfigurationInfo();
+// info.initializeFromXML(root);
+// return info;
+// }
+//
+//
+// }
+//
+// protected class TempLaunchConfigurationInfo extends LaunchConfigurationInfo {
+//
+// protected void initializeFromXML(Element root) throws CoreException {
+//
+//
+//// boolean val = true;
+//// if( val ) {
+//// super.initializeFromXML(root);
+//// return;
+//// }
+//
+//
+// if (!root.getNodeName().equalsIgnoreCase("launchConfiguration")) {
//$NON-NLS-1$
+// throw getInvalidFormatDebugException();
// }
-// setType(type);
-
- // instead just set an attribute right now.
- setAttribute(TempLaunchConfiguration.LAUNCH_CONFIG_TYPE, id);
-
- NodeList list = root.getChildNodes();
- int length = list.getLength();
- for (int i = 0; i < length; ++i) {
- Node node = list.item(i);
- short nodeType = node.getNodeType();
- if (nodeType == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String nodeName = element.getNodeName();
-
- if (nodeName.equalsIgnoreCase("stringAttribute")) { //$NON-NLS-1$
- setStringAttribute(element);
- } else if (nodeName.equalsIgnoreCase("intAttribute")) { //$NON-NLS-1$
- setIntegerAttribute(element);
- } else if (nodeName.equalsIgnoreCase("booleanAttribute")) {
//$NON-NLS-1$
- setBooleanAttribute(element);
- } else if (nodeName.equalsIgnoreCase("listAttribute")) { //$NON-NLS-1$
- setListAttribute(element);
- } else if (nodeName.equalsIgnoreCase("mapAttribute")) { //$NON-NLS-1$
- setMapAttribute(element);
- }
- }
- }
- }
- }
+//
+// // read type
+// String id = root.getAttribute("type"); //$NON-NLS-1$
+// if (id == null) {
+// throw getInvalidFormatDebugException();
+// }
+//
+// // Commenting out as it causes an exception. (Configuration type not found)
+//// ILaunchConfigurationType type =
DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(id);
+//// if (type == null) {
+//// String message=
MessageFormat.format(DebugCoreMessages.LaunchConfigurationInfo_missing_type, new
Object[]{id});
+//// throw new DebugException(
+//// new Status(
+//// IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
+//// DebugException.MISSING_LAUNCH_CONFIGURATION_TYPE, message, null)
+//// );
+//// }
+//// setType(type);
+//
+// // instead just set an attribute right now.
+// setAttribute(TempLaunchConfiguration.LAUNCH_CONFIG_TYPE, id);
+//
+// NodeList list = root.getChildNodes();
+// int length = list.getLength();
+// for (int i = 0; i < length; ++i) {
+// Node node = list.item(i);
+// short nodeType = node.getNodeType();
+// if (nodeType == Node.ELEMENT_NODE) {
+// Element element = (Element) node;
+// String nodeName = element.getNodeName();
+//
+// if (nodeName.equalsIgnoreCase("stringAttribute")) { //$NON-NLS-1$
+// setStringAttribute(element);
+// } else if (nodeName.equalsIgnoreCase("intAttribute")) { //$NON-NLS-1$
+// setIntegerAttribute(element);
+// } else if (nodeName.equalsIgnoreCase("booleanAttribute")) {
//$NON-NLS-1$
+// setBooleanAttribute(element);
+// } else if (nodeName.equalsIgnoreCase("listAttribute")) {
//$NON-NLS-1$
+// setListAttribute(element);
+// } else if (nodeName.equalsIgnoreCase("mapAttribute")) {
//$NON-NLS-1$
+// setMapAttribute(element);
+// }
+// }
+// }
+// }
+// }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2007-09-06 04:52:32 UTC (rev
3466)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2007-09-06 04:52:37 UTC (rev
3467)
@@ -14,7 +14,7 @@
hasConfiguration="false"
id="org.jboss.ide.eclipse.as.32"
initialState="stopped"
-
launchConfigId="org.jboss.ide.eclipse.as.core.server.launchConfiguration"
+
launchConfigId="org.jboss.ide.eclipse.as.core.server.startupConfiguration"
launchModes="run,debug"
name="%jboss.version.32.name"
runtime="true"
@@ -31,7 +31,7 @@
hasConfiguration="false"
id="org.jboss.ide.eclipse.as.40"
initialState="stopped"
-
launchConfigId="org.jboss.ide.eclipse.as.core.server.launchConfiguration"
+
launchConfigId="org.jboss.ide.eclipse.as.core.server.startupConfiguration"
launchModes="run,debug"
name="%jboss.version.40.name"
runtime="true"
@@ -48,7 +48,7 @@
hasConfiguration="false"
id="org.jboss.ide.eclipse.as.42"
initialState="stopped"
-
launchConfigId="org.jboss.ide.eclipse.as.core.server.launchConfiguration"
+
launchConfigId="org.jboss.ide.eclipse.as.core.server.startupConfiguration"
launchModes="run,debug"
name="%jboss.version.42.name"
runtime="true"
@@ -199,21 +199,34 @@
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
category="JBoss"
-
delegate="org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration"
- id="org.jboss.ide.eclipse.as.core.server.launchConfiguration"
+
delegate="org.jboss.ide.eclipse.as.core.launch.JBossServerStartupLaunchConfiguration"
+ id="org.jboss.ide.eclipse.as.core.server.startupConfiguration"
modes="run,debug"
- name="JBoss Application Server"
+ name="JBoss Application Server Startup Configuration"
public="true"
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
sourcePathComputerId="org.jboss.ide.eclipse.as.core.serverSourcePathComputer"/>
<launchConfigurationType
-
delegate="org.jboss.ide.eclipse.as.core.server.stripped.DeployableLaunchConfiguration"
+
delegate="org.jboss.ide.eclipse.as.core.launch.DeployableLaunchConfiguration"
id="org.jboss.ide.eclipse.as.core.server.stripped.launchConfiguration"
modes="run,debug"
name="Stripped Server Launch Configuration"
public="true"
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
sourcePathComputerId="org.jboss.ide.eclipse.as.core.serverSourcePathComputer"/>
+ <launchConfigurationType
+
delegate="org.jboss.ide.eclipse.as.core.launch.TwiddleLaunchConfiguration"
+ id="org.jboss.ide.eclipse.as.core.server.twiddleConfiguration"
+ modes="run"
+ name="Twiddle"
+ public="false">
+ </launchConfigurationType>
+ <launchConfigurationType
+
delegate="org.jboss.ide.eclipse.as.core.launch.StopLaunchConfiguration"
+ id="org.jboss.ide.eclipse.as.core.server.stopLaunchConfiguration"
+ modes="run"
+ name="Stop Server">
+ </launchConfigurationType>
</extension>
<extension