diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentRuntimeProviderBase.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentRuntimeProviderBase.java
new file mode 100644
index 000000000000..2773672f3ffa
--- /dev/null
+++ b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentRuntimeProviderBase.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.impl.util;
+
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
+import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
+import com.intellij.remoteServer.util.*;
+
+import java.io.File;
+
+/**
+ * @author michael.golubev
+ */
+public abstract class ArtifactDeploymentRuntimeProviderBase implements CloudDeploymentRuntimeProvider {
+
+ @Override
+ public CloudDeploymentRuntime createDeploymentRuntime(DeploymentSource source,
+ CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentTask extends CloudDeploymentNameConfiguration> deploymentTask,
+ DeploymentLogManager logManager)
+ throws ServerRuntimeException {
+ if (!(source instanceof ArtifactDeploymentSource)) {
+ return null;
+ }
+
+ ArtifactDeploymentSource artifactSource = (ArtifactDeploymentSource)source;
+ Artifact artifact = artifactSource.getArtifact();
+ if (artifact == null) {
+ throw new ServerRuntimeException("Artifact not found " + artifactSource.getArtifactPointer().getArtifactName());
+ }
+
+ String artifactPath = artifact.getOutputFilePath();
+ if (artifactPath == null) {
+ throw new ServerRuntimeException("Artifact output not found");
+ }
+
+ return doCreateDeploymentRuntime(artifactSource, new File(artifactPath), serverRuntime, deploymentTask, logManager);
+ }
+
+ protected abstract CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
+ File artifactFile,
+ CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentTask extends CloudDeploymentNameConfiguration> deploymentTask,
+ DeploymentLogManager logManager) throws ServerRuntimeException;
+}
diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java
deleted file mode 100644
index 8f05a8289236..000000000000
--- a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.remoteServer.impl.util;
-
-import com.intellij.packaging.artifacts.Artifact;
-import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
-import com.intellij.remoteServer.util.DeploymentSourceHandler;
-import com.intellij.remoteServer.util.ServerRuntimeException;
-
-import java.io.File;
-
-/**
- * @author michael.golubev
- */
-public abstract class ArtifactDeploymentSourceHandlerBase implements DeploymentSourceHandler {
-
- private final File myArtifactFile;
-
- public ArtifactDeploymentSourceHandlerBase(ArtifactDeploymentSource deploymentSource) throws ServerRuntimeException {
- Artifact artifact = deploymentSource.getArtifact();
- if (artifact == null) {
- throw new ServerRuntimeException("Artifact not found " + deploymentSource.getArtifactPointer().getArtifactName());
- }
-
- String artifactPath = artifact.getOutputFilePath();
- if (artifactPath == null) {
- throw new ServerRuntimeException("Artifact output not found");
- }
- myArtifactFile = new File(artifactPath);
- }
-
- protected File getArtifactFile() {
- return myArtifactFile;
- }
-}
diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentRuntimeProviderBase.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentRuntimeProviderBase.java
new file mode 100644
index 000000000000..2a276d613ab1
--- /dev/null
+++ b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentRuntimeProviderBase.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.impl.util;
+
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
+import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
+import com.intellij.remoteServer.util.CloudMultiSourceServerRuntimeInstance;
+import com.intellij.remoteServer.util.CloudDeploymentNameConfiguration;
+import com.intellij.remoteServer.util.CloudDeploymentRuntime;
+import com.intellij.remoteServer.util.ServerRuntimeException;
+
+import java.io.File;
+
+/**
+ * @author michael.golubev
+ */
+public abstract class RepositoryArtifactDeploymentRuntimeProviderBase extends ArtifactDeploymentRuntimeProviderBase {
+
+ @Override
+ protected CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
+ File artifactFile,
+ CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentTask extends CloudDeploymentNameConfiguration> deploymentTask,
+ DeploymentLogManager logManager) throws ServerRuntimeException {
+ RepositoryDeploymentConfiguration config = (RepositoryDeploymentConfiguration)deploymentTask.getConfiguration();
+
+ String repositoryPath = config.getRepositoryPath();
+ File repositoryRootFile;
+ if (StringUtil.isEmpty(repositoryPath)) {
+ File repositoryParentFolder = new File(PathManager.getSystemPath(), "cloud-git-artifact-deploy");
+ repositoryRootFile = FileUtil.findSequentNonexistentFile(repositoryParentFolder, artifactFile.getName(), "");
+ }
+ else {
+ repositoryRootFile = new File(repositoryPath);
+ }
+
+ if (!FileUtil.createDirectory(repositoryRootFile)) {
+ throw new ServerRuntimeException("Unable to create deploy folder: " + repositoryRootFile);
+ }
+ config.setRepositoryPath(repositoryRootFile.getAbsolutePath());
+ return doCreateDeploymentRuntime(artifactSource, artifactFile, serverRuntime, deploymentTask, logManager, repositoryRootFile);
+ }
+
+ protected abstract CloudDeploymentRuntime doCreateDeploymentRuntime(ArtifactDeploymentSource artifactSource,
+ File artifactFile,
+ CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentTask extends CloudDeploymentNameConfiguration> deploymentTask,
+ DeploymentLogManager logManager,
+ File repositoryRootFile) throws ServerRuntimeException;
+}
diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentSourceHandlerBase.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentSourceHandlerBase.java
deleted file mode 100644
index e85e72e37628..000000000000
--- a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/RepositoryArtifactDeploymentSourceHandlerBase.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.remoteServer.impl.util;
-
-import com.intellij.openapi.application.PathManager;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
-import com.intellij.remoteServer.util.ServerRuntimeException;
-
-import java.io.File;
-
-/**
- * @author michael.golubev
- */
-public abstract class RepositoryArtifactDeploymentSourceHandlerBase extends ArtifactDeploymentSourceHandlerBase {
-
- private final File myRepositoryRootFile;
-
- public RepositoryArtifactDeploymentSourceHandlerBase(ArtifactDeploymentSource deploymentSource, RepositoryDeploymentConfiguration config)
- throws ServerRuntimeException {
- super(deploymentSource);
- String repositoryPath = config.getRepositoryPath();
- if (StringUtil.isEmpty(repositoryPath)) {
- File repositoryParentFolder = new File(PathManager.getSystemPath(), "cloud-git-artifact-deploy");
- myRepositoryRootFile = FileUtil.findSequentNonexistentFile(repositoryParentFolder, getArtifactFile().getName(), "");
- }
- else {
- myRepositoryRootFile = new File(repositoryPath);
- }
-
- if (!FileUtil.createDirectory(myRepositoryRootFile)) {
- throw new ServerRuntimeException("Unable to create deploy folder: " + myRepositoryRootFile);
- }
- config.setRepositoryPath(myRepositoryRootFile.getAbsolutePath());
- }
-
- @Override
- public File getRepositoryRootFile() {
- return myRepositoryRootFile;
- }
-}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudApplication.java
similarity index 70%
rename from platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java
rename to platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudApplication.java
index 64a8599eacd6..7e5576531c00 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudApplication.java
@@ -13,18 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.remoteServer.util;
-
-import com.intellij.remoteServer.agent.util.CloudGitApplication;
-
-import java.io.File;
+package com.intellij.remoteServer.agent.util;
/**
* @author michael.golubev
*/
-public interface DeploymentSourceHandler {
+public interface CloudApplication {
- File getRepositoryRootFile();
+ String getName();
- CloudGitApplication deploy() throws ServerRuntimeException;
+ String getWebUrl();
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
index 9e8513d8c299..a258bc649ec8 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
@@ -18,11 +18,7 @@ package com.intellij.remoteServer.agent.util;
/**
* @author michael.golubev
*/
-public interface CloudGitApplication {
-
- String getName();
+public interface CloudGitApplication extends CloudApplication {
String getGitUrl();
-
- String getWebUrl();
}
diff --git a/plugins/git4idea/remote-servers-git/resources/resources/cloud.properties b/platform/remote-servers/impl/resources/resources/cloud.properties
similarity index 100%
rename from plugins/git4idea/remote-servers-git/resources/resources/cloud.properties
rename to platform/remote-servers/impl/resources/resources/cloud.properties
diff --git a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml
index cabac1dba935..c18f18d43304 100644
--- a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml
+++ b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml
@@ -3,6 +3,9 @@
+
+
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudBundle.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java
similarity index 100%
rename from plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudBundle.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudBundle.java
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentConfiguratorBase.java
similarity index 65%
rename from plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentConfiguratorBase.java
index 40b7a23c2d67..19b1895bdccc 100644
--- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentConfiguratorBase.java
@@ -15,20 +15,20 @@ import java.util.List;
/**
* @author michael.golubev
*/
-public abstract class CloudGitDeploymentConfiguratorBase
+public abstract class CloudDeploymentConfiguratorBase
extends DeploymentConfigurator {
private final Project myProject;
private ServerType myServerType;
- public CloudGitDeploymentConfiguratorBase(Project project, ServerType serverType) {
+ public CloudDeploymentConfiguratorBase(Project project, ServerType serverType) {
myProject = project;
myServerType = serverType;
}
- public static List getDeploymentSourceHandlerProviders(ServerType> serverType) {
- List result = new ArrayList();
- for (CloudGitDeploymentSourceHandlerProvider provider : CloudGitDeploymentSourceHandlerProvider.EP_NAME.getExtensions()) {
+ public static List getDeploymentRuntimeProviders(ServerType> serverType) {
+ List result = new ArrayList();
+ for (CloudDeploymentRuntimeProvider provider : CloudDeploymentRuntimeProvider.EP_NAME.getExtensions()) {
ServerType> providerServerType = provider.getServerType();
if (providerServerType == null || providerServerType == serverType) {
result.add(provider);
@@ -42,7 +42,7 @@ public abstract class CloudGitDeploymentConfiguratorBase getAvailableDeploymentSources() {
if (myProject.isDefault()) return Collections.emptyList();
List result = new ArrayList();
- for (CloudGitDeploymentSourceHandlerProvider provider : getDeploymentSourceHandlerProviders(myServerType)) {
+ for (CloudDeploymentRuntimeProvider provider : getDeploymentRuntimeProviders(myServerType)) {
result.addAll(provider.getDeploymentSources(myProject));
}
return result;
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntime.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntime.java
new file mode 100644
index 000000000000..b7bafe27e4fb
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntime.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.util;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.Ref;
+import com.intellij.remoteServer.agent.util.CloudApplication;
+import com.intellij.remoteServer.agent.util.CloudGitAgentDeployment;
+import com.intellij.remoteServer.agent.util.CloudLoggingHandler;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+import com.intellij.remoteServer.runtime.ServerTaskExecutor;
+import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
+import com.intellij.remoteServer.runtime.deployment.DeploymentRuntime;
+import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
+import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
+import com.intellij.remoteServer.runtime.log.LoggingHandler;
+import com.intellij.util.ThrowableRunnable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author michael.golubev
+ */
+public abstract class CloudDeploymentRuntime extends DeploymentRuntime {
+
+ private final CloudGitAgentDeployment myDeployment;
+ private final String myApplicationName;
+ private final CloudConfigurationBase myConfiguration;
+ private final AgentTaskExecutor myAgentTaskExecutor;
+ private final String myPresentableName;
+ private final ServerTaskExecutor myTaskExecutor;
+ private final CloudLoggingHandler myLoggingHandler;
+ @Nullable private final DeploymentLogManager myLogManager;
+ private final Project myProject;
+
+ public CloudDeploymentRuntime(CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentSource source,
+ DeploymentTask extends CloudDeploymentNameConfiguration> task,
+ @Nullable DeploymentLogManager logManager) throws ServerRuntimeException {
+ myConfiguration = serverRuntime.getConfiguration();
+
+ myTaskExecutor = serverRuntime.getTaskExecutor();
+ myAgentTaskExecutor = serverRuntime.getAgentTaskExecutor();
+
+ myLogManager = logManager;
+ myLoggingHandler = logManager == null ? new CloudSilentLoggingHandlerImpl() : new CloudLoggingHandlerImpl(logManager);
+
+ CloudDeploymentNameConfiguration deploymentConfiguration = task.getConfiguration();
+ myApplicationName = deploymentConfiguration.isDefaultDeploymentName()
+ ? serverRuntime.getDeploymentName(source)
+ : deploymentConfiguration.getDeploymentName();
+
+ myPresentableName = source.getPresentableName();
+
+ myDeployment = serverRuntime.getAgent().createDeployment(myApplicationName, myLoggingHandler);
+
+ myProject = task.getProject();
+ }
+
+ public void deploy(ServerRuntimeInstance.DeploymentOperationCallback callback) {
+ try {
+ CloudApplication application = deploy();
+
+ if (myLogManager != null) {
+ LoggingHandler loggingHandler = myLogManager.getMainLoggingHandler();
+ loggingHandler.print("Application is available at ");
+ loggingHandler.printHyperlink(application.getWebUrl());
+ loggingHandler.print("\n");
+ }
+
+ callback.succeeded(this);
+ }
+ catch (ServerRuntimeException e) {
+ callback.errorOccurred(e.getMessage());
+ }
+ }
+
+ @Override
+ public void undeploy(final @NotNull UndeploymentTaskCallback callback) {
+ myTaskExecutor.submit(new ThrowableRunnable() {
+
+ @Override
+ public void run() throws Exception {
+ try {
+ if (!confirmUndeploy()) {
+ throw new ServerRuntimeException("Undeploy cancelled");
+ }
+
+ undeploy();
+
+ callback.succeeded();
+ }
+ catch (ServerRuntimeException e) {
+ callback.errorOccurred(e.getMessage());
+ }
+ }
+ }, callback);
+ }
+
+ public CloudGitAgentDeployment getDeployment() {
+ return myDeployment;
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+
+ public String getApplicationName() {
+ return myApplicationName;
+ }
+
+ public AgentTaskExecutor getAgentTaskExecutor() {
+ return myAgentTaskExecutor;
+ }
+
+ public CloudLoggingHandler getLoggingHandler() {
+ return myLoggingHandler;
+ }
+
+ public boolean confirmUndeploy() {
+ final Ref confirmed = new Ref(false);
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ String title = CloudBundle.getText("cloud.undeploy.confirm.title");
+ while (true) {
+ String password = Messages.showPasswordDialog(CloudBundle.getText("cloud.undeploy.confirm.message", myPresentableName), title);
+ if (password == null) {
+ return;
+ }
+ if (password.equals(myConfiguration.getPassword())) {
+ confirmed.set(true);
+ return;
+ }
+ Messages.showErrorDialog(CloudBundle.getText("cloud.undeploy.confirm.password.incorrect"), title);
+ }
+ }
+ }, ModalityState.defaultModalityState());
+ return confirmed.get();
+ }
+
+ public abstract CloudApplication deploy() throws ServerRuntimeException;
+
+ public abstract void undeploy() throws ServerRuntimeException;
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntimeProvider.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntimeProvider.java
new file mode 100644
index 000000000000..e8aafc739c14
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentRuntimeProvider.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.util;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
+import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
+
+import java.util.Collection;
+
+/**
+ * @author michael.golubev
+ */
+public interface CloudDeploymentRuntimeProvider {
+
+ ExtensionPointName EP_NAME
+ = ExtensionPointName.create("com.intellij.remoteServer.util.CloudDeploymentRuntimeProvider");
+
+ ServerType> getServerType();
+
+ Collection getDeploymentSources(Project project);
+
+ CloudDeploymentRuntime createDeploymentRuntime(DeploymentSource source,
+ CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentTask extends CloudDeploymentNameConfiguration> deploymentTask,
+ DeploymentLogManager logManager)
+ throws ServerRuntimeException;
+}
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java
similarity index 69%
rename from plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java
index 8423be814119..e241bf89897f 100644
--- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java
@@ -3,6 +3,7 @@ package com.intellij.remoteServer.util;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
+import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.agent.RemoteAgentManager;
import com.intellij.remoteServer.agent.util.CloudAgentConfigBase;
import com.intellij.remoteServer.agent.util.CloudAgentLogger;
@@ -25,32 +26,32 @@ import java.util.List;
/**
* @author michael.golubev
*/
-
-public abstract class CloudGitServerRuntimeInstanceBase<
+public abstract class CloudMultiSourceServerRuntimeInstance<
DC extends CloudDeploymentNameConfiguration,
AC extends CloudAgentConfigBase,
A extends CloudGitAgent,
- SC extends AC,
- DR extends CloudGitDeploymentRuntime>
- extends CloudServerRuntimeInstance
- implements CloudDeploymentNameProvider {
+ SC extends AC>
+ extends CloudServerRuntimeInstance {
- private static final Logger LOG = Logger.getInstance("#" + CloudGitServerRuntimeInstanceBase.class.getName());
+ private static final Logger LOG = Logger.getInstance("#" + CloudMultiSourceServerRuntimeInstance.class.getName());
private final A myAgent;
private final AgentTaskExecutor myAgentTaskExecutor;
+ private final ServerType> myServerType;
private final SC myConfiguration;
private final ServerTaskExecutor myTasksExecutor;
- public CloudGitServerRuntimeInstanceBase(SC configuration,
- ServerTaskExecutor tasksExecutor,
- List libraries,
- List> commonJarClasses,
- String specificsModuleName,
- String specificJarPath,
- Class agentInterface,
- String agentClassName) throws Exception {
+ public CloudMultiSourceServerRuntimeInstance(ServerType> serverType,
+ SC configuration,
+ ServerTaskExecutor tasksExecutor,
+ List libraries,
+ List> commonJarClasses,
+ String specificsModuleName,
+ String specificJarPath,
+ Class agentInterface,
+ String agentClassName) throws Exception {
+ myServerType = serverType;
myConfiguration = configuration;
myTasksExecutor = tasksExecutor;
@@ -96,7 +97,7 @@ public abstract class CloudGitServerRuntimeInstanceBase<
@Override
public void onSuccess(Object result) {
- callback.connected(CloudGitServerRuntimeInstanceBase.this);
+ callback.connected(CloudMultiSourceServerRuntimeInstance.this);
}
@Override
@@ -115,7 +116,7 @@ public abstract class CloudGitServerRuntimeInstanceBase<
@Override
public void run() throws Exception {
- createDeploymentRuntime(myConfiguration, myTasksExecutor, task, logManager).deploy(callback);
+ createDeploymentRuntime(task, logManager).deploy(callback);
}
}, callback);
}
@@ -176,43 +177,50 @@ public abstract class CloudGitServerRuntimeInstanceBase<
return myAgentTaskExecutor;
}
- public DR createDeploymentRuntime(final DeployToServerRunConfiguration, DC> runConfiguration)
+ public CloudDeploymentRuntime createDeploymentRuntime(final DeployToServerRunConfiguration, DC> runConfiguration)
throws ServerRuntimeException {
- return createDeploymentRuntime(myConfiguration,
- myTasksExecutor,
- new DeploymentTask() {
+ return createDeploymentRuntime(new DeploymentTask() {
- @NotNull
- @Override
- public DeploymentSource getSource() {
- return runConfiguration.getDeploymentSource();
- }
+ @NotNull
+ @Override
+ public DeploymentSource getSource() {
+ return runConfiguration.getDeploymentSource();
+ }
- @NotNull
- @Override
- public DC getConfiguration() {
- return runConfiguration.getDeploymentConfiguration();
- }
+ @NotNull
+ @Override
+ public DC getConfiguration() {
+ return runConfiguration.getDeploymentConfiguration();
+ }
- @NotNull
- @Override
- public Project getProject() {
- return runConfiguration.getProject();
- }
+ @NotNull
+ @Override
+ public Project getProject() {
+ return runConfiguration.getProject();
+ }
- @Override
- public boolean isDebugMode() {
- return false;
- }
- },
- null
- );
+ @Override
+ public boolean isDebugMode() {
+ return false;
+ }
+ }, null);
}
- protected abstract DR createDeploymentRuntime(SC configuration,
- ServerTaskExecutor serverTaskExecutor,
- DeploymentTask deploymentTask,
- @Nullable DeploymentLogManager logManager) throws ServerRuntimeException;
+ private CloudDeploymentRuntime createDeploymentRuntime(DeploymentTask deploymentTask,
+ @Nullable DeploymentLogManager logManager) throws ServerRuntimeException {
+ DeploymentSource source = deploymentTask.getSource();
+ for (CloudDeploymentRuntimeProvider provider : CloudDeploymentConfiguratorBase.getDeploymentRuntimeProviders(myServerType)) {
+ CloudDeploymentRuntime result = provider.createDeploymentRuntime(source, this, deploymentTask, logManager);
+ if (result != null) {
+ return result;
+ }
+ }
+ throw new ServerRuntimeException("Unknown deployment source");
+ }
+
+ public CloudConfigurationBase getConfiguration() {
+ return (CloudConfigurationBase)myConfiguration;
+ }
protected abstract void doConnect(SC configuration, CloudAgentLogger logger);
}
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
similarity index 99%
rename from plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
index 468a4715a68f..ed55c41f7218 100644
--- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
@@ -46,7 +46,7 @@ public abstract class CloudSupportConfigurableBase<
SC extends CloudConfigurationBase,
DC extends CloudDeploymentNameConfiguration,
ST extends ServerType,
- SR extends CloudGitServerRuntimeInstanceBase>
+ SR extends CloudMultiSourceServerRuntimeInstance>
extends FrameworkSupportConfigurable {
private final String myNotificationDisplayId;
diff --git a/plugins/git4idea/remote-servers-git/remote-servers-git.iml b/plugins/git4idea/remote-servers-git/remote-servers-git.iml
index 07e0637a9be8..b9f613800a04 100644
--- a/plugins/git4idea/remote-servers-git/remote-servers-git.iml
+++ b/plugins/git4idea/remote-servers-git/remote-servers-git.iml
@@ -4,7 +4,6 @@
-
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
index 6a9e0ec58384..f444ea68815f 100644
--- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
@@ -1,12 +1,8 @@
package com.intellij.remoteServer.util;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
@@ -14,20 +10,10 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.remoteServer.ServerType;
-import com.intellij.remoteServer.agent.util.CloudGitAgent;
-import com.intellij.remoteServer.agent.util.CloudGitAgentDeployment;
import com.intellij.remoteServer.agent.util.CloudGitApplication;
-import com.intellij.remoteServer.agent.util.CloudLoggingHandler;
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
-import com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource;
-import com.intellij.remoteServer.runtime.ServerTaskExecutor;
import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
-import com.intellij.remoteServer.runtime.deployment.DeploymentRuntime;
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
-import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
-import com.intellij.remoteServer.runtime.log.LoggingHandler;
-import com.intellij.util.ThrowableRunnable;
import com.intellij.util.concurrency.Semaphore;
import git4idea.GitUtil;
import git4idea.actions.GitInit;
@@ -41,151 +27,68 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
-import java.util.List;
/**
* @author michael.golubev
*/
-public abstract class CloudGitDeploymentRuntime> extends DeploymentRuntime {
+public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
private static final Logger LOG = Logger.getInstance("#" + CloudGitDeploymentRuntime.class.getName());
- private final String myApplicationName;
- private final CloudConfigurationBase myConfiguration;
- private final Project myProject;
private final GitRepositoryManager myGitRepositoryManager;
private final Git myGit;
- private DeploymentSourceHandler mySourceHandler;
private final VirtualFile myContentRoot;
- private final File myContentRootFile;
- private final AgentTaskExecutor myAgentTaskExecutor;
- private final String myPresentableName;
- private final CloudLoggingHandler myLoggingHandler;
- private final ServerTaskExecutor myTasksExecutor;
- private final AD myDeployment;
+ private final File myRepositoryRootFile;
- private final DeploymentLogManager myLogManager;
private final String myRemoteName;
private final String myCloudName;
private GitRepository myRepository;
- public CloudGitDeploymentRuntime(CloudConfigurationBase serverConfiguration,
- A agent,
- ServerTaskExecutor taskExecutor,
- DeploymentTask task,
- AgentTaskExecutor agentTaskExecutor,
- @Nullable DeploymentLogManager logManager,
- CloudDeploymentNameProvider deploymentNameProvider,
+ public CloudGitDeploymentRuntime(CloudMultiSourceServerRuntimeInstance serverRuntime,
+ DeploymentSource source,
+ File repositoryRoot,
+ DeploymentTask extends CloudDeploymentNameConfiguration> task,
+ DeploymentLogManager logManager,
String remoteName,
- String cloudName,
- ServerType> serverType) throws ServerRuntimeException {
- myConfiguration = serverConfiguration;
- myTasksExecutor = taskExecutor;
- myLogManager = logManager;
+ String cloudName) throws ServerRuntimeException {
+ super(serverRuntime, source, task, logManager);
myRemoteName = remoteName;
myCloudName = cloudName;
- DC deploymentConfiguration = task.getConfiguration();
+ myRepositoryRootFile = repositoryRoot;
- List handlerProviders
- = CloudGitDeploymentConfiguratorBase.getDeploymentSourceHandlerProviders(serverType);
- DeploymentSource deploymentSource = task.getSource();
- for (CloudGitDeploymentSourceHandlerProvider handlerProvider : handlerProviders) {
- DeploymentSourceHandler sourceHandler = handlerProvider.createHandler(this, deploymentSource, deploymentConfiguration);
- if (sourceHandler != null) {
- mySourceHandler = sourceHandler;
- break;
- }
- }
- if (mySourceHandler == null) {
- throw new ServerRuntimeException("Unknown deployment source");
- }
-
- myContentRootFile = mySourceHandler.getRepositoryRootFile();
-
- VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myContentRootFile);
+ VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myRepositoryRootFile);
LOG.assertTrue(contentRoot != null, "Repository root is not found");
myContentRoot = contentRoot;
- myProject = task.getProject();
- myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
+ myGitRepositoryManager = GitUtil.getRepositoryManager(getProject());
myGit = ServiceManager.getService(Git.class);
if (myGit == null) {
throw new ServerRuntimeException("Can't initialize GIT");
}
-
- myAgentTaskExecutor = agentTaskExecutor;
- myLoggingHandler = logManager == null ? new CloudSilentLoggingHandlerImpl() : new CloudLoggingHandlerImpl(logManager);
-
- myPresentableName = deploymentSource.getPresentableName();
-
- myApplicationName = deploymentConfiguration.isDefaultDeploymentName()
- ? deploymentNameProvider.getDeploymentName(deploymentSource)
- : deploymentConfiguration.getDeploymentName();
-
- myDeployment = agent.createDeployment(getApplicationName(), myLoggingHandler);
- }
-
- public AgentTaskExecutor getAgentTaskExecutor() {
- return myAgentTaskExecutor;
- }
-
- public AD getDeployment() {
- return myDeployment;
- }
-
- public void deploy(ServerRuntimeInstance.DeploymentOperationCallback callback) {
- try {
- deploy();
- callback.succeeded(this);
- }
- catch (ServerRuntimeException e) {
- callback.errorOccurred(e.getMessage());
- }
- }
-
- public void deploy() throws ServerRuntimeException {
- CloudGitApplication application = mySourceHandler.deploy();
-
- if (myLogManager != null) {
- LoggingHandler loggingHandler = myLogManager.getMainLoggingHandler();
- loggingHandler.print("Application is available at ");
- loggingHandler.printHyperlink(application.getWebUrl());
- loggingHandler.print("\n");
- }
}
@Override
- public void undeploy(final @NotNull UndeploymentTaskCallback callback) {
- myTasksExecutor.submit(new ThrowableRunnable() {
-
- @Override
- public void run() throws Exception {
- try {
- undeploy();
- callback.succeeded();
- }
- catch (ServerRuntimeException e) {
- callback.errorOccurred(e.getMessage());
- }
- }
- }, callback);
+ public CloudGitApplication deploy() throws ServerRuntimeException {
+ CloudGitApplication application = findOrCreateApplication();
+ GitRepository repository = findOrCreateRepository();
+ addOrResetGitRemote(application, repository);
+ add();
+ commit();
+ repository.update();
+ pushApplication(application);
+ return application;
}
public void undeploy() throws ServerRuntimeException {
- if (!confirmUndeploy()) {
- throw new ServerRuntimeException("Undeploy cancelled");
- }
- myAgentTaskExecutor.execute(new Computable