Fixed feign usage after Spring Boot 1.3 upgrade
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -42,40 +42,12 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>1.0.7.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-example-mgmt-feign-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
|
||||
@@ -9,37 +9,26 @@
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
|
||||
import org.eclipse.hawkbit.feign.core.client.FeignClientConfiguration;
|
||||
import org.eclipse.hawkbit.feign.core.client.IgnoreMultipleConsumersProducersSpringMvcContract;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtRolloutClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.ConfigurableScenario;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.CreateStartedRolloutExample;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.upload.FeignMultipartEncoder;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.Banner.Mode;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.Logger;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients("org.eclipse.hawkbit.mgmt.client.resource")
|
||||
@@ -49,9 +38,6 @@ import feign.slf4j.Slf4jLogger;
|
||||
@Import(FeignClientConfiguration.class)
|
||||
public class Application implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private ClientConfigurationProperties configuration;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableScenario configuredScenario;
|
||||
|
||||
@@ -59,7 +45,7 @@ public class Application implements CommandLineRunner {
|
||||
private CreateStartedRolloutExample gettingStartedRolloutScenario;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new SpringApplicationBuilder().showBanner(false).sources(Application.class).run(args);
|
||||
new SpringApplicationBuilder().bannerMode(Mode.OFF).sources(Application.class).run(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,18 +60,17 @@ public class Application implements CommandLineRunner {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
|
||||
public BasicAuthRequestInterceptor basicAuthRequestInterceptor(final ClientConfigurationProperties configuration) {
|
||||
return new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConfigurableScenario configurableScenario(final MgmtDistributionSetClientResource distributionSetResource,
|
||||
@Qualifier("mgmtSoftwareModuleClientResource") final MgmtSoftwareModuleClientResource softwareModuleResource,
|
||||
@Qualifier("uploadSoftwareModule") final MgmtSoftwareModuleClientResource uploadSoftwareModule,
|
||||
final MgmtSoftwareModuleClientResource softwareModuleResource,
|
||||
final MgmtTargetClientResource targetResource, final MgmtRolloutClientResource rolloutResource,
|
||||
final ClientConfigurationProperties clientConfigurationProperties) {
|
||||
return new ConfigurableScenario(distributionSetResource, softwareModuleResource, uploadSoftwareModule,
|
||||
targetResource, rolloutResource, clientConfigurationProperties);
|
||||
return new ConfigurableScenario(distributionSetResource, softwareModuleResource, targetResource,
|
||||
rolloutResource, clientConfigurationProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -98,21 +83,6 @@ public class Application implements CommandLineRunner {
|
||||
return Logger.Level.FULL;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MgmtSoftwareModuleClientResource uploadSoftwareModule() {
|
||||
final ObjectMapper mapper = new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.registerModule(new Jackson2HalModule());
|
||||
|
||||
return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
|
||||
.requestInterceptor(
|
||||
new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword()))
|
||||
.logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder())
|
||||
.decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper)))
|
||||
.target(MgmtSoftwareModuleClientResource.class,
|
||||
configuration.getUrl() + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING);
|
||||
}
|
||||
|
||||
private static boolean containsArg(final String containsArg, final String... args) {
|
||||
for (final String arg : args) {
|
||||
if (arg.equalsIgnoreCase(containsArg)) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.eclipse.hawkbit.mgmt.client.resource.builder.RolloutBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.TargetBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.upload.ArtifactFile;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
|
||||
@@ -31,7 +30,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -50,8 +48,6 @@ public class ConfigurableScenario {
|
||||
|
||||
private final MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
private final MgmtSoftwareModuleClientResource uploadSoftwareModule;
|
||||
|
||||
private final MgmtTargetClientResource targetResource;
|
||||
|
||||
private final MgmtRolloutClientResource rolloutResource;
|
||||
@@ -59,13 +55,11 @@ public class ConfigurableScenario {
|
||||
private final ClientConfigurationProperties clientConfigurationProperties;
|
||||
|
||||
public ConfigurableScenario(final MgmtDistributionSetClientResource distributionSetResource,
|
||||
@Qualifier("mgmtSoftwareModuleClientResource") final MgmtSoftwareModuleClientResource softwareModuleResource,
|
||||
@Qualifier("uploadSoftwareModule") final MgmtSoftwareModuleClientResource uploadSoftwareModule,
|
||||
final MgmtSoftwareModuleClientResource softwareModuleResource,
|
||||
final MgmtTargetClientResource targetResource, final MgmtRolloutClientResource rolloutResource,
|
||||
final ClientConfigurationProperties clientConfigurationProperties) {
|
||||
this.distributionSetResource = distributionSetResource;
|
||||
this.softwareModuleResource = softwareModuleResource;
|
||||
this.uploadSoftwareModule = uploadSoftwareModule;
|
||||
this.targetResource = targetResource;
|
||||
this.rolloutResource = rolloutResource;
|
||||
this.clientConfigurationProperties = clientConfigurationProperties;
|
||||
@@ -191,13 +185,6 @@ public class ConfigurableScenario {
|
||||
.type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
|
||||
.getBody());
|
||||
|
||||
for (int x = 0; x < scenario.getArtifactsPerSM(); x++) {
|
||||
modules.forEach(module -> {
|
||||
final ArtifactFile file = new ArtifactFile("dummyfile.dummy", null, "multipart/form-data", artifact);
|
||||
uploadSoftwareModule.uploadArtifact(module.getModuleId(), file, null, null, null);
|
||||
});
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
/**
|
||||
* Example for creating and starting a Rollout.
|
||||
@@ -46,7 +45,6 @@ public class CreateStartedRolloutExample {
|
||||
private MgmtDistributionSetClientResource distributionSetResource;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mgmtSoftwareModuleClientResource")
|
||||
private MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user