[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server ...
Robert Stryker
rawblem at gmail.com
Thu Jul 27 02:34:03 EDT 2006
User: rawb
Date: 06/07/27 02:34:03
Modified: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server
JBossServerBehavior.java ServerAttributeHelper.java
JBossServer.java ServerStateChecker.java
Log:
Implemented xpath editor in properties view. Other changes made to fascilitate this implementation (added to DescriptorModel, etc). Also fixed bugs, re-added classpath to server configuration so user can customize.
Revision Changes Path
1.6 +9 -8 jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JBossServerBehavior.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServerBehavior.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- JBossServerBehavior.java 10 Jul 2006 15:46:18 -0000 1.5
+++ JBossServerBehavior.java 27 Jul 2006 06:34:03 -0000 1.6
@@ -60,6 +60,8 @@
public static final String ACTION_STARTING = "__ACTION_STARTING__";
public static final String ACTION_TWIDDLE = "__ACTION_TWIDDLE__";
+ public static final String LAUNCH_CONFIG_DEFAULT_CLASSPATH = "__JBOSS_SERVER_BEHAVIOR_LAUNCH_CONFIG_DEFAULT_CLASSPATH__";
+
private JBossServer jbServer = null;
private ProcessLogEvent log = null;
private ServerStateChecker checker = null;
@@ -151,7 +153,7 @@
wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- int maxWait = JBossServerCorePlugin.getDefault().getPreferenceHelper().getStopTimeout(jbServer);
+ int maxWait = helper.getStopTimeout();
int soFar = 0;
// waiting for our stop process to be created
@@ -246,21 +248,20 @@
String action = workingCopy.getAttribute(ATTR_ACTION, ACTION_STARTING);
if( action.equals(ACTION_STARTING)) {
try {
- List classpath = runtimeDelegate.getRuntimeClasspath(getJBossServer(), IJBossServerRuntimeDelegate.ACTION_START);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- helper.getServerHome());
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, helper.getStartArgs());
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, helper.getVMArgs());
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, helper.getStartMainType());
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
-
workingCopy.setAttribute(
IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
helper.getServerHome() + Path.SEPARATOR + "bin");
-
+ boolean defaultCPVal = workingCopy.getAttribute(JBossServerBehavior.LAUNCH_CONFIG_DEFAULT_CLASSPATH, true);
+ if( defaultCPVal ) {
+ List classpath = runtimeDelegate.getRuntimeClasspath(getJBossServer(), IJBossServerRuntimeDelegate.ACTION_START);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
+ }
} catch( Exception e ) {
e.printStackTrace();
}
1.3 +160 -0 jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/ServerAttributeHelper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerAttributeHelper.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/ServerAttributeHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ServerAttributeHelper.java 10 Jul 2006 21:59:55 -0000 1.2
+++ ServerAttributeHelper.java 27 Jul 2006 06:34:03 -0000 1.3
@@ -1,10 +1,18 @@
package org.jboss.ide.eclipse.as.core.server;
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerType;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.model.SimpleTreeItem;
import org.jboss.ide.eclipse.as.core.server.runtime.AbstractServerRuntimeDelegate;
+import org.jboss.ide.eclipse.as.core.util.ASDebug;
public class ServerAttributeHelper {
@@ -23,6 +31,12 @@
public static final String JBOSS_CONFIG_DEFAULT = "default";
+ public static final String XPATH_CATEGORIES = "_XPATH_CATEGORIES_";
+ public static final String XPATH_CATEGORY2_PREFIX = "_XPATH_CATEGORY2_PREFIX_";
+ public static final String XPATH_PROPERTY_PREFIX = "_XPATH_PROPERTY_PREFIX_";
+
+
+
private ServerWorkingCopy server;
private JBossServer jbServer;
public ServerAttributeHelper(JBossServer jbServer, IServerWorkingCopy copy) {
@@ -109,4 +123,150 @@
+ public static final String START_TIMEOUT = "_START_TIMEOUT_";
+ public static final String STOP_TIMEOUT = "_STOP_TIMEOUT_";
+
+ public int getStartTimeout() {
+ int prop = server.getAttribute(START_TIMEOUT, -1);
+ int max = ((ServerType)server.getServerType()).getStartTimeout();
+
+ if( prop <= 0 || prop > max ) return max;
+ return prop;
+ }
+ public int getStopTimeout() {
+ int prop = server.getAttribute(STOP_TIMEOUT, -1);
+ int max = ((ServerType)server.getServerType()).getStopTimeout();
+
+ if( prop <= 0 || prop > max ) return max;
+ return prop;
+ }
+
+ public void setStartTimeout(int time) {
+ server.setAttribute(START_TIMEOUT, time);
+ }
+ public void setStopTimeout(int time) {
+ server.setAttribute(STOP_TIMEOUT, time);
+ }
+
+
+ public IServerWorkingCopy getServer() {
+ return this.server;
+ }
+
+ public SimpleXPathPreferenceTreeItem getXPathPreferenceTree() {
+ List categories = server.getAttribute(XPATH_CATEGORIES, new ArrayList());
+ if( categories.size() == 0 ) {
+ return getDefaultXPathPreferenceTree();
+ }
+ SimpleXPathPreferenceTreeItem model = new SimpleXPathPreferenceTreeItem(null, XPATH_CATEGORIES);
+ Iterator i = categories.iterator();
+ while(i.hasNext()) {
+ String categoryName = (String)i.next();
+ SimpleXPathPreferenceTreeItem categoryItem = new SimpleXPathPreferenceTreeItem(model, categoryName);
+ String categoryListKey = XPATH_CATEGORY2_PREFIX + categoryName;
+ List categoryElementsAsList = server.getAttribute(categoryListKey, new ArrayList());
+ Iterator j = categoryElementsAsList.iterator();
+ while(j.hasNext()) {
+ String xpathName = (String)j.next();
+ String finalKey = XPATH_PROPERTY_PREFIX + categoryName + xpathName;
+ List xpathItem = server.getAttribute(finalKey, new ArrayList());
+ if( xpathItem.size() == 2 ) {
+ XPathPreferenceTreeItem xpi = new XPathPreferenceTreeItem(categoryItem,
+ (String)xpathItem.get(0), (String)xpathItem.get(1));
+ } else if( xpathItem.size() == 3 ) {
+ XPathPreferenceTreeItem xpi = new XPathPreferenceTreeItem(categoryItem,
+ (String)xpathItem.get(0), (String)xpathItem.get(1), (String)xpathItem.get(2));
+ }
+ }
+ }
+
+ return model;
+ }
+
+ private SimpleXPathPreferenceTreeItem getDefaultXPathPreferenceTree() {
+ SimpleXPathPreferenceTreeItem model = new SimpleXPathPreferenceTreeItem(null, XPATH_CATEGORIES);
+ SimpleXPathPreferenceTreeItem ports = new SimpleXPathPreferenceTreeItem(model, "Ports");
+ XPathPreferenceTreeItem jndi = new XPathPreferenceTreeItem(ports,
+ "JNDI", "/server/mbean[@name='jboss:service=Naming']/attribute[@name='Port']");
+ return model;
+ }
+
+ public void saveXPathPreferenceTree(SimpleTreeItem tree) {
+
+ SimpleTreeItem[] children = tree.getChildren2();
+ SimpleTreeItem[] grandChildren;
+ ArrayList categoryList = new ArrayList();
+ ArrayList xpathNameList, itemAsList;
+ XPathPreferenceTreeItem xpathPrefItem;
+ HashMap map = new HashMap();
+ for( int i = 0; i < children.length; i++ ) {
+ xpathNameList = new ArrayList();
+ String categoryName = (String)children[i].getData();
+ categoryList.add(categoryName); // add "Ports"
+
+ grandChildren = children[i].getChildren2(); // list of xpaths under "Ports"
+ for( int j = 0; j < grandChildren.length; j++ ) {
+ xpathPrefItem = ((XPathPreferenceTreeItem)grandChildren[j]); // JNDI
+ itemAsList = new ArrayList();
+ itemAsList.add(xpathPrefItem.getName());
+ itemAsList.add(xpathPrefItem.getXPath());
+ itemAsList.add(xpathPrefItem.getAttributeName());
+ xpathNameList.add(xpathPrefItem.getName());
+ map.put(XPATH_PROPERTY_PREFIX + categoryName + xpathPrefItem.getName(), itemAsList);
+ }
+ map.put(XPATH_CATEGORY2_PREFIX + categoryName, xpathNameList);
+ }
+ map.put(XPATH_CATEGORIES, categoryList);
+
+ Iterator i = map.keySet().iterator();
+ while( i.hasNext()) {
+ String key = (String)i.next();
+ server.setAttribute(key, (List)map.get(key));
+ }
+
+ }
+
+ /* Just a label class */
+ public static class SimpleXPathPreferenceTreeItem extends SimpleTreeItem {
+ public SimpleXPathPreferenceTreeItem(SimpleTreeItem parent, Object data) {
+ super(parent, data);
+ }
+ }
+ public static class XPathPreferenceTreeItem extends SimpleXPathPreferenceTreeItem {
+ private String name;
+ private String elementXPath;
+ private String attributeName = null;
+
+ public XPathPreferenceTreeItem(SimpleTreeItem parent, String key, String value) {
+ super(parent, null);
+ this.name = key;
+ this.elementXPath = value;
+ }
+
+ public XPathPreferenceTreeItem(SimpleTreeItem parent, String key,
+ String value, String attributeName ) {
+ this(parent, key, value);
+ this.attributeName = attributeName;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getXPath() {
+ return elementXPath;
+ }
+ public void setXPath(String value) {
+ this.elementXPath = value;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getAttributeName() {
+ return attributeName;
+ }
+ public void setAttributeName(String attName) {
+ this.attributeName = attName;
+ }
+
+ }
+
}
1.9 +3 -6 jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JBossServer.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/JBossServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- JBossServer.java 10 Jul 2006 22:00:12 -0000 1.8
+++ JBossServer.java 27 Jul 2006 06:34:03 -0000 1.9
@@ -29,6 +29,7 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.internal.PublishServerJob;
import org.eclipse.wst.server.core.model.ServerDelegate;
@@ -73,15 +74,10 @@
public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
debug("saveConfiguration");
- //rtConfig.save();
- // Re-publish in case the configuration change has not been published yet.
- PublishServerJob publishJob = new PublishServerJob(getServer(), IServer.PUBLISH_INCREMENTAL, false);
- publishJob.schedule();
}
public void configurationChanged() {
debug("configurationChanged");
- //rtConfig.save();
}
@@ -102,6 +98,8 @@
public ServerAttributeHelper getAttributeHelper() {
+// IServer server = ServerCore.findServer(getServer().getId());
+// IServerWorkingCopy copy = server.createWorkingCopy();
IServerWorkingCopy copy = getServerWorkingCopy();
if( copy == null ) {
copy = getServer().createWorkingCopy();
@@ -150,5 +148,4 @@
return DescriptorModel.getDefault().getServerModel(getServer());
}
-
}
\ No newline at end of file
1.10 +2 -2 jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/ServerStateChecker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerStateChecker.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/ServerStateChecker.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ServerStateChecker.java 13 Jul 2006 04:39:55 -0000 1.9
+++ ServerStateChecker.java 27 Jul 2006 06:34:03 -0000 1.10
@@ -67,9 +67,9 @@
// load our timeouts
if( expectedState ) {
- max = JBossServerCorePlugin.getDefault().getPreferenceHelper().getStartTimeout(jbServer);
+ max = jbServer.getAttributeHelper().getStartTimeout();
} else {
- max = JBossServerCorePlugin.getDefault().getPreferenceHelper().getStopTimeout(jbServer);
+ max = jbServer.getAttributeHelper().getStopTimeout();
}
}
More information about the jboss-cvs-commits
mailing list