Author: adietish
Date: 2011-05-02 14:10:44 -0400 (Mon, 02 May 2011)
New Revision: 30998
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeClasspathUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeLaunchConfigBuilder.java
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/LocalJBossServerStartupLaunchUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
Log:
[JBIDE-8793] extracted methods to util class
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-05-02
16:43:50 UTC (rev 30997)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2011-05-02
18:10:44 UTC (rev 30998)
@@ -14,6 +14,7 @@
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
@@ -178,7 +179,7 @@
list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
}
- public static void addJREEntry(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
+ public static void addJREEntry(List<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
if (vmInstall != null) {
try {
cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
@@ -201,7 +202,7 @@
addCPEntry(cp, new Path(c2.getAbsolutePath()));
}
- public static ArrayList<String>
convertClasspath(ArrayList<IRuntimeClasspathEntry> cp) {
+ public static ArrayList<String>
convertClasspath(List<IRuntimeClasspathEntry> cp) {
Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
ArrayList<String> list = new ArrayList<String>();
while (cpi.hasNext()) {
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-05-02
16:43:50 UTC (rev 30997)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2011-05-02
18:10:44 UTC (rev 30998)
@@ -46,7 +46,7 @@
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.IStartLaunchSetupParticipant;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
-import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBossRuntimeClasspathUtil;
import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
import org.jboss.ide.eclipse.as.core.util.IConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
@@ -231,7 +231,7 @@
protected static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(IServer server) throws
CoreException {
if (server.getServerType().getId().endsWith("70")) { //$NON-NLS-1$
- return JBoss7ServerBehavior.getRunJarRuntimeCPEntry(server);
+ return JBossRuntimeClasspathUtil.getRunJarRuntimeCPEntry(server);
} else {
IPath containerPath = new Path(RunJarContainerWrapper.ID).append(server.getName());
return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath,
IRuntimeClasspathEntry.USER_CLASSES);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-05-02
16:43:50 UTC (rev 30997)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ServerBehavior.java 2011-05-02
18:10:44 UTC (rev 30998)
@@ -18,33 +18,24 @@
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.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
-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.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBoss7ManagerService;
-import org.jboss.ide.eclipse.as.core.server.internal.AbstractLocalJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
-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.ServerConverter;
public class JBoss7ServerBehavior extends JBossServerBehavior {
- private static final String DEFAULT_CP_PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider";
//$NON-NLS-1$
+ public static final String DEFAULT_CP_PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider";
//$NON-NLS-1$
private IJBoss7ManagerService service;
@@ -77,46 +68,22 @@
return false;
}
- public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy,
IProgressMonitor monitor)
+ public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy launchConfig,
IProgressMonitor monitor)
throws CoreException {
- IRuntime rt = getServer().getRuntime();
- LocalJBoss7ServerRuntime runtime = (LocalJBoss7ServerRuntime)
- rt.loadAdapter(LocalJBoss7ServerRuntime.class, null);
-
- IPath p = rt.getLocation();
- IVMInstall vmInstall = runtime.getVM();
- if (vmInstall != null)
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
JavaRuntime
- .newJREContainerPath(vmInstall).toPortableString());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
DEFAULT_CP_PROVIDER_ID);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
getClasspath());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
false);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
runtime.getDefaultRunArgs());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
runtime.getDefaultRunVMArgs());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
- IJBossRuntimeConstants.START7_MAIN_TYPE);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- p.append(IJBossRuntimeResourceConstants.BIN).toString());
- workingCopy.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID,
getServer().getId());
+ IServer server = getServer();
+ IRuntime runtime = server.getRuntime();
+ IJBossServerRuntime serverRuntime =
+ (IJBossServerRuntime) runtime.loadAdapter(LocalJBoss7ServerRuntime.class, null);
+ new JBossRuntimeLaunchConfigBuilder(launchConfig, serverRuntime)
+ .setVmContainer()
+ .setClassPath(server)
+ .setDefaultArguments()
+ .setMainType(IJBossRuntimeConstants.START7_MAIN_TYPE)
+ .setWorkingDirectory(runtime)
+ .setServerId(server);
}
- protected ArrayList<String> getClasspath() throws CoreException {
- AbstractLocalJBossServerRuntime jbrt = (AbstractLocalJBossServerRuntime)
getServer().getRuntime().loadAdapter(
- AbstractLocalJBossServerRuntime.class, new NullProgressMonitor());
- ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- classpath.add(getRunJarRuntimeCPEntry(getServer()));
- AbstractJBossLaunchConfigType.addJREEntry(classpath, jbrt.getVM());
- ArrayList<String> runtimeClassPaths =
AbstractJBossLaunchConfigType.convertClasspath(classpath);
- return runtimeClassPaths;
- }
- public static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(IServer server) throws
CoreException {
- IPath loc = server.getRuntime().getLocation();
- IClasspathEntry e = JavaRuntime.newArchiveRuntimeClasspathEntry(
- loc.append("jboss-modules.jar")).getClasspathEntry(); //$NON-NLS-1$
- return new RuntimeClasspathEntry(e);
- }
-
@Override
protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor
monitor)
throws CoreException {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeClasspathUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeClasspathUtil.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeClasspathUtil.java 2011-05-02
18:10:44 UTC (rev 30998)
@@ -0,0 +1,35 @@
+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.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
+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.server.internal.launch.AbstractJBossLaunchConfigType;
+
+public class JBossRuntimeClasspathUtil {
+
+ private static final String JBOSS_MODULES_JAR = "jboss-modules.jar";
//$NON-NLS-1$
+
+ public static List<String> getClasspath(IServer server, IVMInstall vmInstall)
throws CoreException {
+ List<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
+ classpath.add(getRunJarRuntimeCPEntry(server));
+ AbstractJBossLaunchConfigType.addJREEntry(classpath, vmInstall);
+ List<String> runtimeClassPaths =
AbstractJBossLaunchConfigType.convertClasspath(classpath);
+ return runtimeClassPaths;
+ }
+
+ public static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(IServer server) throws
CoreException {
+ IPath location = server.getRuntime().getLocation();
+ IClasspathEntry entry =
+ JavaRuntime.newArchiveRuntimeClasspathEntry(location.append(JBOSS_MODULES_JAR)).getClasspathEntry();
+ return new RuntimeClasspathEntry(entry);
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeClasspathUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeLaunchConfigBuilder.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeLaunchConfigBuilder.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeLaunchConfigBuilder.java 2011-05-02
18:10:44 UTC (rev 30998)
@@ -0,0 +1,76 @@
+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.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
+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;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import
org.jboss.ide.eclipse.as.core.server.internal.launch.AbstractJBossLaunchConfigType;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+
+public class JBossRuntimeLaunchConfigBuilder {
+
+ private ILaunchConfigurationWorkingCopy launchConfig;
+ private IJBossServerRuntime jbossRuntime;
+
+ public JBossRuntimeLaunchConfigBuilder(ILaunchConfigurationWorkingCopy launchConfig,
IJBossServerRuntime runtime) {
+ this.launchConfig = launchConfig;
+ this.jbossRuntime = runtime;
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setVmContainer() {
+ IVMInstall vmInstall = jbossRuntime.getVM();
+ if (vmInstall != null) {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
+ JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+ }
+ return this;
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setDefaultArguments() {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+ jbossRuntime.getDefaultRunArgs());
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
+ jbossRuntime.getDefaultRunVMArgs());
+ return this;
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setClassPath(IServer server) throws CoreException
{
+ return setClassPath(JBossRuntimeClasspathUtil.getClasspath(server,
jbossRuntime.getVM()));
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setClassPath(List<String> entries) throws
CoreException {
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
+ JBoss7ServerBehavior.DEFAULT_CP_PROVIDER_ID);
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, entries);
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
false);
+ return this;
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setMainType(String mainType) {
+ launchConfig.setAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
+ return this;
+ }
+
+ public JBossRuntimeLaunchConfigBuilder setWorkingDirectory(IRuntime runtime) {
+ IPath location = runtime.getLocation();
+ launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
+ location.append(IJBossRuntimeResourceConstants.BIN).toString());
+ return this;
+ }
+
+ public void setServerId(IServer server) {
+ launchConfig.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID, server.getId());
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBossRuntimeLaunchConfigBuilder.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain