Author: rob.stryker(a)jboss.com
Date: 2009-04-22 03:24:57 -0400 (Wed, 22 Apr 2009)
New Revision: 14843
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
Log:
JBIDE-3896 - initial fix commit... let's see how this goes
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -27,8 +27,10 @@
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.jboss.ide.eclipse.as.core.server.internal.ServerListener;
@@ -99,5 +101,16 @@
public ResourceBundle getResourceBundle() {
return resourceBundle;
}
-
+
+ public static IPath getServerStateLocation(IServer server) {
+ return server == null ? getDefault().getStateLocation() :
+ getServerStateLocation(server.getId());
+ }
+
+ public static IPath getServerStateLocation(String serverID) {
+ return serverID == null ? getDefault().getStateLocation() :
+ JBossServerCorePlugin.getDefault().getStateLocation()
+ .append(serverID.replace(' ', '_'));
+ }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/events/ServerLogger.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -28,6 +28,7 @@
import org.eclipse.core.runtime.IStatus;
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.IJBossServerConstants;
public class ServerLogger implements IJBossServerConstants {
@@ -77,8 +78,7 @@
}
public static File getServerLogFile(IServer server) {
- File f = server == null ? PLUGIN_LOCATION.toFile() :
- PLUGIN_LOCATION.append(server.getId().replace(' ',
'_')).append(LOG).toFile();
+ File f = JBossServerCorePlugin.getServerStateLocation(server).append(LOG).toFile();
if( !f.getParentFile().exists() )
f.getParentFile().mkdirs();
return f;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerConstants.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -31,12 +31,17 @@
*
*/
public interface IJBossServerConstants {
- public static final IPath PLUGIN_LOCATION =
JBossServerCorePlugin.getDefault().getStateLocation();
+ // Metadata folders
public static final String LOG = "log";
public static final String TEMP_DEPLOY = "tempDeploy";
public static final String JBOSSTOOLS_TMP = "jbosstoolsTemp";
public static final String TMP = "tmp";
+ public static final String CONFIG_IN_METADATA = "jbossConfig";
+
+ // Preference codes
+ public static final String USE_METADATA_CONFIG =
"IJBossServerConstants.useMetadataConfig";
+
// Launch configuration constants
public static final String JBOSS_SERVER_HOME_DIR = "jboss.server.home.dir";
public static final String JBOSS_SERVER_BASE_DIR = "jboss.server.base.dir";
@@ -47,6 +52,11 @@
public static final String DEFAULT_SERVER_NAME = "default";
public static final String DEPLOY = "deploy";
public static final String SERVER = "server";
+ public static final String WORK = "work";
+ public static final String DATA = "data";
+// public static final String TMP = "tmp"; // repeat
+// public static final String LOG = "log"; // repeat
+ public static final String[] JBOSS_TEMPORARY_FOLDERS = new String[] { WORK, DATA, TMP,
LOG};
// Property keys stored in the server object
public static final String SERVER_USERNAME =
"org.jboss.ide.eclipse.as.core.server.userName";
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -35,13 +35,13 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.model.ServerDelegate;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.util.ModuleUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class DeployableServer extends ServerDelegate implements IDeployableServer {
@@ -87,7 +87,7 @@
private IModule[] doGetParentModules(IModule module) {
- IModule[] ears = ServerUtil.getModules("jst.ear"); //$NON-NLS-1$
+ IModule[] ears =
org.eclipse.wst.server.core.ServerUtil.getModules("jst.ear"); //$NON-NLS-1$
ArrayList<IModule> list = new ArrayList<IModule>();
for (int i = 0; i < ears.length; i++) {
IEnterpriseApplication ear =
(IEnterpriseApplication)ears[i].loadAdapter(IEnterpriseApplication.class,null);
@@ -110,43 +110,21 @@
public String getDeployFolder() {
- String type = getDeployLocationType();
- if( type.equals(DEPLOY_CUSTOM))
- return makeGlobal(getRuntime(), new Path(getAttribute(DEPLOY_DIRECTORY,
""))).toString();
- if( type.equals(DEPLOY_METADATA)) {
- return IJBossServerConstants.PLUGIN_LOCATION.append(getServer().getId().replace('
', '_')).
- append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
- } else /* if( type.equals(DEPLOY_SERVER)) */ {
- IJBossServerRuntime jbsrt = getRuntime();
- String config = jbsrt.getJBossConfiguration();
- IPath p = new Path(IJBossServerConstants.SERVER).append(config)
- .append(IJBossServerConstants.DEPLOY).makeRelative();
- return makeGlobal(getRuntime(), p).toString();
- }
+ IJBossServerRuntime jbsrt = getRuntime();
+ return ServerUtil.makeGlobal(jbsrt, new Path(getAttribute(DEPLOY_DIRECTORY,
""))).toString();
}
public void setDeployFolder(String folder) {
- setAttribute(DEPLOY_DIRECTORY, makeRelative(getRuntime(), new
Path(folder)).toString());
+ setAttribute(DEPLOY_DIRECTORY, ServerUtil.makeRelative(getRuntime(), new
Path(folder)).toString());
}
public String getTempDeployFolder() {
- String type = getDeployLocationType();
- if( type.equals(DEPLOY_CUSTOM))
- return makeGlobal(getRuntime(), new Path(getAttribute(TEMP_DEPLOY_DIRECTORY,
""))).toString();
- if( type.equals(DEPLOY_METADATA)) {
- return IJBossServerConstants.PLUGIN_LOCATION.append(getServer().getId().replace('
', '_')).
- append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
- } else /* if( type.equals(DEPLOY_SERVER)) */{
- IJBossServerRuntime jbsrt = getRuntime();
- String config = jbsrt.getJBossConfiguration();
- IPath p = new Path(IJBossServerConstants.SERVER)
- .append(config).append(IJBossServerConstants.TMP)
- .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative();
- return makeGlobal(getRuntime(), p).toString();
- }
- }
+ IJBossServerRuntime jbsrt = getRuntime();
+ return ServerUtil.makeGlobal(jbsrt, new Path(getAttribute(TEMP_DEPLOY_DIRECTORY,
""))).toString();
+ }
+
public void setTempDeployFolder(String folder) {
- setAttribute(TEMP_DEPLOY_DIRECTORY, makeRelative(getRuntime(), new
Path(folder)).toString());
+ setAttribute(TEMP_DEPLOY_DIRECTORY, ServerUtil.makeRelative(getRuntime(), new
Path(folder)).toString());
}
public void setDeployLocationType(String type) {
@@ -188,21 +166,5 @@
new NullProgressMonitor());
return ajbsrt;
}
-
- public static IPath makeRelative(IJBossServerRuntime rt, IPath p) {
- if( p.isAbsolute() && rt != null) {
- if(rt.getRuntime().getLocation().isPrefixOf(p)) {
- int size = rt.getRuntime().getLocation().toOSString().length();
- return new Path(p.toOSString().substring(size)).makeRelative();
- }
- }
- return p;
- }
-
- public static IPath makeGlobal(IJBossServerRuntime rt, IPath p) {
- if( !p.isAbsolute() && rt != null) {
- return rt.getRuntime().getLocation().append(p).makeAbsolute();
- }
- return p;
- }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -27,6 +27,7 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -46,6 +47,7 @@
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
*
@@ -134,14 +136,57 @@
}
public String getDeployFolder() {
- String folder = super.getDeployFolder();
- return folder != null ? folder : getDeployFolder(true);
+ IJBossServerRuntime jbsrt = getRuntime();
+ String type = getDeployLocationType();
+ if( type.equals(DEPLOY_CUSTOM))
+ return ServerUtil.makeGlobal(jbsrt, new Path(getAttribute(DEPLOY_DIRECTORY,
""))).toString();
+ if( type.equals(DEPLOY_METADATA)) {
+ return JBossServerCorePlugin.getServerStateLocation(getServer()).
+ append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+ } else if( type.equals(DEPLOY_SERVER)) {
+ if( !getAttribute(USE_METADATA_CONFIG, false)) {
+ String config = jbsrt.getJBossConfiguration();
+ IPath p = new Path(IJBossServerConstants.SERVER).append(config)
+ .append(IJBossServerConstants.DEPLOY).makeRelative();
+ return ServerUtil.makeGlobal(jbsrt, p).toString();
+ } else {
+ IPath dest = JBossServerCorePlugin.getServerStateLocation(getServer());
+ dest = dest.append(IJBossServerConstants.CONFIG_IN_METADATA);
+ return dest.toOSString();
+ }
+ }
+ return null;
}
protected String getDeployFolder(boolean checkLaunchConfig) {
return new Path(getConfigDirectory(checkLaunchConfig) + Path.SEPARATOR +
DEPLOY).toOSString();
}
+
+ public String getTempDeployFolder() {
+ IJBossServerRuntime jbsrt = getRuntime();
+ String type = getDeployLocationType();
+ if( type.equals(DEPLOY_CUSTOM))
+ return ServerUtil.makeGlobal(jbsrt, new Path(getAttribute(TEMP_DEPLOY_DIRECTORY,
""))).toString();
+ if( type.equals(DEPLOY_METADATA)) {
+ return JBossServerCorePlugin.getServerStateLocation(getServer()).
+ append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ } else if( type.equals(DEPLOY_SERVER)) {
+ if( !getAttribute(USE_METADATA_CONFIG, false)) {
+ String config = jbsrt.getJBossConfiguration();
+ IPath p = new Path(IJBossServerConstants.SERVER)
+ .append(config).append(IJBossServerConstants.TMP)
+ .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative();
+ return ServerUtil.makeGlobal(jbsrt, p).toString();
+ } else {
+ return JBossServerCorePlugin.getServerStateLocation(getServer()).
+ append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ }
+ }
+ return null;
+ }
+
+
protected String getLaunchConfigConfigurationDirectory() {
try {
Server s = (Server)getServer();
@@ -167,6 +212,10 @@
return null;
}
+ public boolean isMetadataConfig() {
+ return getAttribute(USE_METADATA_CONFIG, false);
+ }
+
protected String getRuntimeConfigDirectory() {
IJBossServerRuntime runtime = (IJBossServerRuntime)
getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/ServerListener.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -6,6 +6,7 @@
import javax.management.ObjectName;
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.Path;
@@ -13,6 +14,7 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerEvent;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
@@ -22,6 +24,7 @@
import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.tools.jmx.core.IJMXRunnable;
import org.jboss.tools.jmx.core.JMXException;
@@ -34,35 +37,11 @@
}
public void serverAdded(IServer server) {
- // create metadata area
- File location =
IJBossServerConstants.PLUGIN_LOCATION.append(server.getId().replace(' ',
'_')).toFile();
- location.mkdirs();
-
- // create temp deploy folder
- IDeployableServer ds = (IDeployableServer)server.loadAdapter(IDeployableServer.class,
null);
- if( ds != null ) {
- File d1 = new File(location, IJBossServerConstants.DEPLOY);
- File d2 = new File(location, IJBossServerConstants.TEMP_DEPLOY);
- d1.mkdirs();
- d2.mkdirs();
- if( !new File(ds.getDeployFolder()).equals(d1))
- new File(ds.getDeployFolder()).mkdirs();
- if( !new File(ds.getTempDeployFolder()).equals(d2))
- new File(ds.getTempDeployFolder()).mkdirs();
- IRuntime rt = server.getRuntime();
- IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
- String config = jbsrt.getJBossConfiguration();
- IPath newTemp = new Path(IJBossServerConstants.SERVER).append(config)
- .append(IJBossServerConstants.TMP)
- .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative();
- IPath newTempAsGlobal = DeployableServer.makeGlobal(jbsrt, newTemp);
- newTempAsGlobal.toFile().mkdirs();
- }
}
public void serverRemoved(IServer server) {
// delete metadata area
- File f = IJBossServerConstants.PLUGIN_LOCATION.append(server.getId().replace('
', '_')).toFile();
+ File f = JBossServerCorePlugin.getServerStateLocation(server).toFile();
FileUtil.safeDelete(f);
}
@@ -119,7 +98,7 @@
IPath deploy = new Path(IJBossServerConstants.SERVER)
.append(config)
.append(IJBossServerConstants.DEPLOY).makeRelative();
- IPath deployGlobal = DeployableServer.makeGlobal(jbsrt, deploy);
+ IPath deployGlobal = ServerUtil.makeGlobal(jbsrt, deploy);
if( new Path(deployFolder).equals(deployGlobal))
shouldAdd = false;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -21,6 +21,7 @@
*/
package org.jboss.ide.eclipse.as.core.server.internal.launch;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -49,6 +50,7 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
@@ -121,7 +123,16 @@
jbs.getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
String config = runtime.getJBossConfiguration();
args = ArgsUtil.setArg(args, "-c", "--configuration", config);
-
+
+ if( jbs.isMetadataConfig()) {
+ try {
+ IPath dest = JBossServerCorePlugin.getServerStateLocation(jbs.getServer());
+ dest = dest.append(IJBossServerConstants.CONFIG_IN_METADATA);
+ args = ArgsUtil.setArg(args, null, "-Djboss.server.home.url",
dest.toFile().toURL().toString());
+ } catch( MalformedURLException murle) {}
+ }
+
+
vmArgs= ArgsUtil.setArg(vmArgs, null, "-Djava.endorsed.dirs",
"\"" +
runtime.getRuntime().getLocation().append("lib").append("endorsed") +
"\"", false);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -1,5 +1,85 @@
package org.jboss.ide.eclipse.as.core.util;
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+
public class ServerUtil {
-
+
+ public static IPath makeRelative(IJBossServerRuntime rt, IPath p) {
+ if( p.isAbsolute() && rt != null) {
+ if(rt.getRuntime().getLocation().isPrefixOf(p)) {
+ int size = rt.getRuntime().getLocation().toOSString().length();
+ return new Path(p.toOSString().substring(size)).makeRelative();
+ }
+ }
+ return p;
+ }
+
+ public static IPath makeGlobal(IJBossServerRuntime rt, IPath p) {
+ if( !p.isAbsolute() && rt != null) {
+ return rt.getRuntime().getLocation().append(p).makeAbsolute();
+ }
+ return p;
+ }
+
+ public static void cloneConfigToMetadata(IServer server, IProgressMonitor monitor) {
+ IPath dest = JBossServerCorePlugin.getServerStateLocation(server);
+ dest = dest.append(IJBossServerConstants.CONFIG_IN_METADATA);
+ IRuntime rt = server.getRuntime();
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ IPath src =
rt.getLocation().append(IJBossServerConstants.SERVER).append(jbsrt.getJBossConfiguration());
+ dest.toFile().mkdirs();
+
+ File[] subFiles = src.toFile().listFiles();
+ dest.toFile().mkdirs();
+ String[] excluded = IJBossServerConstants.JBOSS_TEMPORARY_FOLDERS;
+ for (int i = 0; i < subFiles.length; i++) {
+ boolean found = false;
+ for( int j = 0; j < excluded.length; j++)
+ if( subFiles[i].getName().equals(excluded[j]))
+ found = true;
+ if( !found ) {
+ File newDest = new File(dest.toFile(), subFiles[i].getName());
+ FileUtil.fileSafeCopy(subFiles[i], newDest, null);
+ }
+ }
+ }
+
+ public static void createStandardFolders(IServer server) {
+ // create metadata area
+ File location = JBossServerCorePlugin.getServerStateLocation(server).toFile();
+ location.mkdirs();
+
+ // create temp deploy folder
+ JBossServer ds = ( JBossServer)server.loadAdapter(JBossServer.class, null);
+ if( ds != null ) {
+ File d1 = new File(location, IJBossServerConstants.DEPLOY);
+ File d2 = new File(location, IJBossServerConstants.TEMP_DEPLOY);
+ d1.mkdirs();
+ d2.mkdirs();
+ if( !new File(ds.getDeployFolder()).equals(d1))
+ new File(ds.getDeployFolder()).mkdirs();
+ if( !new File(ds.getTempDeployFolder()).equals(d2))
+ new File(ds.getTempDeployFolder()).mkdirs();
+ IRuntime rt = server.getRuntime();
+ IJBossServerRuntime jbsrt =
(IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new
NullProgressMonitor());
+ String config = jbsrt.getJBossConfiguration();
+ IPath newTemp = new Path(IJBossServerConstants.SERVER).append(config)
+ .append(IJBossServerConstants.TMP)
+ .append(IJBossServerConstants.JBOSSTOOLS_TMP).makeRelative();
+ IPath newTempAsGlobal = ServerUtil.makeGlobal(jbsrt, newTemp);
+ newTempAsGlobal.toFile().mkdirs();
+ }
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -59,6 +59,7 @@
public static String swf_DeploymentDescription;
public static String swf_DeployDirectory;
public static String swf_TempDeployDirectory;
+ public static String swf_CloneConfiguration;
public static String sswf_Title;
public static String sswf_BaseName;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2009-04-22
07:24:57 UTC (rev 14843)
@@ -31,6 +31,7 @@
swf_DeploymentDescription=The temporary deployment location is where files will \nbe
copied to before being renamed into the deploy directory. \nThis folder should be on the
same file system \nas the deploy folder.
swf_DeployDirectory=Deploy Directory
swf_TempDeployDirectory=Temporary Deploy Directory
+swf_CloneConfiguration=Copy this configuration into workspace metadata
sswf_Title=Create a new System Copy Server
sswf_BaseName=Local Deployer
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -61,8 +61,8 @@
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -397,10 +397,10 @@
if( newSelection == metadataRadio ) {
- newDir = IJBossServerConstants.PLUGIN_LOCATION.append(id.replace(' ',
'_')).
- append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
- newTemp = IJBossServerConstants.PLUGIN_LOCATION.append(id.replace(' ',
'_')).
- append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
+ newDir = JBossServerCorePlugin.getServerStateLocation(id)
+ .append(IJBossServerConstants.DEPLOY).makeAbsolute().toString();
+ newTemp = JBossServerCorePlugin.getServerStateLocation(id)
+ .append(IJBossServerConstants.TEMP_DEPLOY).makeAbsolute().toString();
type = IDeployableServer.DEPLOY_METADATA;
new File(newDir).mkdirs();
new File(newTemp).mkdirs();
@@ -486,14 +486,14 @@
}
private String makeGlobal(String path) {
- return DeployableServer.makeGlobal(getRuntime(), new Path(path)).toString();
+ return ServerUtil.makeGlobal(getRuntime(), new Path(path)).toString();
}
private String makeRelative(String path) {
if (getRuntime() == null) {
return path;
}
- return DeployableServer.makeRelative(getRuntime(), new Path(path)).toString();
+ return ServerUtil.makeRelative(getRuntime(), new Path(path)).toString();
}
private IJBossServerRuntime getRuntime() {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-04-22
05:56:32 UTC (rev 14842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-04-22
07:24:57 UTC (rev 14843)
@@ -30,11 +30,14 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
@@ -44,11 +47,14 @@
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -68,7 +74,8 @@
private Composite nameComposite;
private Group runtimeGroup;
private Text nameText;
-
+ private Button cloneButton;
+ private boolean shouldClone;
public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
@@ -224,6 +231,21 @@
configValLabel = new Label(runtimeGroup, SWT.NONE);
d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
configValLabel.setLayoutData(d);
+
+ cloneButton = new Button(runtimeGroup, SWT.CHECK);
+ cloneButton.setText(Messages.swf_CloneConfiguration);
+ d = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
+ d.horizontalSpan = 2;
+ cloneButton.setLayoutData(d);
+
+ cloneButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ shouldClone = cloneButton.getSelection();
+ }
+ });
}
private void updateErrorMessage() {
@@ -264,10 +286,17 @@
JBossServer jbs = (JBossServer)serverWC.loadAdapter(JBossServer.class, new
NullProgressMonitor());
jbs.setUsername("admin");
jbs.setPassword("admin");
+ ((ServerWorkingCopy)serverWC).setAttribute(IJBossServerConstants.USE_METADATA_CONFIG,
shouldClone);
jbs.setDeployLocationType(isAS5() ? IDeployableServer.DEPLOY_SERVER :
IDeployableServer.DEPLOY_METADATA);
serverWC.setRuntime((IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME));
serverWC.setName(name);
serverWC.setServerConfiguration(null); // no inside jboss folder
+
+ IServer saved = serverWC.save(false, new NullProgressMonitor());
+ getTaskModel().putObject(TaskModel.TASK_SERVER, saved);
+ ServerUtil.createStandardFolders(saved);
+ if( shouldClone)
+ ServerUtil.cloneConfigToMetadata(saved, monitor);
}
private IJBossServerRuntime getRuntime() {