-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
josepharul82
committed
May 24, 2020
0 parents
commit a8fc6e7
Showing
73 changed files
with
2,687 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/bin/ | ||
/.settings/ | ||
/target/ | ||
/target-eclipse/ | ||
.classpath | ||
.project | ||
/.apt_generated/ | ||
/.factorypath | ||
/.idea/ | ||
|
||
|
||
.idea/ | ||
*.iml |
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,20 @@ | ||
# Introduction | ||
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. | ||
|
||
# Getting Started | ||
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about: | ||
1. Installation process | ||
2. Software dependencies | ||
3. Latest releases | ||
4. API references | ||
|
||
# Build and Test | ||
TODO: Describe and show how to build your code and run the tests. | ||
|
||
# Contribute | ||
TODO: Explain how other users and developers can contribute to make your code better. | ||
|
||
If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files: | ||
- [ASP.NET Core](https://github.com/aspnet/Home) | ||
- [Visual Studio Code](https://github.com/Microsoft/vscode) | ||
- [Chakra Core](https://github.com/Microsoft/ChakraCore) |
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,13 @@ | ||
/bin/ | ||
/.settings/ | ||
/target/ | ||
/target-eclipse/ | ||
.classpath | ||
.project | ||
/.apt_generated/ | ||
/.factorypath | ||
/.idea/ | ||
|
||
|
||
.idea/ | ||
*.iml |
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,117 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<groupId>fr.axa.editique.users</groupId> | ||
<artifactId>users</artifactId> | ||
<version>1.0.0.BUILD-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>application</artifactId> | ||
<packaging>war</packaging> | ||
<name>application</name> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>fr.axa.editique.users</groupId> | ||
<artifactId>service-impl</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>fr.axa.editique.users</groupId> | ||
<artifactId>service-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>fr.axa.editique.users</groupId> | ||
<artifactId>repository</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>fr.axa.editique.users</groupId> | ||
<artifactId>model</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jdbc</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger-ui</artifactId> | ||
</dependency> | ||
|
||
<!-- Cucumber --> | ||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-java</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-spring</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-junit</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
<!-- Compiler plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
</plugin> | ||
|
||
|
||
</plugins> | ||
</build> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
application/src/main/java/fr/axa/editique/users/UsersApplication.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,13 @@ | ||
package fr.axa.editique.users; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class UsersApplication { | ||
|
||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(UsersApplication.class, args); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
application/src/main/java/fr/axa/editique/users/application/aop/LoggingAspect.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,75 @@ | ||
package fr.axa.editique.users.application.aop; | ||
|
||
import fr.axa.editique.users.application.config.properties.UsersProperties; | ||
import lombok.AccessLevel; | ||
import lombok.experimental.FieldDefaults; | ||
import lombok.extern.java.Log; | ||
import org.apache.commons.lang3.time.StopWatch; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Arrays; | ||
|
||
@Aspect | ||
@Component | ||
@Log | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public class LoggingAspect { | ||
|
||
UsersProperties usersProperties; | ||
|
||
public LoggingAspect(UsersProperties usersProperties) { | ||
this.usersProperties = usersProperties; | ||
} | ||
|
||
@Pointcut("execution(public * fr.axa.editique.users.application.web.*.*(..))") | ||
public void controllerMethodTime() { | ||
//See spring documentation | ||
} | ||
|
||
@Pointcut("execution(public * fr.axa.editique.users.service.impl.*.*(..))") | ||
public void serviceMethodTime() { | ||
//See spring documentation | ||
} | ||
|
||
@Pointcut("execution(public * fr.axa.editique.users.repository.*.*(..))") | ||
public void repositoryMethodTime() { | ||
//See spring documentation | ||
} | ||
|
||
@Around("controllerMethodTime() || serviceMethodTime() || repositoryMethodTime()") | ||
public Object beforeSampleCreation(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { | ||
StopWatch stopWatch = new StopWatch(); | ||
stopWatch.start(); | ||
Object output = proceedingJoinPoint.proceed(); | ||
stopWatch.stop(); | ||
locExecutionTime(proceedingJoinPoint, stopWatch); | ||
return output; | ||
} | ||
|
||
private void locExecutionTime(ProceedingJoinPoint proceedingJoinPoint, StopWatch stopWatch) { | ||
String message = composeLogMessage(proceedingJoinPoint, stopWatch); | ||
if(stopWatch.getTime() > this.usersProperties.getLogging().getAlertWarningMethodExecutionTime()){ | ||
log.warning(message); | ||
} | ||
} | ||
|
||
private String composeLogMessage(ProceedingJoinPoint proceedingJoinPoint, StopWatch stopWatch) { | ||
Object[] args = proceedingJoinPoint.getArgs(); | ||
StringBuilder logMessage = new StringBuilder(); | ||
logMessage.append(proceedingJoinPoint.getTarget().getClass().getName()); | ||
logMessage.append("."); | ||
logMessage.append(proceedingJoinPoint.getSignature().getName()); | ||
logMessage.append("("); | ||
Arrays.asList(args).stream().forEach(arg -> logMessage.append(arg).append(",")); | ||
logMessage.deleteCharAt(logMessage.toString().length()-1); | ||
logMessage.append(")"); | ||
logMessage.append(" execution time: "); | ||
logMessage.append(stopWatch.getTime()); | ||
logMessage.append(" ms"); | ||
return logMessage.toString(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...on/src/main/java/fr/axa/editique/users/application/config/properties/UsersProperties.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,30 @@ | ||
package fr.axa.editique.users.application.config.properties; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.experimental.FieldDefaults; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Si besoin de véhiculer des propriétés dans les autres modules, il faut passer un DTO | ||
*/ | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = "users-application", ignoreUnknownFields = true) | ||
@Getter | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public class UsersProperties { | ||
|
||
final Logging logging = new Logging(); | ||
|
||
@Getter | ||
@Setter | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public static class Logging { | ||
int alertWarningMethodExecutionTime; | ||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ication/src/main/java/fr/axa/editique/users/application/config/swagger/SwaggerConfig.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,36 @@ | ||
package fr.axa.editique.users.application.config.swagger; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SwaggerConfig { | ||
@Bean | ||
public Docket api() { | ||
|
||
return new Docket(DocumentationType.SWAGGER_2).select() | ||
.apis(RequestHandlerSelectors.basePackage("fr.axa.editique.users.application.web")) | ||
.paths(PathSelectors.any()) | ||
.build().apiInfo(apiEndPointsInfo()); | ||
} | ||
private ApiInfo apiEndPointsInfo() { | ||
return new ApiInfoBuilder() | ||
.title("Spring Boot REST API") | ||
.description("\"Spring Boot REST API for Online Store\"") | ||
.version("1.0.0") | ||
.license("Apache License Version 2.0") | ||
.licenseUrl("https://www.apache.org/licenses/LICENSE-2.0\"") | ||
.contact(new Contact("Joseph ARUL", "https://www.test.fr", "[email protected]")) | ||
.build(); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...ation/src/main/java/fr/axa/editique/users/application/config/web/WebMvcConfiguration.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,9 @@ | ||
package fr.axa.editique.users.application.config.web; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebMvcConfiguration implements WebMvcConfigurer { | ||
|
||
} |
Oops, something went wrong.