-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1857 from Bolo89/move-common-springboot-actuator
Move common springboot actuator
- Loading branch information
Showing
23 changed files
with
357 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ech/jhipster/lite/generator/server/springboot/technicaltools/actuator/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Technical tools - Actuator | ||
|
||
## Description | ||
|
||
This context is used to add actuator, in existing project. | ||
|
||
## Maintainers | ||
|
||
- [Bolo](https://github.com/bolo89) |
19 changes: 19 additions & 0 deletions
19
.../springboot/technicaltools/actuator/application/SpringBootActuatorApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain.SpringBootActuatorService; | ||
|
||
@Service | ||
public class SpringBootActuatorApplicationService { | ||
|
||
private final SpringBootActuatorService springBootActuatorService; | ||
|
||
public SpringBootActuatorApplicationService(SpringBootActuatorService springBootActuatorService) { | ||
this.springBootActuatorService = springBootActuatorService; | ||
} | ||
|
||
public void addActuator(Project project) { | ||
springBootActuatorService.addActuator(project); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...r/lite/generator/server/springboot/technicaltools/actuator/domain/SpringBootActuator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain; | ||
|
||
import tech.jhipster.lite.generator.buildtool.generic.domain.Dependency; | ||
|
||
public class SpringBootActuator { | ||
|
||
private SpringBootActuator() {} | ||
|
||
public static Dependency springBootActuatorDependency() { | ||
return Dependency.builder().groupId("org.springframework.boot").artifactId("spring-boot-starter-actuator").build(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...tor/server/springboot/technicaltools/actuator/domain/SpringBootActuatorDomainService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain; | ||
|
||
import static tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain.SpringBootActuator.springBootActuatorDependency; | ||
|
||
import tech.jhipster.lite.generator.buildtool.generic.domain.BuildToolService; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.springboot.common.domain.SpringBootCommonService; | ||
|
||
public class SpringBootActuatorDomainService implements SpringBootActuatorService { | ||
|
||
private final BuildToolService buildToolService; | ||
private final SpringBootCommonService springBootCommonService; | ||
|
||
public SpringBootActuatorDomainService(BuildToolService buildToolService, SpringBootCommonService springBootCommonService) { | ||
this.buildToolService = buildToolService; | ||
this.springBootCommonService = springBootCommonService; | ||
} | ||
|
||
@Override | ||
public void addActuator(Project project) { | ||
buildToolService.addDependency(project, springBootActuatorDependency()); | ||
|
||
springBootCommonService.addPropertiesComment(project, "Spring Boot Actuator"); | ||
springBootCommonService.addProperties(project, "management.endpoints.web.base-path", "/management"); | ||
springBootCommonService.addProperties( | ||
project, | ||
"management.endpoints.web.exposure.include", | ||
"configprops, env, health, info, logfile, loggers, threaddump" | ||
); | ||
springBootCommonService.addProperties(project, "management.endpoint.health.probes.enabled", "true"); | ||
springBootCommonService.addPropertiesNewLine(project); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...generator/server/springboot/technicaltools/actuator/domain/SpringBootActuatorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain; | ||
|
||
import tech.jhipster.lite.generator.project.domain.Project; | ||
|
||
public interface SpringBootActuatorService { | ||
void addActuator(Project project); | ||
} |
25 changes: 25 additions & 0 deletions
25
...ot/technicaltools/actuator/infrastructure/config/SpringBootActuatorBeanConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.infrastructure.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.buildtool.generic.domain.BuildToolService; | ||
import tech.jhipster.lite.generator.server.springboot.common.domain.SpringBootCommonService; | ||
import tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain.SpringBootActuatorDomainService; | ||
import tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.domain.SpringBootActuatorService; | ||
|
||
@Configuration | ||
public class SpringBootActuatorBeanConfiguration { | ||
|
||
private final BuildToolService buildToolService; | ||
private final SpringBootCommonService springBootCommonService; | ||
|
||
public SpringBootActuatorBeanConfiguration(BuildToolService buildToolService, SpringBootCommonService springBootCommonService) { | ||
this.buildToolService = buildToolService; | ||
this.springBootCommonService = springBootCommonService; | ||
} | ||
|
||
@Bean | ||
public SpringBootActuatorService springBootActuatorService() { | ||
return new SpringBootActuatorDomainService(buildToolService, springBootCommonService); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...gboot/technicaltools/actuator/infrastructure/primary/rest/SpringBootActuatorResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.infrastructure.primary.rest; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import tech.jhipster.lite.generator.project.domain.GeneratorAction; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.project.infrastructure.primary.dto.ProjectDTO; | ||
import tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.application.SpringBootActuatorApplicationService; | ||
import tech.jhipster.lite.technical.infrastructure.primary.annotation.GeneratorStep; | ||
|
||
@RestController | ||
@RequestMapping("/api/servers/spring-boot/technical-tools") | ||
@Tag(name = "Spring Boot - Technical tools") | ||
class SpringBootActuatorResource { | ||
|
||
private final SpringBootActuatorApplicationService springBootActuatorApplicationService; | ||
|
||
public SpringBootActuatorResource(SpringBootActuatorApplicationService springBootActuatorApplicationService) { | ||
this.springBootActuatorApplicationService = springBootActuatorApplicationService; | ||
} | ||
|
||
@Operation(summary = "Add Spring Boot Actuator") | ||
@ApiResponse(responseCode = "500", description = "An error occurred while adding Spring Boot Actuator") | ||
@PostMapping("/actuator") | ||
@GeneratorStep(id = GeneratorAction.SPRINGBOOT_ACTUATOR) | ||
public void addActuator(@RequestBody ProjectDTO projectDTO) { | ||
Project project = ProjectDTO.toProject(projectDTO); | ||
springBootActuatorApplicationService.addActuator(project); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
.../tech/jhipster/lite/generator/server/springboot/technicaltools/actuator/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...pringboot/technicaltools/actuator/application/SpringBootActuatorApplicationServiceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tech.jhipster.lite.generator.server.springboot.technicaltools.actuator.application; | ||
|
||
import static tech.jhipster.lite.TestUtils.tmpProject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import tech.jhipster.lite.IntegrationTest; | ||
import tech.jhipster.lite.generator.buildtool.maven.application.MavenApplicationService; | ||
import tech.jhipster.lite.generator.init.application.InitApplicationService; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.springboot.core.application.SpringBootApplicationService; | ||
|
||
@IntegrationTest | ||
class SpringBootActuatorApplicationServiceIT { | ||
|
||
@Autowired | ||
InitApplicationService initApplicationService; | ||
|
||
@Autowired | ||
MavenApplicationService mavenApplicationService; | ||
|
||
@Autowired | ||
SpringBootApplicationService springBootApplicationService; | ||
|
||
@Autowired | ||
SpringBootActuatorApplicationService springBootActuatorApplicationService; | ||
|
||
@Test | ||
void shouldAddSpringBootActuator() { | ||
Project project = tmpProject(); | ||
initApplicationService.init(project); | ||
mavenApplicationService.addPomXml(project); | ||
springBootApplicationService.init(project); | ||
|
||
springBootActuatorApplicationService.addActuator(project); | ||
|
||
SpringbootActuatorAssert.assertDependencies(project); | ||
SpringbootActuatorAssert.assertProperties(project); | ||
} | ||
} |
Oops, something went wrong.