Author: rob.stryker(a)jboss.com
Date: 2010-12-20 05:13:37 -0500 (Mon, 20 Dec 2010)
New Revision: 27607
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateServerFromRSEJob.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.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.rse.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/META-INF/MANIFEST.MF
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
Log:
"JBIDE-7889 deltacloud integration stuff" support for deploy only server, or
hard-coded server details added
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -35,6 +35,8 @@
public static final String SERVER_EAP_43 = "org.jboss.ide.eclipse.as.eap.43";
//$NON-NLS-1$
public static final String SERVER_EAP_50 = "org.jboss.ide.eclipse.as.eap.50";
//$NON-NLS-1$
+ public static final String DEPLOY_ONLY_RUNTIME =
"org.jboss.ide.eclipse.as.runtime.stripped"; //$NON-NLS-1$
+ public static final String DEPLOY_ONLY_SERVER =
"org.jboss.ide.eclipse.as.systemCopyServer"; //$NON-NLS-1$
/* Version Strings */
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -0,0 +1,132 @@
+package org.jboss.ide.eclipse.as.core.util;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+
+public class ServerCreationUtils {
+
+ public static HashMap<String, String> runtimeServerTypeMap =
+ new HashMap<String, String>();
+ static {
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_32,
IJBossToolingConstants.SERVER_AS_32);
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_40,
IJBossToolingConstants.SERVER_AS_40);
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_42,
IJBossToolingConstants.SERVER_AS_42);
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_50,
IJBossToolingConstants.SERVER_AS_50);
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_51,
IJBossToolingConstants.SERVER_AS_51);
+ runtimeServerTypeMap.put(IJBossToolingConstants.AS_60,
IJBossToolingConstants.SERVER_AS_60);
+ runtimeServerTypeMap.put(IJBossToolingConstants.EAP_43,
IJBossToolingConstants.SERVER_EAP_43);
+ runtimeServerTypeMap.put(IJBossToolingConstants.EAP_50,
IJBossToolingConstants.SERVER_EAP_50);
+ }
+
+
+ public static IServer createDeployOnlyServer(String deployLocation, String
tempDeployLocation,
+ String rtName, String serverName) throws CoreException {
+ IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
//$NON-NLS-1$
+ IRuntimeWorkingCopy wc = rt.createRuntime(rtName, null);
+ IRuntime runtime = wc.save(true, null);
+ IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
//$NON-NLS-1$
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer(serverName, null, null);
+ swc.setServerConfiguration(null);
+ swc.setName(serverName);
+ swc.setRuntime(runtime);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+ public static IServer createServer(String runtimeID, String serverID,
+ String location, String configuration) throws CoreException {
+ IRuntime currentRuntime = createRuntime(runtimeID, location,configuration);
+ return createServer2(currentRuntime, serverID);
+ }
+ public static IServer createServer(String runtimeID, String serverID,
+ String location, String configuration, IVMInstall install) throws CoreException {
+ IRuntime currentRuntime = createRuntime(runtimeID, location,
+ configuration, install);
+ return createServer2(currentRuntime, serverID);
+ }
+
+ public static IServer createServer2(String name, IRuntime currentRuntime) throws
CoreException {
+ return createServer2(currentRuntime,
runtimeServerTypeMap.get(currentRuntime.getRuntimeType().getId()), name);
+ }
+
+ public static IServer createServer2(IRuntime currentRuntime, String serverID) throws
CoreException {
+ return createServer2(currentRuntime, serverID, serverID);
+ }
+
+ public static IServer createServer2(IRuntime currentRuntime, String serverID, String
serverName) throws CoreException {
+ IServerType serverType = ServerCore.findServerType(serverID);
+ IServerWorkingCopy serverWC = serverType.createServer(null, null,
+ new NullProgressMonitor());
+ serverWC.setRuntime(currentRuntime);
+ serverWC.setName(serverName);
+ serverWC.setServerConfiguration(null);
+ return serverWC.save(true, new NullProgressMonitor());
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config) throws CoreException {
+ return createRuntime(runtimeId, homeDir, config, getDefaultVMInstall());
+ }
+
+ public static IVMInstall getDefaultVMInstall() {
+ return JavaRuntime.getDefaultVMInstall();
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config, IVMInstall install) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
+ new NullProgressMonitor());
+ runtimeWC.setName(runtimeId);
+ runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, install.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, install
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
+
+ IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
+ return savedRuntime;
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config, IExecutionEnvironment environment) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
+ new NullProgressMonitor());
+ runtimeWC.setName(runtimeId);
+ runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_EXECUTION_ENVIRONMENT, environment.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
+
+ IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
+ return savedRuntime;
+ }
+
+}
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 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -129,5 +129,6 @@
return NLS.bind(Messages.serverCountName, base, i);
}
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/META-INF/MANIFEST.MF 2010-12-20
09:54:21 UTC (rev 27606)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/META-INF/MANIFEST.MF 2010-12-20
10:13:37 UTC (rev 27607)
@@ -12,6 +12,7 @@
org.eclipse.rse.services.files.ftp,
org.eclipse.rse.services.local,
org.eclipse.rse.services.ssh,
+ org.eclipse.rse.subsystems.shells.core,
org.jboss.ide.eclipse.as.core,
org.jboss.ide.eclipse.as.wtp.core,
org.eclipse.wst.server.core,
@@ -22,8 +23,7 @@
org.eclipse.jem.util,
org.jboss.ide.eclipse.archives.webtools,
org.eclipse.debug.core,
- org.eclipse.jdt.launching,
- org.eclipse.rse.subsystems.shells.core;bundle-version="3.1.100"
+ org.eclipse.jdt.launching
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.jboss.ide.eclipse.as.rse.core
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -13,12 +13,14 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerAttributes;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
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;
@@ -37,6 +39,7 @@
public static final String RSE_SERVER_HOME_DIR =
"org.jboss.ide.eclipse.as.rse.core.RSEServerHomeDir"; //$NON-NLS-1$
public static final String RSE_SERVER_HOST =
"org.jboss.ide.eclipse.as.rse.core.ServerHost"; //$NON-NLS-1$
public static final String RSE_SERVER_DEFAULT_HOST = "Local"; //$NON-NLS-1$
+ public static final String RSE_MODE = "rse";
public static String getRSEConnectionName(IServer server) {
return server.getAttribute(RSEUtils.RSE_SERVER_HOST, RSE_SERVER_DEFAULT_HOST);
@@ -116,4 +119,27 @@
}
}
+ public static IServer setServerToRSEMode(IServer server, IHost newHost) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(IDeployableServer.SERVER_MODE, RSE_MODE);
+ wc.setAttribute(RSE_SERVER_HOST, newHost.getAliasName());
+ wc.setAttribute("hostname", newHost.getHostName());
+ return wc.save(false, new NullProgressMonitor());
+ }
+
+ public static IServer setServerToRSEMode(IServer server, IHost newHost,
+ String jbossHome, String config) throws CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(IDeployableServer.SERVER_MODE, RSE_MODE);
+ wc.setAttribute(RSE_SERVER_CONFIG, config);
+ wc.setAttribute(RSE_SERVER_HOME_DIR, jbossHome);
+ wc.setAttribute(RSE_SERVER_HOST, newHost.getAliasName());
+ wc.setAttribute("hostname", newHost.getHostName());
+ wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
+ IDeployableServer.DEPLOY_SERVER);
+ return wc.save(false, new NullProgressMonitor());
+ }
+
+
+
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -46,6 +46,7 @@
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
import org.osgi.framework.Bundle;
@@ -101,18 +102,7 @@
}
public static IServer createMockDeployOnlyServer(String deployLocation, String
tempDeployLocation,
String rtName, String serverName) throws CoreException {
- IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
- IRuntimeWorkingCopy wc = rt.createRuntime(rtName, null);
- IRuntime runtime = wc.save(true, null);
- IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
- ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer(serverName, null, null);
- swc.setServerConfiguration(null);
- swc.setName(serverName);
- swc.setRuntime(runtime);
- swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
- swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
- IServer server = swc.save(true, null);
- return server;
+ return ServerCreationUtils.createDeployOnlyServer(deployLocation, tempDeployLocation,
rtName, serverName);
}
public static IServer createMockServerWithRuntime(String serverType, String name, String
config) {
@@ -146,71 +136,31 @@
public static IServer createServer(String runtimeID, String serverID,
String location, String configuration) throws CoreException {
- IRuntime currentRuntime = createRuntime(runtimeID, location,configuration);
- return createServer2(currentRuntime, serverID);
+ IRuntime currentRuntime = ServerCreationUtils.createRuntime(runtimeID,
location,configuration);
+ return ServerCreationUtils.createServer2(currentRuntime, serverID);
}
public static IServer createServer(String runtimeID, String serverID,
String location, String configuration, IVMInstall install) throws CoreException {
- IRuntime currentRuntime = createRuntime(runtimeID, location,
+ IRuntime currentRuntime = ServerCreationUtils.createRuntime(runtimeID, location,
configuration, install);
- return createServer2(currentRuntime, serverID);
+ return ServerCreationUtils.createServer2(currentRuntime, serverID);
}
-
- private static IServer createServer2(IRuntime currentRuntime, String serverID) throws
CoreException {
- IServerType serverType = ServerCore.findServerType(serverID);
- IServerWorkingCopy serverWC = serverType.createServer(null, null,
- new NullProgressMonitor());
- serverWC.setRuntime(currentRuntime);
- serverWC.setName(serverID);
- serverWC.setServerConfiguration(null);
- return serverWC.save(true, new NullProgressMonitor());
- }
-
public static IRuntime createRuntime(String runtimeId, String homeDir,
String config) throws CoreException {
- return createRuntime(runtimeId, homeDir, config, VM_INSTALL);
+ return ServerCreationUtils.createRuntime(runtimeId, homeDir, config, VM_INSTALL);
}
public static IRuntime createRuntime(String runtimeId, String homeDir,
String config, IVMInstall install) throws CoreException {
assertTrue("path \"" + homeDir + "\" does not exist", new
Path(homeDir).toFile().exists());
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
- assertEquals("expects only one runtime type", runtimeTypes.length, 1);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
- new NullProgressMonitor());
- runtimeWC.setName(runtimeId);
- runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_ID, install.getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_TYPE_ID, install
- .getVMInstallType().getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
-
- IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
- return savedRuntime;
+ return ServerCreationUtils.createRuntime(runtimeId, homeDir, config, install);
}
public static IRuntime createRuntime(String runtimeId, String homeDir,
String config, IExecutionEnvironment environment) throws CoreException {
assertTrue("path \"" + homeDir + "\" does not exist", new
Path(homeDir).toFile().exists());
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,runtimeId);
- assertEquals("expects only one runtime type", runtimeTypes.length, 1);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
- new NullProgressMonitor());
- runtimeWC.setName(runtimeId);
- runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_EXECUTION_ENVIRONMENT, environment.getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
-
- IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
- return savedRuntime;
+ return ServerCreationUtils.createRuntime(runtimeId, homeDir, config);
}
public static void deleteAllServers() throws CoreException {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/META-INF/MANIFEST.MF
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/META-INF/MANIFEST.MF 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/META-INF/MANIFEST.MF 2010-12-20
10:13:37 UTC (rev 27607)
@@ -13,4 +13,8 @@
org.eclipse.ui,
org.jboss.tools.deltacloud.core,
org.jboss.tools.deltacloud.ui,
- org.jboss.ide.eclipse.as.core
+ org.jboss.ide.eclipse.as.core,
+ org.eclipse.wst.server.core;bundle-version="1.1.302",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.jboss.ide.eclipse.as.rse.core;bundle-version="0.9.0",
+ org.eclipse.wst.server.ui;bundle-version="1.1.305"
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.integration.wizard;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.core.job.AbstractInstanceJob;
+import org.jboss.tools.deltacloud.integration.Messages;
+import org.jboss.tools.deltacloud.integration.rse.util.RSEUtils;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
+import org.osgi.service.prefs.Preferences;
+
+public class CreateRSEFromInstanceJob extends AbstractInstanceJob {
+ private Job nextJob2 = null;
+ public CreateRSEFromInstanceJob(DeltaCloudInstance instance, String family) {
+ super("Create RSE Host from DeltaCloud Instance", instance, family);
+ }
+ public IStatus doRun(IProgressMonitor monitor) {
+ return runRSEJob(getInstance(), monitor);
+ }
+
+ public void setNextJob(Job job) {
+ super.setNextJob(job);
+ this.nextJob2 = job;
+ }
+
+ private IStatus runRSEJob(DeltaCloudInstance instance, IProgressMonitor monitor) {
+ String hostname = RSEUtils.createHostName(instance);
+ if (hostname != null && hostname.length() > 0 && isAutoconnect()) {
+ try {
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName,
+ RSEUtils.createHostName(instance),
+ RSEUtils.getSSHOnlySystemType(),
+ RSEUtils.getSystemRegistry());
+ if( nextJob2 != null && nextJob2 instanceof CreateServerFromRSEJob) {
+ ((CreateServerFromRSEJob)nextJob2).setHost(host);
+ }
+ RSEUtils.connect(connectionName, RSEUtils.getConnectorService(host));
+ } catch (Exception e) {
+ return ErrorUtils.handleError(Messages.ERROR,
+ NLS.bind(Messages.COULD_NOT_LAUNCH_RSE_EXPLORER2, instance.getName()),
+ e, Display.getDefault().getActiveShell());
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ private boolean isAutoconnect() {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ boolean autoConnect =
prefs.getBoolean(IDeltaCloudPreferenceConstants.AUTO_CONNECT_INSTANCE, true);
+ return autoConnect;
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateServerFromRSEJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateServerFromRSEJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateServerFromRSEJob.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.integration.wizard;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
+import org.jboss.ide.eclipse.as.rse.core.RSEUtils;
+import org.jboss.tools.common.jobs.ChainedJob;
+
+public class CreateServerFromRSEJob extends ChainedJob {
+ public static final String CREATE_DEPLOY_ONLY_SERVER =
"CREATE_DEPLOY_ONLY_SERVER";
+ public static final String CHECK_SERVER_FOR_DETAILS =
"CHECK_SERVER_FOR_DETAILS";
+ public static final String SET_DETAILS_NOW = "SET_DETAILS_NOW";
+
+ private String type;
+ private String name;
+ private String[] data;
+ private IHost host;
+ public CreateServerFromRSEJob(String type, String[] data, String name) {
+ super("Create Server From RSE Host");
+ this.data = data;
+ this.type = type;
+ this.name = name;
+ }
+
+ public void setHost(IHost host) {
+ this.host = host;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ IServer result = null;
+ if( type.equals(CREATE_DEPLOY_ONLY_SERVER) ) {
+ result = createDeployOnlyServer();
+ } else if( type.equals(CHECK_SERVER_FOR_DETAILS )) {
+ result = createServerCheckRemoteDetails();
+ } else if( type.equals(SET_DETAILS_NOW)) {
+ result = createServerSetDetailsNow();
+ }
+ } catch(CoreException ce) {
+ return ce.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ protected IServer createDeployOnlyServer() throws CoreException {
+ IServer server = createDeployOnlyServerWithRuntime(data[0], data[0], name);
+ server = RSEUtils.setServerToRSEMode(server, host);
+ return server;
+ }
+ protected IServer createServerCheckRemoteDetails() {
+ return null;
+ }
+ protected IServer createServerSetDetailsNow() throws CoreException {
+ String home = data[0];
+ String config = data[1];
+ String rtId = data[2];
+ IRuntime runtime = ServerCore.findRuntime(rtId);
+ IServer newServer = ServerCreationUtils.createServer2(name, runtime);
+ newServer = RSEUtils.setServerToRSEMode(newServer, host, home, config);
+ return newServer;
+ }
+
+ private static IRuntime findOrCreateStubDeployOnlyRuntime() throws CoreException {
+ IRuntime[] rts = ServerCore.getRuntimes();
+ for( int i = 0; i < rts.length; i++ ) {
+ if(
rts[i].getRuntimeType().getId().equals("org.jboss.ide.eclipse.as.runtime.stripped"))
{
+ return rts[i];
+ }
+ }
+ IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
+ IRuntimeWorkingCopy wc = rt.createRuntime("Deploy Only Runtime", null);
+ IRuntime runtime = wc.save(true, null);
+ return runtime;
+ }
+
+ private static IServer createDeployOnlyServerWithRuntime(String deployLocation, String
tempDeployLocation,
+ String serverName) throws CoreException {
+ IRuntime rt = findOrCreateStubDeployOnlyRuntime();
+ IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer(serverName, null, null);
+ swc.setServerConfiguration(null);
+ swc.setName(serverName);
+ swc.setRuntime(rt);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2010-12-20
09:54:21 UTC (rev 27606)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2010-12-20
10:13:37 UTC (rev 27607)
@@ -10,41 +10,45 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.integration.wizard;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import java.util.ArrayList;
+
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.rse.core.model.IHost;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.ui.ServerUIUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.job.AbstractInstanceJob;
import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
-import org.jboss.tools.deltacloud.integration.Messages;
-import org.jboss.tools.deltacloud.integration.rse.util.RSEUtils;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.INewInstanceWizardPage;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
/**
* @author Rob Stryker
*/
public class RSEandASWizardPage extends WizardPage implements INewInstanceWizardPage {
- private Button createRSE;
- private Button createServer;
+ private Button createRSE, createServer;
+ private Group serverDetailsGroup;
+ private Button autoScanCheck, hardCodeServerDetails, deployOnlyRadio,
addLocalRuntimeButton;
+ private Text remoteDetailsLoc, serverHomeText, serverConfigText, deployFolderText;
+ private Label serverHome, serverConfig, localRuntimeLabel, deployFolder;
+ private Combo localRuntimeCombo;
+
private final static String CREATE_RSE_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_RSE_PREF_KEY";
private final static String CREATE_SERVER_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_SERVER_PREF_KEY";
@@ -64,6 +68,72 @@
createServer.setText("Create Server Adapter");
createServer.setLayoutData(UIUtils.createFormData(createRSE, 5, null, 0, 0, 5, 100,
-5));
+ Group g = new Group(c2, SWT.SHADOW_IN);
+ serverDetailsGroup = g;
+ g.setLayout(new FormLayout());
+ g.setLayoutData(UIUtils.createFormData(createServer,5,null,0,0,5,100,-5));
+ g.setText("Server Details");
+
+ final int INDENTATION = 40;
+
+ autoScanCheck = new Button(g, SWT.RADIO);
+ autoScanCheck.setText("Determine server details from this remote file:");
+ autoScanCheck.setLayoutData(UIUtils.createFormData(0,5,null,0,0,5,null,0));
+
+ remoteDetailsLoc = new Text(g, SWT.BORDER);
+ remoteDetailsLoc.setLayoutData(UIUtils.createFormData(autoScanCheck,5,null,0,0,INDENTATION,100,-5));
+ remoteDetailsLoc.setText("/etc/sysconfig/jboss-eap");
+
+
+ hardCodeServerDetails = new Button(g, SWT.RADIO);
+ hardCodeServerDetails.setText("Set remote server details manually");
+ hardCodeServerDetails.setLayoutData(UIUtils.createFormData(remoteDetailsLoc,5,null,0,0,5,null,0));
+
+ serverHome = new Label(g, SWT.NONE);
+ serverHome.setText("JBoss Server Home: ");
+ serverHome.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ serverHomeText = new Text(g, SWT.BORDER);
+ serverHomeText.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 5, null, 0,
serverHome, 5, 100, -5));
+ serverHomeText.setText("/etc/jboss/jboss-as");
+
+ serverConfig = new Label(g, SWT.NONE);
+ serverConfig.setText("Configuration: ");
+ serverConfig.setLayoutData(UIUtils.createFormData(serverHomeText, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ serverConfigText = new Text(g, SWT.BORDER);
+ serverConfigText.setLayoutData(UIUtils.createFormData(serverHomeText, 5, null, 0,
serverHome, 5, 100, -5));
+ serverConfigText.setText("default");
+
+ localRuntimeLabel = new Label(g, SWT.NONE);
+ localRuntimeLabel.setText("Local Runtime: ");
+ localRuntimeLabel.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null, 0, 0,
INDENTATION, null, 0 ));
+
+ addLocalRuntimeButton = new Button(g, SWT.DEFAULT);
+ addLocalRuntimeButton.setText("Configure Runtimes...");
+ addLocalRuntimeButton.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null,
0, null, 0, 100, -5));
+ addLocalRuntimeButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ configureRuntimesPressed();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ localRuntimeCombo = new Combo(g, SWT.NONE);
+ localRuntimeCombo.setLayoutData(UIUtils.createFormData(serverConfigText, 5, null, 0,
serverHome, 5, addLocalRuntimeButton, -5));
+
+
+ deployOnlyRadio = new Button(g, SWT.RADIO);
+ deployOnlyRadio.setText("Use a deploy-only server adapter");
+ deployOnlyRadio.setLayoutData(UIUtils.createFormData(localRuntimeCombo,5,null,0,0,5,null,0));
+
+ deployFolder = new Label(g, SWT.NONE);
+ deployFolder.setText("Deploy Folder: ");
+ deployFolder.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 7, null, 0, 0,
INDENTATION, null, 0 ));
+ deployFolderText = new Text(g, SWT.BORDER);
+ deployFolderText.setText("/path/to/deploy");
+ deployFolderText.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 5, null, 0,
deployFolder, 5, 100, -5));
+ deployOnlyRadio.setSelection(true);
+
+
IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
boolean initRSE, initServer;
initRSE = prefs.getBoolean(CREATE_RSE_PREF_KEY, true);
@@ -80,25 +150,67 @@
handleSelection(e.widget);
}
};
-
+
+ fillRuntimeTypeCombo();
+ refreshServerWidgets();
createRSE.addSelectionListener(listener);
createServer.addSelectionListener(listener);
setControl(c2);
}
+ private ArrayList<IRuntime> localRuntimes = new ArrayList<IRuntime>();
+ private void fillRuntimeTypeCombo() {
+ localRuntimes.clear();
+ IRuntime[] rts = ServerCore.getRuntimes();
+ ArrayList<String> names = new ArrayList<String>();
+ for( int i = 0; i < rts.length; i++ ) {
+ if( rts[i].getRuntimeType().getId().startsWith("org.jboss.")
+ &&
!rts[i].getRuntimeType().getId().equals(IJBossToolingConstants.DEPLOY_ONLY_RUNTIME)) {
+ localRuntimes.add(rts[i]);
+ names.add(rts[i].getName());
+ }
+ }
+ localRuntimeCombo.setItems((String[]) names.toArray(new String[names.size()]));
+ }
+
+ protected void configureRuntimesPressed() {
+ ServerUIUtil.showNewRuntimeWizard(addLocalRuntimeButton.getShell(), null, null);
+ fillRuntimeTypeCombo();
+ }
+
private void handleSelection(Widget w) {
if (w == createRSE) {
if (!createRSE.getSelection()) {
createServer.setEnabled(false);
createServer.setSelection(false);
+ refreshServerWidgets();
} else {
createServer.setEnabled(true);
}
}
+ if( w == createServer ) {
+ refreshServerWidgets();
+ }
}
+ private void refreshServerWidgets() {
+ boolean enabled = createServer.getSelection();
+ boolean enabled2 = false;
+ serverDetailsGroup.setEnabled(enabled);
+ autoScanCheck.setEnabled(enabled2);
+ remoteDetailsLoc.setEnabled(enabled2);
+ hardCodeServerDetails.setEnabled(enabled);
+ serverHomeText.setEnabled(enabled);
+ serverConfigText.setEnabled(enabled);
+ serverHome.setEnabled(enabled);
+ serverConfig.setEnabled(enabled);
+ deployFolder.setEnabled(enabled);
+ deployFolderText.setEnabled(enabled);
+ deployOnlyRadio.setEnabled(enabled);
+ System.out.println(deployFolderText.getEditable());
+ }
+
public AbstractInstanceJob getPerformFinishJob(final DeltaCloudInstance instance) {
- System.out.println(instance.getHostName());
IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
prefs.putBoolean(CREATE_RSE_PREF_KEY, createRSE.getSelection());
prefs.putBoolean(CREATE_SERVER_PREF_KEY, createServer.getSelection());
@@ -108,38 +220,30 @@
// ignore
}
- AbstractInstanceJob j = new AbstractInstanceJob(
- "Register RSE Connection", instance,
INewInstanceWizardPage.NEW_INSTANCE_FAMILY) {
- public IStatus doRun(IProgressMonitor monitor) {
- return runJob(instance, monitor);
- }
- };
- return j;
- }
+ CreateRSEFromInstanceJob j =
+ new CreateRSEFromInstanceJob(instance, INewInstanceWizardPage.NEW_INSTANCE_FAMILY);
- private IStatus runJob(DeltaCloudInstance instance, IProgressMonitor monitor) {
- String hostname = RSEUtils.createHostName(instance);
- if (hostname != null && hostname.length() > 0 && isAutoconnect()) {
- try {
- String connectionName = RSEUtils.createConnectionName(instance);
- IHost host = RSEUtils.createHost(connectionName,
- RSEUtils.createHostName(instance),
- RSEUtils.getSSHOnlySystemType(),
- RSEUtils.getSystemRegistry());
- RSEUtils.connect(connectionName, RSEUtils.getConnectorService(host));
- } catch (Exception e) {
- return ErrorUtils.handleError(Messages.ERROR,
- NLS.bind(Messages.COULD_NOT_LAUNCH_RSE_EXPLORER2, instance.getName()),
- e, getShell());
+ if( createServer.getSelection()) {
+ String[] data = null;
+ String type = null;
+ if( deployOnlyRadio.getSelection()) {
+ type = CreateServerFromRSEJob.CREATE_DEPLOY_ONLY_SERVER;
+ data = new String[]{deployFolderText.getText()};
+ } else if( autoScanCheck.getSelection()) {
+ type = CreateServerFromRSEJob.CHECK_SERVER_FOR_DETAILS;
+ data = new String[]{remoteDetailsLoc.getText()};
+ } else if( hardCodeServerDetails.getSelection()) {
+ type = CreateServerFromRSEJob.SET_DETAILS_NOW;
+ int index = localRuntimeCombo.getSelectionIndex();
+ String rtId = localRuntimes.get(index).getId();
+ data = new String[]{serverHomeText.getText(), serverConfigText.getText(), rtId};
}
+ if( type != null && data != null ) {
+ CreateServerFromRSEJob job2 = new CreateServerFromRSEJob(type, data,
instance.getImageId());
+ j.setNextJob(job2);
+ }
}
- return Status.OK_STATUS;
+ return j;
}
-
- private boolean isAutoconnect() {
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- boolean autoConnect =
prefs.getBoolean(IDeltaCloudPreferenceConstants.AUTO_CONNECT_INSTANCE, true);
- return autoConnect;
- }
-
+
}