Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBIDE-13208 - remove hard-code refs to standalone #152

Merged
merged 1 commit into from Oct 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -275,6 +275,8 @@ private XPathCategory[] load_LEGACY(IServer server) {
private static HashMap<String, URL> rtToPortsFile;
private static final String ATTRIBUTE_SUFFIX = "_ATTRIBUTE";//$NON-NLS-1$
private static final String FILE_SUFFIX = "_FILE";//$NON-NLS-1$
private static final String BASEDIR_SUFFIX = "_BASEDIR";//$NON-NLS-1$

static {
rtToPortsFile = new HashMap<String, URL>();
rtToPortsFile.put(IConstants.AS_32, getURLFor(DEFAULT_PROPS_32));
Expand Down Expand Up @@ -344,15 +346,18 @@ public static void addQueriesToCategoryFromDefaultFile(IServer server, XPathCate
Properties pr = new Properties();
pr.load(url.openStream());
Iterator<Object> i = pr.keySet().iterator();
String name, xpath, attributeName, file;
String name, xpath, attributeName, file, tmpBasedir;
XPathQuery query;
while(i.hasNext()) {
name = (String)i.next();
if( !name.endsWith(ATTRIBUTE_SUFFIX) && !name.endsWith(FILE_SUFFIX)) {
if( !name.endsWith(ATTRIBUTE_SUFFIX) && !name.endsWith(FILE_SUFFIX) && !name.endsWith(BASEDIR_SUFFIX)) {
xpath = pr.getProperty(name);
attributeName = pr.getProperty(name+ATTRIBUTE_SUFFIX);
file = pr.getProperty(name + FILE_SUFFIX);
query = new XPathQuery(server, name.replace('_', ' '), baseDir, file, xpath, attributeName);
tmpBasedir = pr.getProperty(name + BASEDIR_SUFFIX);
query = new XPathQuery(server, name.replace('_', ' '),
tmpBasedir == null ? baseDir : tmpBasedir,
file, xpath, attributeName);
category.addQuery(query);
}
}
Expand Down
Expand Up @@ -72,7 +72,9 @@ public String getProperty(String prop) {
boolean relative = PROP_SERVER_TMP_DEPLOYMENTS_FOLDER_REL.equals(prop);
IPath p = null;
if( isAS7Structure()) {
p = new Path(IJBossRuntimeResourceConstants.AS7_STANDALONE)
LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)server.getRuntime().loadAdapter(LocalJBoss7ServerRuntime.class, null);
String basedir = jb7rt.getBaseDirectory();
p = new Path(basedir)
.append(IJBossRuntimeResourceConstants.FOLDER_TMP);
} else {
p = new Path(jbrt.getConfigLocation()).append(jbrt.getJBossConfiguration())
Expand Down
Expand Up @@ -11,8 +11,10 @@
package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;

public class GateIn33AS71DefaultLaunchArguments extends JBoss71DefaultLaunchArguments {
public GateIn33AS71DefaultLaunchArguments(IServer s) {
Expand Down Expand Up @@ -41,9 +43,10 @@ protected String getLoggingProgramArg() {
}

protected String getJBossJavaFlags() {
LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)runtime.getAdapter(LocalJBoss7ServerRuntime.class);
IPath basedir = new Path(jb7rt.getBaseDirectory());
IPath gateInConfig =
getServerHome().append("standalone")//$NON-NLS-1$
.append("configuration").append("gatein"); //$NON-NLS-1$ //$NON-NLS-2$
basedir.append("configuration").append("gatein"); //$NON-NLS-1$ //$NON-NLS-2$
String s1 = "-Dexo.conf.dir=" + QUOTE //$NON-NLS-1$
+ gateInConfig.toString()
+ QUOTE + SPACE
Expand Down
Expand Up @@ -11,8 +11,10 @@
package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;

public class JBoss70DefaultLaunchArguments extends JBossDefaultLaunchArguments {
Expand Down Expand Up @@ -57,10 +59,11 @@ protected String getJBossJavaFlags() {

// don't like typing that big constants interface over and over; its ugly
IJBossRuntimeResourceConstants c = new IJBossRuntimeResourceConstants() {};

LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)runtime.loadAdapter(LocalJBoss7ServerRuntime.class, null);
IPath base = new Path(jb7rt.getBaseDirectory());
// TODO this can be changed to the config folder, if such a feature is added
IPath bootLog = serverHome.append(c.AS7_STANDALONE).append(c.FOLDER_LOG).append(c.AS7_BOOT_LOG);
IPath logConfig = serverHome.append(c.AS7_STANDALONE).append(c.CONFIGURATION).append(c.LOGGING_PROPERTIES);
IPath bootLog = base.append(c.FOLDER_LOG).append(c.AS7_BOOT_LOG);
IPath logConfig = base.append(c.CONFIGURATION).append(c.LOGGING_PROPERTIES);

String ret =
"-Djava.awt.headless=true" + //$NON-NLS-1$
Expand Down
Expand Up @@ -11,17 +11,18 @@
package org.jboss.ide.eclipse.as.core.server.internal.extendedproperties;

import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.AS7_DEPLOYMENTS;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.AS7_STANDALONE;

import java.io.File;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.internal.launching.environments.EnvironmentsManager;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
import org.jboss.ide.eclipse.as.core.server.IDefaultLaunchArguments;
import org.jboss.ide.eclipse.as.core.server.IDeploymentScannerModifier;
import org.jboss.ide.eclipse.as.core.server.IServerModuleStateVerifier;
Expand All @@ -43,7 +44,10 @@ public String getNewXPathDefaultRootFolder() {
}

public String getNewFilesetDefaultRootFolder() {
return IJBossRuntimeResourceConstants.AS7_STANDALONE + "/" + IJBossRuntimeResourceConstants.CONFIGURATION; //$NON-NLS-1$
if( runtime == null )
return IJBossRuntimeResourceConstants.AS7_STANDALONE + "/" + IJBossRuntimeResourceConstants.CONFIGURATION; //$NON-NLS-1$
LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)runtime.loadAdapter(LocalJBoss7ServerRuntime.class, null);
return jb7rt.getConfigLocation();
}

public String getNewClasspathFilesetDefaultRootFolder() {
Expand Down Expand Up @@ -77,11 +81,9 @@ public String getVerifyStructureErrorMessage() throws CoreException {
return NLS.bind(Messages.RuntimeFolderDoesNotExist, server.getRuntime().getLocation().toOSString());
IRuntime rt = server.getRuntime();
LocalJBoss7ServerRuntime rt2 = (LocalJBoss7ServerRuntime)rt.loadAdapter(LocalJBoss7ServerRuntime.class, null);
String cfile = rt2.getConfigurationFile();
IPath cFilePath = rt.getLocation().append(IJBossRuntimeResourceConstants.AS7_STANDALONE)
.append(IJBossRuntimeResourceConstants.CONFIGURATION).append(cfile);
if( !cFilePath.toFile().exists())
return NLS.bind(Messages.JBossAS7ConfigurationFileDoesNotExist, cFilePath.toOSString());
String cFile = rt2.getConfigurationFileFullPath();
if( !(new File(cFile)).exists())
return NLS.bind(Messages.JBossAS7ConfigurationFileDoesNotExist, cFile);
return null;
}

Expand Down Expand Up @@ -135,7 +137,8 @@ public String getManagerServiceId() {
public String getServerDeployLocation() {
if( runtime == null )
return null;
IPath p = runtime.getLocation().append(AS7_STANDALONE).append(AS7_DEPLOYMENTS);
LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)runtime.loadAdapter(LocalJBoss7ServerRuntime.class, null);
IPath p = new Path(jb7rt.getBaseDirectory()).append(AS7_DEPLOYMENTS);
return ServerUtil.makeGlobal(runtime, p).toString();
}
}
Expand Up @@ -38,8 +38,8 @@ public class JBossDefaultLaunchArguments implements IDefaultLaunchArguments, IJB
// If created with a server, we can try to get values from
// whatever 'mode' it is in (local vs rse).
public JBossDefaultLaunchArguments(IServer s) {
this(s.getRuntime());
this.server = s;
serverHome = getLocalRuntimeHomeDirectory();
}

/*
Expand Down
Expand Up @@ -43,6 +43,21 @@ public void setConfigurationFile(String file, ILaunchConfigurationWorkingCopy la
}
}

/**
* @since 2.5
*/
public void setBaseDirectory(String file, ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
if (isSet(file)) {
String progArgs = getProgramArguments(launchConfig);
progArgs = ArgsUtil.setArg(progArgs,
null, IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_BASE_DIR, file);
setProgramArguments(progArgs, launchConfig);
}
}



public void setBootLogFile(String blf, ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException {
if (isSet(blf)) {
Expand Down
Expand Up @@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.v7;

import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.AS7_STANDALONE;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.FOLDER_TMP;
import static org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants.AS7_MANAGEMENT_PORT;
import static org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants.AS7_MANAGEMENT_PORT_DEFAULT_PORT;
Expand All @@ -25,11 +24,11 @@

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IRuntime;
import org.jboss.ide.eclipse.as.core.server.IManagementPortProvider;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import org.jboss.ide.eclipse.as.core.util.ExpressionResolverUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;

Expand Down Expand Up @@ -75,7 +74,8 @@ public String getTempDeployFolder() {
String type = getDeployLocationType();
if( DEPLOY_SERVER.equals(type)) {
IRuntime rt = getServer().getRuntime();
IPath p = rt.getLocation().append(AS7_STANDALONE).append(FOLDER_TMP);
LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)rt.loadAdapter(LocalJBoss7ServerRuntime.class, null);
IPath p = new Path(jb7rt.getBaseDirectory()).append(FOLDER_TMP);
return ServerUtil.makeGlobal(rt, p).toString();
}
return getTempDeployFolder(this, type);
Expand Down
Expand Up @@ -13,6 +13,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
Expand All @@ -22,6 +23,10 @@
public class LocalJBoss7ServerRuntime extends LocalJBossServerRuntime implements IJBossRuntimeConstants {
public static final String CONFIG_FILE = "org.jboss.ide.eclipse.as.core.server.internal.v7.CONFIG_FILE"; //$NON-NLS-1$
public static final String CONFIG_FILE_DEFAULT = "standalone.xml"; //$NON-NLS-1$
/**
* @since 2.5
*/
public static final String BASE_DIRECTORY = "org.jboss.ide.eclipse.as.core.server.internal.v7.BASE_DIRECTORY"; //$NON-NLS-1$

@Override
public void setDefaults(IProgressMonitor monitor) {
Expand Down Expand Up @@ -63,12 +68,50 @@ public void setConfigurationFile(String file) {
setAttribute(CONFIG_FILE, file);
}

/**
* @since 2.5
*/
public String getConfigurationFileFullPath() {
String configFile = getConfigurationFile();
if( new Path(configFile).isAbsolute())
return configFile;

// If the file is not absolute, it's relative to the configuration folder
IPath configFolder = new Path(getBaseDirectory()).append(IJBossRuntimeResourceConstants.CONFIGURATION);
return configFolder.append(configFile).toFile().getAbsolutePath();
}


/**
* This method is technically internal and is not part of any interface
*
* @since 2.5
*/
public String getBaseDirectory() {
String bd = getAttribute(BASE_DIRECTORY, IJBossRuntimeResourceConstants.AS7_STANDALONE);
Path p = new Path(bd);
if( p.isAbsolute() )
return p.toFile().getAbsolutePath();
return getRuntime().getLocation().append(p).toFile().getAbsolutePath();
}

/**
* Set a base directory, which may either be relative to the server home,
* or, a file-system absolute path. Setting the value of 'null' will
* restore it to the default of 'standalone'
*
* @since 2.5
*/
public void setBaseDirectory(String s) {
setAttribute(BASE_DIRECTORY, s);
}



// Overrides of as6-and-below's notion of configuration
@Override
public String getConfigLocation() {
IPath config = getRuntime().getLocation().append(IJBossRuntimeResourceConstants.AS7_STANDALONE)
.append(IJBossRuntimeResourceConstants.CONFIGURATION);
return config.toFile().getAbsolutePath();
return new Path(getBaseDirectory()).append(IJBossRuntimeResourceConstants.CONFIGURATION).toFile().getAbsolutePath();
}

@Override
Expand Down
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.IVMInstall;
Expand Down Expand Up @@ -65,6 +66,7 @@ protected void doOverrides(ILaunchConfigurationWorkingCopy launchConfig, JBossSe
getProperties().setServerId(getServerId(jbossServer), launchConfig);
getProperties().setModulesFolder(getModulesFolder(jbossServer, jbossRuntime), launchConfig);
getProperties().setConfigurationFile(getServerConfigFile(jbossServer, jbossRuntime), launchConfig);
getProperties().setBaseDirectory(getBaseDir(jbossRuntime), launchConfig);
getProperties().setBootLogFile(getBootLogPath(jbossRuntime), launchConfig);
getProperties().setLoggingConfigFile(getLoggingConfigPath(jbossRuntime), launchConfig);
}
Expand All @@ -90,6 +92,14 @@ protected String getServerConfigFile(JBossServer server, IJBossServerRuntime run
return rt.getConfigurationFile();
}

/**
* @since 2.5
*/
protected String getBaseDir(IJBossServerRuntime runtime) throws CoreException {
LocalJBoss7ServerRuntime rt = (LocalJBoss7ServerRuntime)runtime.getRuntime().loadAdapter(LocalJBoss7ServerRuntime.class, null);
return rt.getBaseDirectory();
}


@Override
protected List<String> getClasspath(JBossServer server, IJBossServerRuntime runtime, List<String> currentClasspath) throws CoreException {
Expand Down Expand Up @@ -144,16 +154,16 @@ protected String getJavaLibraryPath(IJBossServerRuntime runtime) {
}

protected String getBootLogPath(IJBossServerRuntime runtime) {
IPath serverHome = runtime.getRuntime().getLocation();
IJBossRuntimeResourceConstants c = new IJBossRuntimeResourceConstants() {};
IPath bootLog = serverHome.append(c.AS7_STANDALONE).append(c.FOLDER_LOG).append(c.AS7_BOOT_LOG);
IPath basedir = new Path(((LocalJBoss7ServerRuntime)runtime).getBaseDirectory());
IPath bootLog = basedir.append(c.FOLDER_LOG).append(c.AS7_BOOT_LOG);
return bootLog.toString();
}

protected String getLoggingConfigPath(IJBossServerRuntime runtime) {
IJBossRuntimeResourceConstants c = new IJBossRuntimeResourceConstants() {};
IPath serverHome = runtime.getRuntime().getLocation();
IPath logConfigPath = serverHome.append(c.AS7_STANDALONE).append(c.CONFIGURATION).append(c.LOGGING_PROPERTIES);
IPath basedir = new Path(((LocalJBoss7ServerRuntime)runtime).getBaseDirectory());
IPath logConfigPath = basedir.append(c.CONFIGURATION).append(c.LOGGING_PROPERTIES);
try {
return logConfigPath.toFile().toURI().toURL().toString();
} catch (MalformedURLException murle) {
Expand Down
@@ -1,6 +1,8 @@
JBoss_Web=//*[@name="standard-sockets"]/*[@name="http"]
JBoss_Web_FILE=standalone/configuration/${jboss_config_file}
JBoss_Web_BASEDIR=${jboss_config_dir}
JBoss_Web_FILE=${jboss_config_file}
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="management-interfaces"]/*[local-name()="native-interface"]
JBoss_Management_ATTRIBUTE=port
JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
JBoss_Management_BASEDIR=${jboss_config_dir}
JBoss_Management_FILE=${jboss_config_file}
@@ -1,9 +1,12 @@
JBoss_Web=//*[@name="standard-sockets"]/*[@name="http"]
JBoss_Web_FILE=standalone/configuration/${jboss_config_file}
JBoss_Web_BASEDIR=${jboss_config_dir}
JBoss_Web_FILE=${jboss_config_file}
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/${jboss_config_file}
JBoss_Management_BASEDIR=${jboss_config_dir}
JBoss_Management_FILE=${jboss_config_file}
Port_Offset=//*[local-name()="socket-binding-group"]
Port_Offset_ATTRIBUTE=port-offset
Port_Offset_FILE=standalone/configuration/${jboss_config_file}
Port_Offset_BASEDIR=${jboss_config_dir}
Port_Offset_FILE=${jboss_config_file}
@@ -1,9 +1,12 @@
JBoss_Web=//*[@name="standard-sockets"]/*[@name="http"]
JBoss_Web_FILE=standalone/configuration/${jboss_config_file}
JBoss_Web_BASEDIR=${jboss_config_dir}
JBoss_Web_FILE=${jboss_config_file}
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="socket-binding-group"]/*[local-name()="socket-binding"][@name="management-http"]
JBoss_Management_ATTRIBUTE=port
JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
JBoss_Management_BASEDIR=${jboss_config_dir}
JBoss_Management_FILE=${jboss_config_file}
Port_Offset=//*[local-name()="socket-binding-group"]
Port_Offset_ATTRIBUTE=port-offset
Port_Offset_FILE=standalone/configuration/${jboss_config_file}
Port_Offset_BASEDIR=${jboss_config_dir}
Port_Offset_FILE=${jboss_config_file}
Expand Up @@ -52,6 +52,10 @@
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.UIUtil;

/**
* This class was replaced by {@link DeploymentPage}
*/
@Deprecated
public class ModuleDeploymentPage extends ServerEditorPart {
protected ServerResourceCommandManager commandManager;
protected ArrayList<IModule> possibleModules;
Expand Down