Author: adietish
Date: 2011-06-20 07:10:36 -0400 (Mon, 20 Jun 2011)
New Revision: 32205
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/LaunchConfigUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/RuntimeUtils.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBoss7RuntimeClasspathUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
Log:
[JBIDE-9200] moved static methods to util classes and changed static method to be instance
methods where they should not offer functionality to the instance, only (no accessibility
from outside the object is needed)
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -41,9 +41,6 @@
public class JBossServer extends DeployableServer
implements IJBossServerConstants, IDeployableServer, IURLProvider {
- public JBossServer() {
- }
-
public void setDefaults(IProgressMonitor monitor) {
super.setDefaults(monitor);
setAttribute("auto-publish-time", 1); //$NON-NLS-1$
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -11,9 +11,7 @@
package org.jboss.ide.eclipse.as.core.server.internal.launch;
import java.io.File;
-import java.io.FilenameFilter;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -22,7 +20,6 @@
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;
@@ -32,22 +29,19 @@
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.jst.server.core.ServerProfilerDelegate;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.AbstractLocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.IConstants;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
* @author Rob Stryker
@@ -56,6 +50,7 @@
public static final String SERVER_ID = "server-id"; //$NON-NLS-1$
// we have no need to do anything in pre-launch check
+ @Override
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode,
IProgressMonitor monitor)
throws CoreException {
return true;
@@ -71,6 +66,7 @@
// override me
}
+ @Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
preLaunch(configuration, mode, launch, monitor);
@@ -131,7 +127,7 @@
try {
ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
} catch (CoreException ce) {
- IServer server = ServerUtil.getServer(configuration);
+ IServer server = org.eclipse.wst.server.core.ServerUtil.getServer(configuration);
JBossServerBehavior jbsb = (JBossServerBehavior)
server.getAdapter(JBossServerBehavior.class);
jbsb.stop(true);
// genericServer.stopImpl();
@@ -141,106 +137,54 @@
// Launch the configuration
runner.run(runConfig, launch, monitor);
}
-
+
+ @Deprecated
public static JBossServer findJBossServer(String serverId) throws CoreException {
- if (serverId == null)
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.ServerNotFound, serverId)));
-
- IServer s = ServerCore.findServer(serverId);
- if (s == null)
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.ServerNotFound, serverId)));
-
- JBossServer jbs = ServerConverter.getJBossServer(s);
- if (jbs == null)
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.ServerNotFound, serverId)));
-
- return jbs;
+ return ServerConverter.findJBossServer(serverId);
}
-
+
+ @Deprecated
public 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,
- NLS.bind(Messages.ServerRuntimeNotFound, server.getName())));
- return jbrt;
+ return RuntimeUtils.getJBossServerRuntime(server);
}
-
+
+ @Deprecated
public static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, JBossServer
jbs, String relative) {
- addCPEntry(list, new Path(getServerHome(jbs)).append(relative));
+ String serverHome = org.jboss.ide.eclipse.as.core.util.ServerUtil.getServerHome(jbs);
+ LaunchConfigUtils.addCPEntry(serverHome, relative, list);
}
+ @Deprecated
public static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, IPath path)
{
- list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
+ LaunchConfigUtils.addCPEntry(path, list);
}
+ @Deprecated
public static void addJREEntry(List<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
- if (vmInstall != null) {
- try {
- cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
- new Path(JavaRuntime.JRE_CONTAINER)
- .append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName()),
- IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
- } catch (CoreException e) {
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- Messages.LaunchConfigJREError, e);
- JBossServerCorePlugin.getDefault().getLog().log(s);
- }
- }
+ LaunchConfigUtils.addJREEntry(vmInstall, cp);
}
+ @Deprecated
public static void addToolsJar(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
- File f = vmInstall.getInstallLocation();
- File c1 = new File(f, IConstants.LIB);
- File c2 = new File(c1, IConstants.TOOLS_JAR);
- if (c2.exists())
- addCPEntry(cp, new Path(c2.getAbsolutePath()));
+ LaunchConfigUtils.addToolsJar(vmInstall, cp);
}
+ @Deprecated
public static ArrayList<String>
convertClasspath(List<IRuntimeClasspathEntry> cp) {
- Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
- ArrayList<String> list = new ArrayList<String>();
- while (cpi.hasNext()) {
- IRuntimeClasspathEntry entry = cpi.next();
- try {
- list.add(entry.getMemento());
- } catch (Exception e) {
- // Trace.trace(Trace.SEVERE, "Could not resolve classpath entry:
- // " + entry, e);
- }
- }
-
- return list;
+ return (ArrayList) LaunchConfigUtils.toStrings(cp);
}
- public static void addDirectory(String serverHome,
ArrayList<IRuntimeClasspathEntry> classpath,
+ @Deprecated
+ protected static void addDirectory(String serverHome, List<IRuntimeClasspathEntry>
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(IConstants.EXT_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())));
- }
+ LaunchConfigUtils.addDirectory(serverHome, classpath, dirName);
}
+ @Deprecated
public static String getServerHome(JBossServer jbs) {
- return jbs.getServer().getRuntime().getLocation().toOSString();
+ return ServerUtil.getServerHome(jbs);
}
-
+
public IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException
{
String serverId = configuration.getAttribute(SERVER_ID, (String) null);
JBossServer jbs = findJBossServer(serverId);
@@ -249,4 +193,5 @@
.loadAdapter(AbstractLocalJBossServerRuntime.class, new NullProgressMonitor());
return rt.getVM();
}
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -135,58 +135,4 @@
ILaunch launch, IProgressMonitor monitor) throws CoreException {
getDelegate(configuration).postLaunch(configuration, mode, launch, monitor);
}
-
- /**
- * Will create a launch configuration for the server
- * if one does not already exist.
- */
- public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
- ILaunchConfigurationType launchConfigType =
DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LAUNCH_TYPE);
- 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(AbstractJBossLaunchConfigType.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(AbstractJBossLaunchConfigType.SERVER_ID, server.getId());
- return wc;
- }
-
- static final char[] INVALID_CHARS = new char[] {'\\', '/', ':',
'*', '?', '"', '<', '>', '|',
'\0', '@', '&'};
- static final String LAUNCH_TYPE =
"org.jboss.ide.eclipse.as.core.server.startupConfiguration"; //$NON-NLS-1$
-
- protected static String getValidLaunchConfigurationName(String s) {
- if (s == null || s.length() == 0)
- return "1"; //$NON-NLS-1$
- int size = INVALID_CHARS.length;
- for (int i = 0; i < size; i++) {
- s = s.replace(INVALID_CHARS[i], '_');
- }
- return s;
- }
-
-
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -16,7 +16,6 @@
import java.util.List;
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;
@@ -51,9 +50,11 @@
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
-import org.jboss.ide.eclipse.as.core.util.JBoss7RuntimeClasspathUtil;
import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class LocalJBossServerStartupLaunchUtil implements StartLaunchDelegate,
IStartLaunchSetupParticipant {
@@ -91,9 +92,9 @@
* Merges proper required params into args and vm args
*/
- protected static void updateMandatedFields(ILaunchConfigurationWorkingCopy wc,
JBossServer jbs)
+ protected void updateMandatedFields(ILaunchConfigurationWorkingCopy wc, JBossServer
jbs)
throws CoreException {
- String serverHome = AbstractJBossLaunchConfigType.getServerHome(jbs);
+ String serverHome = ServerUtil.getServerHome(jbs);
if (serverHome == null)
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
NLS.bind(Messages.CannotLocateServerHome, jbs.getServer().getName())));
@@ -158,34 +159,34 @@
}
- protected static List<String> fixCP(List<String> list, JBossServer jbs) {
+ protected List<String> fixCP(List<String> list, JBossServer jbs) {
try {
boolean found = false;
String[] asString = (String[]) list.toArray(new String[list.size()]);
for (int i = 0; i < asString.length; i++) {
if (asString[i].contains(RunJarContainerWrapper.ID)) {
found = true;
- asString[i] = getRunJarRuntimeCPEntry(jbs.getServer()).getMemento();
+ asString[i] =
LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()).getMemento();
}
}
ArrayList<String> result = new ArrayList<String>();
result.addAll(Arrays.asList(asString));
if (!found)
- result.add(getRunJarRuntimeCPEntry(jbs.getServer()).getMemento());
+ result.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()).getMemento());
return result;
} catch (CoreException ce) {
return list;
}
}
- protected static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer
server) throws CoreException {
+ protected void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server)
throws CoreException {
JBossServer jbs = ServerConverter.findJBossServer(server.getId());
if (jbs == null) {
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
NLS.bind(Messages.CannotSetUpImproperServer, server.getName())));
}
- String serverHome = AbstractJBossLaunchConfigType.getServerHome(jbs);
+ String serverHome = ServerUtil.getServerHome(jbs);
if (serverHome == null)
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
NLS.bind(Messages.CannotLocateServerHome, server.getName())));
@@ -216,32 +217,23 @@
wc.setAttribute(DEFAULTS_SET, true);
}
-
- protected static ArrayList<String> getClasspath(JBossServer jbs) throws
CoreException {
- IJBossServerRuntime jbrt =
AbstractJBossLaunchConfigType.findJBossServerRuntime(jbs.getServer());
+
+ private List<String> getClasspath(JBossServer jbs) throws CoreException {
+ IJBossServerRuntime jbrt = RuntimeUtils.getJBossServerRuntime(jbs.getServer());
ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- classpath.add(getRunJarRuntimeCPEntry(jbs.getServer()));
- AbstractJBossLaunchConfigType.addJREEntry(classpath, jbrt.getVM());
+ classpath.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(jbs.getServer()));
+ LaunchConfigUtils.addJREEntry(jbrt.getVM(), classpath);
String version = jbs.getServer().getRuntime().getRuntimeType().getVersion();
if (version.equals(IJBossToolingConstants.AS_40))
- AbstractJBossLaunchConfigType.addToolsJar(classpath, jbrt.getVM());
+ LaunchConfigUtils.addToolsJar(jbrt.getVM(), classpath);
- ArrayList<String> runtimeClassPaths =
AbstractJBossLaunchConfigType.convertClasspath(classpath);
+ List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
return runtimeClassPaths;
}
- protected static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(IServer server) throws
CoreException {
- if (server.getServerType().getId().endsWith("70")) { //$NON-NLS-1$
- return JBoss7RuntimeClasspathUtil.getModulesClasspathEntry(server);
- } else {
- IPath containerPath = new Path(RunJarContainerWrapper.ID).append(server.getName());
- return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath,
IRuntimeClasspathEntry.USER_CLASSES);
- }
- }
-
- protected static String getDefaultArgs(JBossServer jbs) throws CoreException {
- IJBossServerRuntime rt =
AbstractJBossLaunchConfigType.findJBossServerRuntime(jbs.getServer());
+ protected String getDefaultArgs(JBossServer jbs) throws CoreException {
+ IJBossServerRuntime rt = RuntimeUtils.getJBossServerRuntime(jbs.getServer());
if (rt != null) {
return rt.getDefaultRunArgs() +
IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
@@ -273,8 +265,8 @@
JBossServer jbs = (JBossServer) s.loadAdapter(JBossServer.class, new
NullProgressMonitor());
IVMInstall install = ibjsrt.getVM();
ArrayList<IRuntimeClasspathEntry> list = new
ArrayList<IRuntimeClasspathEntry>();
- AbstractJBossLaunchConfigType.addJREEntry(list, install);
- list.add(getRunJarRuntimeCPEntry(s));
+ LaunchConfigUtils.addJREEntry(install, list);
+ list.add(LaunchConfigUtils.getRunJarRuntimeCPEntry(s));
return (IRuntimeClasspathEntry[]) list
.toArray(new IRuntimeClasspathEntry[list.size()]);
} catch (CoreException ce) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -12,12 +12,13 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.List;
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.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -37,6 +38,10 @@
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class StopLaunchConfiguration extends AbstractJBossLaunchConfigType {
@@ -74,9 +79,9 @@
public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server)
throws CoreException {
- JBossServer jbs = findJBossServer(server.getId());
- IJBossServerRuntime jbrt = findJBossServerRuntime(server);
- String serverHome = getServerHome(jbs);
+ JBossServer jbs = ServerConverter.findJBossServer(server.getId());
+ IJBossServerRuntime jbrt = RuntimeUtils.getJBossServerRuntime(server);
+ IPath serverHome = ServerUtil.getServerHomePath(jbs);
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType(STOP_LAUNCH_TYPE);
@@ -87,11 +92,11 @@
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 + IJBossRuntimeResourceConstants.BIN);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
serverHome.append(IJBossRuntimeResourceConstants.BIN).toOSString());
ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- addCPEntry(classpath, jbs, STOP_JAR_LOC);
- addJREEntry(classpath, jbrt.getVM());
- ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
+ LaunchConfigUtils.addCPEntry(serverHome, STOP_JAR_LOC, classpath);
+ LaunchConfigUtils.addJREEntry(jbrt.getVM(), classpath);
+ List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
wc.setAttribute(cpKey, runtimeClassPaths);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/TwiddleLaunchConfiguration.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -19,7 +19,9 @@
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.SPACE;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -31,15 +33,20 @@
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class TwiddleLaunchConfiguration extends AbstractJBossLaunchConfigType {
@@ -49,18 +56,14 @@
protected static final String TWIDDLE_JAR_LOC =
IJBossRuntimeResourceConstants.BIN + File.separator +
IJBossRuntimeResourceConstants.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 = ServerConverter.findJBossServer(server.getId());
if (jbs == null) {
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
NLS.bind(Messages.ServerNotFound, server.getName())));
}
- IJBossServerRuntime jbrt = findJBossServerRuntime(server);
- String serverHome = getServerHome(jbs);
+ IJBossServerRuntime jbrt = RuntimeUtils.getJBossServerRuntime(server);
+ String serverHome = ServerUtil.getServerHome(jbs);
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType(TWIDDLE_LAUNCH_TYPE);
@@ -74,13 +77,13 @@
wc.setAttribute(TwiddleLaunchConfiguration.SERVER_ID, server.getId());
ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- addCPEntry(classpath, jbs, TWIDDLE_JAR_LOC);
+ LaunchConfigUtils.addCPEntry(TWIDDLE_JAR_LOC, serverHome, classpath);
// Twiddle requires more classes and I'm too lazy to actually figure OUT which ones
it needs.
- addDirectory (serverHome, classpath, IJBossRuntimeResourceConstants.LIB);
- addDirectory (serverHome, classpath, IJBossRuntimeResourceConstants.LIB +
File.separator + IJBossRuntimeResourceConstants.ENDORSED);
- addDirectory (serverHome, classpath, IJBossRuntimeResourceConstants.CLIENT);
- addJREEntry(classpath, jbrt.getVM());
- ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
+ LaunchConfigUtils.addDirectory(serverHome, classpath,
IJBossRuntimeResourceConstants.LIB);
+ LaunchConfigUtils.addDirectory(serverHome, classpath,
IJBossRuntimeResourceConstants.LIB + File.separator +
IJBossRuntimeResourceConstants.ENDORSED);
+ LaunchConfigUtils.addDirectory(serverHome, classpath,
IJBossRuntimeResourceConstants.CLIENT);
+ LaunchConfigUtils.addJREEntry(jbrt.getVM(), classpath);
+ List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
wc.setAttribute(cpKey, runtimeClassPaths);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7RuntimeLaunchConfigurator.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -10,11 +10,13 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.v7;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
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.IRuntime;
@@ -23,7 +25,7 @@
import
org.jboss.ide.eclipse.as.core.server.internal.launch.AbstractJBossLaunchConfigType;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
-import org.jboss.ide.eclipse.as.core.util.JBoss7RuntimeClasspathUtil;
+import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
public class JBoss7RuntimeLaunchConfigurator {
@@ -70,9 +72,17 @@
private JBoss7RuntimeLaunchConfigurator setClassPath(IServer server, IJBossServerRuntime
jbossRuntime)
throws CoreException {
- return setClassPath(JBoss7RuntimeClasspathUtil.getClasspath(server,
jbossRuntime.getVM()));
+ return setClassPath(getClasspath(server, jbossRuntime.getVM()));
}
+ private List<String> getClasspath(IServer server, IVMInstall vmInstall) throws
CoreException {
+ List<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
+ classpath.add(LaunchConfigUtils.getModulesClasspathEntry(server));
+ LaunchConfigUtils.addJREEntry(vmInstall, classpath);
+ List<String> runtimeClassPaths = LaunchConfigUtils.toStrings(classpath);
+ return runtimeClassPaths;
+ }
+
private JBoss7RuntimeLaunchConfigurator setClassPath(List<String> entries) throws
CoreException {
launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
JBoss7ServerBehavior.DEFAULT_CP_PROVIDER_ID);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBoss7RuntimeClasspathUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBoss7RuntimeClasspathUtil.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBoss7RuntimeClasspathUtil.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -23,6 +23,7 @@
public class JBoss7RuntimeClasspathUtil {
+ @Deprecated
public static List<String> getClasspath(IServer server, IVMInstall vmInstall)
throws CoreException {
List<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
classpath.add(getModulesClasspathEntry(server));
@@ -30,7 +31,8 @@
List<String> runtimeClassPaths =
AbstractJBossLaunchConfigType.convertClasspath(classpath);
return runtimeClassPaths;
}
-
+
+ @Deprecated
public static IRuntimeClasspathEntry getModulesClasspathEntry(IServer server) throws
CoreException {
IPath runtimeLocation = server.getRuntime().getLocation();
IPath modulesLocation =
runtimeLocation.append(IJBossRuntimeResourceConstants.JBOSS_MODULES_JAR);
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/LaunchConfigUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/LaunchConfigUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/LaunchConfigUtils.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -0,0 +1,121 @@
+package org.jboss.ide.eclipse.as.core.util;
+
+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.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+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.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.RunJarContainerWrapper;
+
+/**
+ * @author André Dietisheim
+ */
+public class LaunchConfigUtils {
+
+ /**
+ * Adds an entry for the given vm install to the given list of classpath
+ * entries.
+ *
+ * @param vmInstall
+ * to add
+ * @param cp
+ * the classpath entries to add to
+ */
+ public static void addJREEntry(IVMInstall vmInstall, List<IRuntimeClasspathEntry>
cp) {
+ if (vmInstall != null) {
+ try {
+ String name = vmInstall.getName();
+ String installTypeId = vmInstall.getVMInstallType().getId();
+ cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
+ new Path(JavaRuntime.JRE_CONTAINER).append(installTypeId).append(name),
+ IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
+ } catch (CoreException e) {
+ IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ Messages.LaunchConfigJREError, e);
+ JBossServerCorePlugin.getDefault().getLog().log(s);
+ }
+ }
+ }
+
+ public static void addToolsJar(IVMInstall vmInstall, List<IRuntimeClasspathEntry>
cp) {
+ File f = vmInstall.getInstallLocation();
+ File c1 = new File(f, IConstants.LIB);
+ File c2 = new File(c1, IConstants.TOOLS_JAR);
+ if (c2.exists())
+ addCPEntry(new Path(c2.getAbsolutePath()), cp);
+ }
+
+ public static void addCPEntry(IPath path, List<IRuntimeClasspathEntry> list) {
+ list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
+ }
+
+ public static void addCPEntry(String serverHome, String relative,
ArrayList<IRuntimeClasspathEntry> list) {
+ addCPEntry(new Path(serverHome), relative, list);
+ }
+
+ public static void addCPEntry(IPath serverHome, String relative,
ArrayList<IRuntimeClasspathEntry> list) {
+ addCPEntry(serverHome.append(relative), list);
+ }
+
+ public static List<String> toStrings(List<IRuntimeClasspathEntry> cp) {
+ Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
+ ArrayList<String> list = new ArrayList<String>();
+ while (cpi.hasNext()) {
+ IRuntimeClasspathEntry entry = cpi.next();
+ try {
+ list.add(entry.getMemento());
+ } catch (Exception e) {
+ // Trace.trace(Trace.SEVERE, "Could not resolve classpath entry:
+ // " + entry, e);
+ }
+ }
+
+ return list;
+ }
+
+ public static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(IServer server) throws
CoreException {
+ // TODO: improve/avoid server version check
+ if (server.getServerType().getId().endsWith("70")) { //$NON-NLS-1$
+ return getModulesClasspathEntry(server);
+ } else {
+ IPath containerPath = new Path(RunJarContainerWrapper.ID).append(server.getName());
+ return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath,
IRuntimeClasspathEntry.USER_CLASSES);
+ }
+ }
+
+ public static IRuntimeClasspathEntry getModulesClasspathEntry(IServer server) throws
CoreException {
+ IPath runtimeLocation = server.getRuntime().getLocation();
+ IPath modulesLocation =
runtimeLocation.append(IJBossRuntimeResourceConstants.JBOSS_MODULES_JAR);
+ return JavaRuntime.newArchiveRuntimeClasspathEntry(modulesLocation);
+ }
+
+ public static void addDirectory(String serverHome, List<IRuntimeClasspathEntry>
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(IConstants.EXT_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())));
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/LaunchConfigUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/RuntimeUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/RuntimeUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/RuntimeUtils.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -0,0 +1,60 @@
+package org.jboss.ide.eclipse.as.core.util;
+
+import org.eclipse.core.runtime.CoreException;
+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.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+
+public class RuntimeUtils {
+
+ public static IJBossServerRuntime getJBossServerRuntime(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,
+ NLS.bind(Messages.ServerRuntimeNotFound, server.getName())));
+ return jbrt;
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config, IVMInstall install) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
+ new NullProgressMonitor());
+ runtimeWC.setName(runtimeId);
+ runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, install.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, install
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
+
+ IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
+ return savedRuntime;
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config) throws CoreException {
+ return createRuntime(runtimeId, homeDir, config, JavaRuntime.getDefaultVMInstall());
+ }
+
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/RuntimeUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -28,6 +28,7 @@
/**
*
* @author rob.stryker(a)jboss.com
+ * @author adietish(a)redhat.com
*/
public class ServerConverter {
@@ -38,7 +39,7 @@
IServer s = ServerCore.findServer(serverId);
if (s == null)
return null;
- return ServerConverter.getJBossServer(s);
+ return getJBossServer(s);
}
public static JBossServer getJBossServer(IServer server) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -53,18 +53,6 @@
IServer server = swc.save(true, null);
return server;
}
-
- public static IServer createServer(String runtimeID, String serverID,
- String location, String configuration) throws CoreException {
- IRuntime currentRuntime = createRuntime(runtimeID, location,configuration);
- return createServer2(currentRuntime, serverID);
- }
- public static IServer createServer(String runtimeID, String serverID,
- String location, String configuration, IVMInstall install) throws CoreException {
- IRuntime currentRuntime = createRuntime(runtimeID, location,
- configuration, install);
- return createServer2(currentRuntime, serverID);
- }
public static IServer createServer2(String name, IRuntime currentRuntime) throws
CoreException {
return createServer2(currentRuntime,
runtimeServerTypeMap.get(currentRuntime.getRuntimeType().getId()), name);
@@ -85,35 +73,6 @@
}
public static IRuntime createRuntime(String runtimeId, String homeDir,
- String config) throws CoreException {
- return createRuntime(runtimeId, homeDir, config, getDefaultVMInstall());
- }
-
- public static IVMInstall getDefaultVMInstall() {
- return JavaRuntime.getDefaultVMInstall();
- }
-
- public static IRuntime createRuntime(String runtimeId, String homeDir,
- String config, IVMInstall install) throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
- new NullProgressMonitor());
- runtimeWC.setName(runtimeId);
- runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_ID, install.getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_TYPE_ID, install
- .getVMInstallType().getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
-
- IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
- return savedRuntime;
- }
-
- public static IRuntime createRuntime(String runtimeId, String homeDir,
String config, IExecutionEnvironment environment) throws CoreException {
IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
IRuntimeType runtimeType = runtimeTypes[0];
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2011-06-20
10:45:21 UTC (rev 32204)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2011-06-20
11:10:36 UTC (rev 32205)
@@ -160,6 +160,12 @@
return NLS.bind(Messages.serverCountName, base, i);
}
+ public static String getServerHome(JBossServer jbs) {
+ return jbs.getServer().getRuntime().getLocation().toOSString();
+ }
+
+ public static IPath getServerHomePath(JBossServer jbs) {
+ return new Path(getServerHome(jbs));
+ }
-
}