GERONIMODEVTOOLS-795: Another take. Tell the server which ports to use (via system properties) instead of updating config-substitutions.properties file
git-svn-id: https://svn.apache.org/repos/asf/geronimo/devtools/eclipse-plugin/trunk@1460849 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
index 9f12fec..572bb8a 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java
@@ -17,14 +17,18 @@
package org.apache.geronimo.st.v30.core;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.geronimo.st.v30.core.internal.Messages;
import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.util.ConfigSubstitutionsHelper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -139,35 +143,34 @@
boolean managedApplicationStart = server.getServerDelegate().isManageApplicationStart();
Trace.trace(Trace.INFO, "GeronimoLaunchConfigurationDelegate: manageApplicationStart:=" + managedApplicationStart, Activator.traceCore);
- int params = 0;
+ List<String> params = new ArrayList<String>(6);
+
+ GeronimoServerDelegate serverDelegate = server.getServerDelegate();
+
+ params.add("-Dorg.apache.geronimo.config.substitution.prefix=gep.");
+ params.add("-Dgep." + ConfigSubstitutionsHelper.PORT_OFFSET + "=" + serverDelegate.getPortOffset());
+ params.add("-Dgep." + ConfigSubstitutionsHelper.HTTP_PORT + "=" + serverDelegate.getHTTPPort());
+ params.add("-Dgep." + ConfigSubstitutionsHelper.NAMING_PORT + "=" + serverDelegate.getRMINamingPort());
+
Set<String> deletedConfigs = server.getDeletedConfigIds();
if (!deletedConfigs.isEmpty()) {
- params++;
+ params.add(toString("-Dgeronimo.removedArtifactList=", deletedConfigs));
}
- Set<String> modifiedConfigs = null;
if (managedApplicationStart) {
- modifiedConfigs = server.getModifiedConfigIds();
+ Set<String> modifiedConfigs = server.getModifiedConfigIds();
if (!modifiedConfigs.isEmpty()) {
- params++;
+ params.add(toString("-Dgeronimo.loadOnlyConfigList=", modifiedConfigs));
}
- } else {
- modifiedConfigs = Collections.emptySet();
}
-
- if (params > 0) {
- String[] newJvmArguments = new String[jvmArguments.length + params];
- System.arraycopy(jvmArguments, 0, newJvmArguments, 0, jvmArguments.length);
- int index = jvmArguments.length;
- if (!modifiedConfigs.isEmpty()) {
- newJvmArguments[index] = toString("-Dgeronimo.loadOnlyConfigList=", modifiedConfigs);
- index++;
- }
- if (!deletedConfigs.isEmpty()) {
- newJvmArguments[index] = toString("-Dgeronimo.removedArtifactList=", deletedConfigs);
- }
- jvmArguments = newJvmArguments;
+
+ int size = params.size();
+ String[] newJvmArguments = new String[jvmArguments.length + size];
+ System.arraycopy(jvmArguments, 0, newJvmArguments, 0, jvmArguments.length);
+ for (int i = 0; i < size; i++) {
+ newJvmArguments[jvmArguments.length + i] = params.get(i);
}
+ jvmArguments = newJvmArguments;
return jvmArguments;
}
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java
index 67b720e..d10183f 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoRuntimeDelegate.java
@@ -23,9 +23,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -51,8 +49,6 @@
private static final String PROP_VM_INSTALL_ID = "vm-install-id";
- public static final String SERVER_INSTANCE_PROPERTIES = "geronimo_server_instance_properties";
-
public static final String RUNTIME_SOURCE= "runtime.source";
public static final int NO_IMAGE = 0;
@@ -164,15 +160,12 @@
* @see org.apache.geronimo.st.v30.core.IGeronimoRuntime#getRuntimeSourceLocation()
*/
public IPath getRuntimeSourceLocation() {
- String source = (String) getServerInstanceProperties().get(RUNTIME_SOURCE);
- if (source != null) {
- return new Path(source);
- }
- return null;
+ String source = getAttribute(RUNTIME_SOURCE, (String) null);
+ return (source != null) ? new Path(source) : null;
}
public void setRuntimeSourceLocation(String path) {
- setInstanceProperty(RUNTIME_SOURCE, path);
+ setAttribute(RUNTIME_SOURCE, path);
}
/**
@@ -285,38 +278,6 @@
}
/**
- * @return
- */
- public Map getServerInstanceProperties() {
- return getAttribute(SERVER_INSTANCE_PROPERTIES, new HashMap());
- }
-
- /**
- * @param map
- */
- public void setServerInstanceProperties(Map map) {
- setAttribute(SERVER_INSTANCE_PROPERTIES, map);
- }
-
- /**
- * @param name
- * @return
- */
- public String getInstanceProperty(String name) {
- return(String) getServerInstanceProperties().get(name);
- }
-
- /**
- * @param name
- * @param value
- */
- public void setInstanceProperty(String name, String value) {
- Map map = getServerInstanceProperties();
- map.put(name, value);
- setServerInstanceProperties(map);
- }
-
- /**
* @param vmInstall
*/
public void setVMInstall(IVMInstall vmInstall) {
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
index 8067450..1f9e349 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
@@ -1260,10 +1260,6 @@
return true;
}
- public Map getServerInstanceProperties() {
- return getRuntimeDelegate().getServerInstanceProperties();
- }
-
protected GeronimoRuntimeDelegate getRuntimeDelegate() {
GeronimoRuntimeDelegate rd = (GeronimoRuntimeDelegate) getServer().getRuntime().getAdapter(GeronimoRuntimeDelegate.class);
if (rd == null)
diff --git a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
index b7e296d..f78cdce 100644
--- a/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
+++ b/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerDelegate.java
@@ -40,7 +40,6 @@
import org.apache.geronimo.st.v30.core.internal.Trace;
import org.apache.geronimo.st.v30.core.osgi.AriesHelper;
import org.apache.geronimo.st.v30.core.osgi.OsgiConstants;
-import org.apache.geronimo.st.v30.core.util.ConfigSubstitutionsHelper;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -53,7 +52,6 @@
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IModuleType;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.ServerUtil;
@@ -566,43 +564,14 @@
setRunFromWorkspace(false);
setSelectClasspathContainers(false);
- IServer server = getServer();
- if (server != null) {
- IRuntime runtime = server.getRuntime();
- if (runtime != null) {
- ConfigSubstitutionsHelper configSubstitutions = new ConfigSubstitutionsHelper(runtime.getLocation());
- configSubstitutions.load();
- setAttribute(configSubstitutions, ConfigSubstitutionsHelper.PORT_OFFSET, PROPERTY_PORT_OFFSET);
- setAttribute(configSubstitutions, ConfigSubstitutionsHelper.HTTP_PORT, PROPERTY_HTTP_PORT);
- setAttribute(configSubstitutions, ConfigSubstitutionsHelper.NAMING_PORT, PROPERTY_RMI_PORT);
- }
- }
-
resumeArgUpdates();
Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerDelegate.setDefaults", monitor);
}
- private void setAttribute(ConfigSubstitutionsHelper configSubstitutions, String substProperty, String property) {
- String value = configSubstitutions.getProperty(substProperty);
- if (value != null) {
- setAttribute(property, value);
- }
- }
-
@Override
public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
Trace.tracePoint("Enter", Activator.traceCore, "GeronimoServerDelegate.saveConfiguration", monitor);
super.saveConfiguration(monitor);
-
- if (SocketUtil.isLocalhost(getServer().getHost())) {
- ConfigSubstitutionsHelper configSubstitutions = new ConfigSubstitutionsHelper(getServer().getRuntime().getLocation());
- configSubstitutions.load();
- configSubstitutions.setProperty(ConfigSubstitutionsHelper.PORT_OFFSET, String.valueOf(getPortOffset()));
- configSubstitutions.setProperty(ConfigSubstitutionsHelper.HTTP_PORT, getHTTPPort());
- configSubstitutions.setProperty(ConfigSubstitutionsHelper.NAMING_PORT, getRMINamingPort());
- configSubstitutions.store();
- }
-
Trace.tracePoint("Exit", Activator.traceCore, "GeronimoServerDelegate.saveConfiguration", monitor);
}
diff --git a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
index 8a8f7b2..cae2e53 100644
--- a/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
+++ b/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/GeronimoRuntimeWizardFragment.java
@@ -317,7 +317,6 @@
}
IRuntimeWorkingCopy runtimeWC = getRuntimeDelegate().getRuntimeWorkingCopy();
- getRuntimeDelegate().setInstanceProperty("serverRootDirectory", installDir.getText());
if (installDir.getText() == null || installDir.getText().length() == 0) {
// installDir field has not been entered