Search in sources :

Example 1 with IWebAppRunConfiguration

use of com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration in project azure-tools-for-java by Microsoft.

the class Connection method isApplicableFor.

/**
 * is this connection applicable for the specified {@code configuration}.<br>
 * - the {@code Connect Azure Resource} before run task will take effect if
 * applicable: the {@link #prepareBeforeRun} & {@link #updateJavaParametersAtRun}
 * will be called.
 *
 * @return true if this connection should intervene the specified {@code configuration}.
 */
public boolean isApplicableFor(@Nonnull RunConfiguration configuration) {
    final boolean javaAppRunConfiguration = configuration instanceof ApplicationConfiguration;
    final boolean springbootAppRunConfiguration = StringUtils.equals(configuration.getClass().getName(), SPRING_BOOT_CONFIGURATION);
    final boolean azureWebAppRunConfiguration = configuration instanceof IWebAppRunConfiguration;
    if (javaAppRunConfiguration || azureWebAppRunConfiguration || springbootAppRunConfiguration) {
        final Module module = getTargetModule(configuration);
        return Objects.nonNull(module) && Objects.equals(module.getName(), this.consumer.getName());
    }
    return false;
}
Also used : IWebAppRunConfiguration(com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration) Module(com.intellij.openapi.module.Module) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Example 2 with IWebAppRunConfiguration

use of com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration in project azure-tools-for-java by Microsoft.

the class Connection method prepareBeforeRun.

/**
 * do some preparation in the {@code Connect Azure Resource} before run task
 * of the {@code configuration}<br>
 */
@AzureOperation(name = "connector|connection.prepare_before_run", type = AzureOperation.Type.ACTION)
public boolean prepareBeforeRun(@Nonnull RunConfiguration configuration, DataContext dataContext) {
    this.env = this.resource.initEnv(configuration.getProject()).entrySet().stream().collect(Collectors.toMap(e -> e.getKey().replaceAll(Connection.ENV_PREFIX, this.getEnvPrefix()), Map.Entry::getValue));
    if (configuration instanceof IWebAppRunConfiguration) {
        // set envs for remote deploy
        final IWebAppRunConfiguration webAppConfiguration = (IWebAppRunConfiguration) configuration;
        webAppConfiguration.setApplicationSettings(this.env);
    }
    return true;
}
Also used : IWebAppRunConfiguration(com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

IWebAppRunConfiguration (com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration)2 ApplicationConfiguration (com.intellij.execution.application.ApplicationConfiguration)1 Module (com.intellij.openapi.module.Module)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1