Author: rob.stryker(a)jboss.com
Date: 2012-02-28 11:17:03 -0500 (Tue, 28 Feb 2012)
New Revision: 39177
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.rse.ui/META-INF/MANIFEST.MF
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
Log:
JBIDE-11058 to branch beta1
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2012-02-28
16:17:03 UTC (rev 39177)
@@ -34,6 +34,7 @@
org.jboss.ide.eclipse.as.core.modules,
org.jboss.ide.eclipse.as.core.publishers,
org.jboss.ide.eclipse.as.core.publishers.patterns,
+ org.jboss.ide.eclipse.as.core.resolvers,
org.jboss.ide.eclipse.as.core.server,
org.jboss.ide.eclipse.as.core.server.bean,
org.jboss.ide.eclipse.as.core.server.internal,
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2012-02-28
16:17:03 UTC (rev 39177)
@@ -27,7 +27,9 @@
import org.jaxen.SimpleNamespaceContext;
import org.jaxen.XPath;
import org.jaxen.dom4j.Dom4jXPath;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
import org.jboss.ide.eclipse.as.core.util.IMemento;
/**
@@ -45,6 +47,7 @@
protected String baseDir;
protected volatile String effectiveBaseDir;
protected String filePattern;
+ protected volatile String effectiveFilePattern;
protected String xpathPattern;
protected String attribute;
@@ -69,6 +72,7 @@
this.xpathPattern = memento.getString("xpathPattern"); //$NON-NLS-1$
this.attribute = memento.getString("attribute"); //$NON-NLS-1$
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
public XPathQuery(String name, List list) {
@@ -78,6 +82,7 @@
this.xpathPattern = list.get(2).equals(XPathModel.EMPTY_STRING) ? null :
(String)list.get(2);
this.attribute = list.size() < 3 || list.get(3).equals(XPathModel.EMPTY_STRING) ?
null : (String)list.get(3);
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
public XPathQuery(IServer server, String name, String baseDir,
@@ -90,40 +95,33 @@
this.attribute = attribute;
this.results = null;
setEffectiveBaseDir();
+ setEffectiveFilePattern();
}
private void setEffectiveBaseDir() {
String serverName = server == null ? "" : server.getName(); //$NON-NLS-1$
String dir1 = baseDir == null ? null : baseDir;
-
- String dir2 = null;
- if( dir1 != null ) {
- dir2 = dir1.replace("${jboss_config_dir}", //$NON-NLS-1$
- "${jboss_config_dir:" + serverName + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- dir2 = dir2.replace("${jboss_config}", //$NON-NLS-1$
- "${jboss_config:" + serverName + "}"); //$NON-NLS-1$
//$NON-NLS-2$
-
- try {
- StringSubstitutionEngine engine = new StringSubstitutionEngine();
- dir2 = engine.performStringSubstitution(dir2, true,
- true, StringVariableManager.getDefault());
- } catch( CoreException ce ) {}
- }
-
-
+ String dir2 = new ConfigNameResolver().performSubstitutions(dir1, serverName);
IPath dir = dir2 == null ? null : new Path(dir2);
if( dir == null && category != null) {
dir = getCategory().getServer().getRuntime().getLocation();
}
if( dir != null && !dir.isAbsolute() && category != null)
dir = getCategory().getServer().getRuntime().getLocation().append(dir);
-
effectiveBaseDir = dir == null ? null : dir.toString();
}
+ private void setEffectiveFilePattern() {
+ String serverName = server == null ? "" : server.getName(); //$NON-NLS-1$
+ String pattern = filePattern == null ? null : filePattern;
+ String pattern2 = new ConfigNameResolver().performSubstitutions(pattern, serverName);
+ effectiveFilePattern = pattern2;
+ }
+
+
protected AntFileFilter getFilter() {
if( filter == null ) {
- filter = new AntFileFilter(effectiveBaseDir, filePattern);
+ filter = new AntFileFilter(effectiveBaseDir, effectiveFilePattern);
}
return filter;
}
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28
16:17:03 UTC (rev 39177)
@@ -11,6 +11,8 @@
package org.jboss.ide.eclipse.as.core.resolvers;
+import org.eclipse.core.internal.variables.StringSubstitutionEngine;
+import org.eclipse.core.internal.variables.StringVariableManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.variables.IDynamicVariable;
@@ -18,31 +20,83 @@
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.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
/**
* These classes are primarily geared for as6-and-below
* and are meant to serve as a dereferencing point to discover
* the configuration name and it's parent directory in the case
* other portions of the tool, such as xpaths or classpaths,
* want to use these variables in their saved strings.
- *
- * They are not really geared for use with as7 and above, and their
- * behaviour with regards to as7 and above are officially undefined,
- * though unofficially both should return the empty string in these cases
- * @author rob
- *
*/
public class ConfigNameResolver implements IDynamicVariableResolver {
+ public static final String JBOSS_CONFIG = "jboss_config"; //$NON-NLS-1$
+ public static final String JBOSS_CONFIG_DIR = "jboss_config_dir";
//$NON-NLS-1$
+ public static final String JBOSS_AS7_CONFIG_FILE = "jboss_config_file";
//$NON-NLS-1$
+
+ /*
+ * entry points to fill out the server name in these variable substitutions
+ */
+
+ /**
+ * Kick off the substitution engine for this string, doing
+ * server-related replacements (adding variables) beforehand.
+ *
+ * @param dir1
+ * @param serverName
+ * @return
+ */
+ public String performSubstitutions(String dir1, String serverName) {
+ String dir2 = null;
+ if( dir1 != null ) {
+ dir2 = replace(dir1, ConfigNameResolver.JBOSS_CONFIG, serverName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_CONFIG_DIR, serverName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_AS7_CONFIG_FILE, serverName);
+
+ try {
+ StringSubstitutionEngine engine = new StringSubstitutionEngine();
+ dir2 = engine.performStringSubstitution(dir2, true,
+ true, StringVariableManager.getDefault());
+ } catch( CoreException ce ) {
+ JBossServerCorePlugin.log(ce.getStatus());
+ }
+ }
+ return dir2;
+ }
+
+ private String replace(String original, String variable, String serverName) {
+ if( original != null ) {
+ return original.replace(getVariablePattern(variable), getVariablePattern(variable,
serverName));
+ }
+ return null;
+ }
+
+ private String getVariablePattern(String var) {
+ return "${" + var + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private String getVariablePattern(String var, String serverName) {
+ return "${" + var + ":" + serverName + "}"; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
+ /*
+ * Actual resolution of these dynamic variables are performed below
+ */
+
public String resolveValue(IDynamicVariable variable, String argument)
throws CoreException {
- if( variable.getName().equals("jboss_config")) //$NON-NLS-1$
+ if( variable.getName().equals(JBOSS_CONFIG))
return handleConfig(variable, argument);
- if( variable.getName().equals("jboss_config_dir")) //$NON-NLS-1$
+ if( variable.getName().equals(JBOSS_CONFIG_DIR))
return handleConfigDir(variable, argument);
+ if( variable.getName().equals(JBOSS_AS7_CONFIG_FILE))
+ return handleAS7ConfigFile(variable, argument);
return null;
}
-
+
protected String handleConfig(IDynamicVariable variable, String argument) {
IJBossServerRuntime ajbsrt = findJBossServerRuntime(argument);
if( ajbsrt != null ) {
@@ -66,6 +120,14 @@
return null;
}
+ protected String handleAS7ConfigFile(IDynamicVariable variable, String argument) {
+ IJBossServerRuntime ajbsrt = findJBossServerRuntime(argument);
+ if( ajbsrt != null && ajbsrt instanceof LocalJBoss7ServerRuntime) {
+ return ((LocalJBoss7ServerRuntime)ajbsrt).getConfigurationFile();
+ }
+ return null;
+ }
+
private IJBossServerRuntime findJBossServerRuntime(String serverName) {
IServer[] servers = ServerCore.getServers();
for( int i = 0; i < servers.length; i++ ) {
@@ -82,7 +144,6 @@
}
}
return null;
-
}
}
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-28
16:17:03 UTC (rev 39177)
@@ -1123,6 +1123,12 @@
resolver="org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver"
supportsArgument="true">
</variable>
+ <variable
+ name="jboss_config_file"
+ description="Returns the full path of the configuration file for the
server who's name matches the variable, or, if none, the runtime who's
name matches the variable"
+
resolver="org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver"
+ supportsArgument="true">
+ </variable>
</extension>
<extension
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28
16:17:03 UTC (rev 39177)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="management-interfaces"]/*[local-name()="native-interface"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/standalone.xml
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
\ No newline at end of file
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28
16:17:03 UTC (rev 39177)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="socket-binding-group"]/*[local-name()="socket-binding"][@name="management-native"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/standalone.xml
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
\ No newline at end of file
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.rse.ui/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.rse.ui/META-INF/MANIFEST.MF 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.rse.ui/META-INF/MANIFEST.MF 2012-02-28
16:17:03 UTC (rev 39177)
@@ -28,7 +28,6 @@
org.eclipse.rse.ui;bundle-version="3.2.0",
org.eclipse.wst.server.ui;bundle-version="1.1.305",
org.eclipse.debug.ui;bundle-version="3.7.0",
- org.eclipse.rse.subsystems.shells.dstore;bundle-version="2.1.300",
org.eclipse.rse.subsystems.shells.local;bundle-version="2.1.300",
org.eclipse.rse.subsystems.shells.ssh;bundle-version="2.1.300",
org.eclipse.rse.subsystems.shells.telnet;bundle-version="1.2.200",
Modified:
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-02-28
16:14:54 UTC (rev 39176)
+++
branches/jbosstools-3.3.0.Beta1/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-02-28
16:17:03 UTC (rev 39177)
@@ -67,6 +67,7 @@
import
org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathFileResult.XPathResultNode;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -372,25 +373,23 @@
final String xpText = xpathText.getText();
final String attText = attributeText.getText();
- final String filePattern = filesetText.getText();
+ String filePattern = filesetText.getText();
String directory = baseDirText.getText();
- directory = directory.replace("${jboss_config_dir}", //$NON-NLS-1$
- "${jboss_config_dir:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- directory = directory.replace("${jboss_config}", //$NON-NLS-1$
- "${jboss_config:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
- try {
- StringSubstitutionEngine engine = new StringSubstitutionEngine();
- directory = engine.performStringSubstitution(directory, true,
- true, StringVariableManager.getDefault());
- } catch( CoreException ce ) {}
+
+ // substitute in basedir
+ directory = new ConfigNameResolver().performSubstitutions(directory,
server.getName());
if( !new Path(directory).isAbsolute()) {
directory = server.getRuntime().getLocation().append(directory).toString();
}
-
final String directory2 = directory;
+
+ // substitute in filePattern
+ filePattern = new ConfigNameResolver().performSubstitutions(filePattern,
server.getName());
+ final String filePattern2 = filePattern;
+
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- XPathQuery tmp = new XPathQuery(null, "", directory2, filePattern, xpText,
attText); //$NON-NLS-1$
+ XPathQuery tmp = new XPathQuery(null, "", directory2, filePattern2,
xpText, attText); //$NON-NLS-1$
tmp.setRepository(repository);
final ArrayList<XPathFileResult> list = new
ArrayList<XPathFileResult>();
list.addAll(Arrays.asList(tmp.getResults()));
@@ -413,7 +412,9 @@
try {
new ProgressMonitorDialog(new Shell()).run(true, true, op);
} catch (InvocationTargetException e) {
+ //Do not need to do anything
} catch (InterruptedException e) {
+ //Do not need to do anything
}
}
protected void layoutWidgets(Composite c) {