Author: rob.stryker(a)jboss.com
Date: 2012-05-08 06:41:25 -0400 (Tue, 08 May 2012)
New Revision: 40845
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/util/ServerCreationUtils.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
tools should use public API where possible
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 2012-05-08
08:27:08 UTC (rev 40844)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2012-05-08
10:41:25 UTC (rev 40845)
@@ -71,6 +71,7 @@
setUsername("admin"); //$NON-NLS-1$
boolean defaultServerDeployment = isAS50() || isEAP(getServer());
setDeployLocationType(defaultServerDeployment ? IDeployableServer.DEPLOY_SERVER :
IDeployableServer.DEPLOY_METADATA);
+ setAttribute(IDeployableServer.SERVER_MODE, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
}
public static boolean isEAP(IServer server) {
Modified:
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 2012-05-08
08:27:08 UTC (rev 40844)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2012-05-08
10:41:25 UTC (rev 40845)
@@ -1,7 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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, Inc. - initial API and implementation
+ ******************************************************************************/
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;
@@ -22,24 +30,6 @@
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.AS_70,
IJBossToolingConstants.SERVER_AS_70);
- runtimeServerTypeMap.put(IJBossToolingConstants.AS_71,
IJBossToolingConstants.SERVER_AS_71);
- runtimeServerTypeMap.put(IJBossToolingConstants.EAP_43,
IJBossToolingConstants.SERVER_EAP_43);
- runtimeServerTypeMap.put(IJBossToolingConstants.EAP_50,
IJBossToolingConstants.SERVER_EAP_50);
- runtimeServerTypeMap.put(IJBossToolingConstants.EAP_60,
IJBossToolingConstants.SERVER_EAP_60);
- // NEW_SERVER_ADAPTER Add the server / runtime mapping here
- }
-
-
public static IServer createDeployOnlyServer(String deployLocation, String
tempDeployLocation,
String rtName, String serverName) throws CoreException {
IRuntimeType rt =
ServerCore.findRuntimeType(IJBossToolingConstants.DEPLOY_ONLY_RUNTIME);
@@ -56,10 +46,6 @@
return server;
}
- 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 serverTypeId) throws
CoreException {
return createServer2(currentRuntime, serverTypeId, serverTypeId);
}
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 2012-05-08
08:27:08 UTC (rev 40844)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-05-08
10:41:25 UTC (rev 40845)
@@ -130,7 +130,7 @@
public static IServer createMockJBoss7Server(String deployLocation, String
tempDeployLocation) throws CoreException {
IRuntime runtime = RuntimeUtils.createRuntime(IJBossToolingConstants.AS_70,
"/", "default");
- IServer s = ServerCreationUtils.createServer2(IJBossToolingConstants.SERVER_AS_70,
runtime);
+ IServer s = ServerCreationUtils.createServer2(runtime,
IJBossToolingConstants.SERVER_AS_70);
IServerWorkingCopy swc = s.createWorkingCopy();
swc.setServerConfiguration(null);
swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-05-08
08:27:08 UTC (rev 40844)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-05-08
10:41:25 UTC (rev 40845)
@@ -29,6 +29,7 @@
import org.eclipse.wst.server.core.IServerAttributes;
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.internal.Server;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
@@ -37,12 +38,12 @@
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftPasswordStorageKey;
import org.osgi.service.prefs.BackingStoreException;
import com.openshift.client.IApplication;
@@ -249,13 +250,24 @@
}
public static IServer createServer(IRuntime runtime, String serverID) throws
CoreException {
- return ServerCreationUtils.createServer2(runtime, serverID, serverID,
"openshift");
+ return createServer2(runtime, ServerCore.findServerType(serverID), serverID);
}
public static IServer createServer(IRuntime runtime, IServerType serverType, String
serverName) throws CoreException {
- return ServerCreationUtils.createServer2(runtime, serverType, serverName,
"openshift");
+ return createServer2(runtime, serverType, serverName);
}
+ public static IServer createServer2(IRuntime currentRuntime, IServerType serverType,
String serverName) throws CoreException {
+ IServerWorkingCopy serverWC = serverType.createServer(null, null,
+ new NullProgressMonitor());
+ serverWC.setRuntime(currentRuntime);
+ serverWC.setName(serverName);
+ serverWC.setServerConfiguration(null);
+ serverWC.setAttribute(IDeployableServer.SERVER_MODE,
ExpressBehaviourDelegate.OPENSHIFT_ID);
+ return serverWC.save(true, new NullProgressMonitor());
+ }
+
+
/**
* Returns true if the given server is an OpenShift one, false otherwise.
* @param server the server to check
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-05-08
08:27:08 UTC (rev 40844)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-05-08
10:41:25 UTC (rev 40845)
@@ -43,13 +43,14 @@
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.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBean;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
-import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
import org.jboss.tools.runtime.as.detector.IJBossRuntimePluginConstants;
import org.jboss.tools.runtime.as.detector.Messages;
import org.jboss.tools.runtime.as.detector.RuntimeAsActivator;
@@ -255,8 +256,18 @@
}
}
IServerType serverType = ServerCore.findServerType(JBOSS_AS_TYPE_ID[index]);
- ServerCreationUtils.createServer2(runtime, serverType, name,
LocalPublishMethod.LOCAL_PUBLISH_METHOD);
+ createServer2(runtime, serverType, name, LocalPublishMethod.LOCAL_PUBLISH_METHOD);
}
+
+ public static IServer createServer2(IRuntime currentRuntime, IServerType serverType,
String serverName, String mode) throws CoreException {
+ IServerWorkingCopy serverWC = serverType.createServer(null, null,
+ new NullProgressMonitor());
+ serverWC.setRuntime(currentRuntime);
+ serverWC.setName(serverName);
+ serverWC.setServerConfiguration(null);
+ serverWC.setAttribute(IDeployableServer.SERVER_MODE, mode);
+ return serverWC.save(true, new NullProgressMonitor());
+ }
/**
* Creates HSQL DB Driver