From 722ce8fba4c46880d4fee51b5611f58ec613dbb2 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 26 Apr 2017 18:11:15 +0200 Subject: [PATCH] Merge aspectj -> spring-aop (#1737) --- aspectj/README.md | 3 - aspectj/pom.xml | 138 ------------------ pom.xml | 1 - spring-aop/README.md | 2 + .../java/org}/baeldung/aspectj/Account.java | 2 +- .../org}/baeldung/aspectj/AccountAspect.aj | 2 +- .../java/org}/baeldung/aspectj/Secured.java | 2 +- .../org}/baeldung/aspectj/SecuredMethod.java | 2 +- .../baeldung/aspectj/SecuredMethodAspect.java | 2 +- .../performancemonitor/AopConfiguration.java | 8 +- .../MyPerformanceMonitorInterceptor.java | 6 +- .../performancemonitor/PerfomanceApp.java | 2 +- .../baeldung/performancemonitor/Person.java | 2 +- .../performancemonitor/PersonService.java | 2 +- .../src/main/resources/META-INF/aop.xml | 2 +- .../src/main/resources/logback.xml | 0 .../org/baeldung/aspectj}/AccountTest.java | 7 +- .../baeldung/aspectj}/SecuredMethodTest.java | 4 +- .../main/java/org/baeldung/Application.java | 3 +- .../SpringBootApplicationIntegrationTest.java | 10 +- 20 files changed, 30 insertions(+), 170 deletions(-) delete mode 100644 aspectj/README.md delete mode 100644 aspectj/pom.xml rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/aspectj/Account.java (88%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/aspectj/AccountAspect.aj (96%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/aspectj/Secured.java (90%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/aspectj/SecuredMethod.java (94%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/aspectj/SecuredMethodAspect.java (96%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/performancemonitor/AopConfiguration.java (98%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java (96%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/performancemonitor/PerfomanceApp.java (93%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/performancemonitor/Person.java (95%) rename {aspectj/src/main/java/com => spring-aop/src/main/java/org}/baeldung/performancemonitor/PersonService.java (89%) rename {aspectj => spring-aop}/src/main/resources/META-INF/aop.xml (73%) rename {aspectj => spring-aop}/src/main/resources/logback.xml (100%) rename {aspectj/src/test/java/com/baeldung/aspectj/test => spring-aop/src/test/java/org/baeldung/aspectj}/AccountTest.java (79%) rename {aspectj/src/test/java/com/baeldung/aspectj/test => spring-aop/src/test/java/org/baeldung/aspectj}/SecuredMethodTest.java (75%) diff --git a/aspectj/README.md b/aspectj/README.md deleted file mode 100644 index 71724e76b6..0000000000 --- a/aspectj/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: -- [Intro to AspectJ](http://www.baeldung.com/aspectj) -- [Spring Performance Logging](http://www.baeldung.com/spring-performance-logging) diff --git a/aspectj/pom.xml b/aspectj/pom.xml deleted file mode 100644 index 2ef2ae9df7..0000000000 --- a/aspectj/pom.xml +++ /dev/null @@ -1,138 +0,0 @@ - - 4.0.0 - com.baeldung - aspectj - 0.0.1-SNAPSHOT - aspectj - - - - org.aspectj - aspectjrt - ${aspectj.version} - - - - org.aspectj - aspectjweaver - ${aspectj.version} - - - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - - ch.qos.logback - logback-classic - ${logback.version} - - - - ch.qos.logback - logback-core - ${logback.version} - - - - - junit - junit - ${junit.version} - - - - org.springframework - spring-context - 4.3.4.RELEASE - - - org.springframework - spring-beans - 4.3.4.RELEASE - - - org.springframework - spring-core - 4.3.4.RELEASE - - - cglib - cglib - 3.2.4 - - - org.springframework - spring-aop - 4.3.4.RELEASE - - - - - aspectj - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${source.version} - ${source.version} - - - - - - org.codehaus.mojo - aspectj-maven-plugin - 1.7 - - ${source.version} - ${source.version} - ${source.version} - true - true - ignore - ${project.build.sourceEncoding} - - - - - - - compile - test-compile - - - - - - - - - - - 1.8 - UTF-8 - 1.8.9 - 1.7.21 - 1.1.7 - 3.6.0 - 4.12 - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index e3dc78eece..956013c467 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,6 @@ apache-fop apache-poi apache-thrift - aspectj assertj autovalue axon diff --git a/spring-aop/README.md b/spring-aop/README.md index 28295faf23..03d5d8f429 100644 --- a/spring-aop/README.md +++ b/spring-aop/README.md @@ -1,3 +1,5 @@ ### Relevant articles - [Implementing a Custom Spring AOP Annotation](http://www.baeldung.com/spring-aop-annotation) +- [Intro to AspectJ](http://www.baeldung.com/aspectj) +- [Spring Performance Logging](http://www.baeldung.com/spring-performance-logging) \ No newline at end of file diff --git a/aspectj/src/main/java/com/baeldung/aspectj/Account.java b/spring-aop/src/main/java/org/baeldung/aspectj/Account.java similarity index 88% rename from aspectj/src/main/java/com/baeldung/aspectj/Account.java rename to spring-aop/src/main/java/org/baeldung/aspectj/Account.java index bc9ca375aa..2c551116f4 100644 --- a/aspectj/src/main/java/com/baeldung/aspectj/Account.java +++ b/spring-aop/src/main/java/org/baeldung/aspectj/Account.java @@ -1,4 +1,4 @@ -package com.baeldung.aspectj; +package org.baeldung.aspectj; public class Account { int balance = 20; diff --git a/aspectj/src/main/java/com/baeldung/aspectj/AccountAspect.aj b/spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj similarity index 96% rename from aspectj/src/main/java/com/baeldung/aspectj/AccountAspect.aj rename to spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj index 8423c1da97..f08d7dc281 100644 --- a/aspectj/src/main/java/com/baeldung/aspectj/AccountAspect.aj +++ b/spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj @@ -1,4 +1,4 @@ -package com.baeldung.aspectj; +package org.baeldung.aspectj; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/aspectj/src/main/java/com/baeldung/aspectj/Secured.java b/spring-aop/src/main/java/org/baeldung/aspectj/Secured.java similarity index 90% rename from aspectj/src/main/java/com/baeldung/aspectj/Secured.java rename to spring-aop/src/main/java/org/baeldung/aspectj/Secured.java index 923f208c2f..08711d5db1 100644 --- a/aspectj/src/main/java/com/baeldung/aspectj/Secured.java +++ b/spring-aop/src/main/java/org/baeldung/aspectj/Secured.java @@ -1,4 +1,4 @@ -package com.baeldung.aspectj; +package org.baeldung.aspectj; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/aspectj/src/main/java/com/baeldung/aspectj/SecuredMethod.java b/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java similarity index 94% rename from aspectj/src/main/java/com/baeldung/aspectj/SecuredMethod.java rename to spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java index aa4b733a00..d1f7d43738 100644 --- a/aspectj/src/main/java/com/baeldung/aspectj/SecuredMethod.java +++ b/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java @@ -1,4 +1,4 @@ -package com.baeldung.aspectj; +package org.baeldung.aspectj; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/aspectj/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java b/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java similarity index 96% rename from aspectj/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java rename to spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java index 9ea45ec43b..b474f266ab 100644 --- a/aspectj/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java +++ b/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java @@ -1,4 +1,4 @@ -package com.baeldung.aspectj; +package org.baeldung.aspectj; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; diff --git a/aspectj/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java b/spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java similarity index 98% rename from aspectj/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java rename to spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java index 5e2ef90c0f..a5f36fb716 100644 --- a/aspectj/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java +++ b/spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java @@ -1,7 +1,4 @@ -package com.baeldung.performancemonitor; - -import java.time.LocalDate; -import java.time.Month; +package org.baeldung.performancemonitor; import org.aspectj.lang.annotation.Pointcut; import org.springframework.aop.Advisor; @@ -12,6 +9,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import java.time.LocalDate; +import java.time.Month; + @Configuration @EnableAspectJAutoProxy public class AopConfiguration { diff --git a/aspectj/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java b/spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java similarity index 96% rename from aspectj/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java rename to spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java index e995e52182..d098d9466c 100644 --- a/aspectj/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java +++ b/spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java @@ -1,11 +1,11 @@ -package com.baeldung.performancemonitor; - -import java.util.Date; +package org.baeldung.performancemonitor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.springframework.aop.interceptor.AbstractMonitoringInterceptor; +import java.util.Date; + public class MyPerformanceMonitorInterceptor extends AbstractMonitoringInterceptor { public MyPerformanceMonitorInterceptor() { diff --git a/aspectj/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java b/spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java similarity index 93% rename from aspectj/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java rename to spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java index 00268c978e..d0fb3a5393 100644 --- a/aspectj/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java +++ b/spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java @@ -1,4 +1,4 @@ -package com.baeldung.performancemonitor; +package org.baeldung.performancemonitor; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/aspectj/src/main/java/com/baeldung/performancemonitor/Person.java b/spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java similarity index 95% rename from aspectj/src/main/java/com/baeldung/performancemonitor/Person.java rename to spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java index f16f28fdef..abd2465764 100644 --- a/aspectj/src/main/java/com/baeldung/performancemonitor/Person.java +++ b/spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java @@ -1,4 +1,4 @@ -package com.baeldung.performancemonitor; +package org.baeldung.performancemonitor; import java.time.LocalDate; diff --git a/aspectj/src/main/java/com/baeldung/performancemonitor/PersonService.java b/spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java similarity index 89% rename from aspectj/src/main/java/com/baeldung/performancemonitor/PersonService.java rename to spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java index f5bfdddc12..5b98aaf436 100644 --- a/aspectj/src/main/java/com/baeldung/performancemonitor/PersonService.java +++ b/spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java @@ -1,4 +1,4 @@ -package com.baeldung.performancemonitor; +package org.baeldung.performancemonitor; import java.time.LocalDate; import java.time.Period; diff --git a/aspectj/src/main/resources/META-INF/aop.xml b/spring-aop/src/main/resources/META-INF/aop.xml similarity index 73% rename from aspectj/src/main/resources/META-INF/aop.xml rename to spring-aop/src/main/resources/META-INF/aop.xml index f930cde942..e5bddcc30c 100644 --- a/aspectj/src/main/resources/META-INF/aop.xml +++ b/spring-aop/src/main/resources/META-INF/aop.xml @@ -1,6 +1,6 @@ - + diff --git a/aspectj/src/main/resources/logback.xml b/spring-aop/src/main/resources/logback.xml similarity index 100% rename from aspectj/src/main/resources/logback.xml rename to spring-aop/src/main/resources/logback.xml diff --git a/aspectj/src/test/java/com/baeldung/aspectj/test/AccountTest.java b/spring-aop/src/test/java/org/baeldung/aspectj/AccountTest.java similarity index 79% rename from aspectj/src/test/java/com/baeldung/aspectj/test/AccountTest.java rename to spring-aop/src/test/java/org/baeldung/aspectj/AccountTest.java index d90793f681..f118dad034 100644 --- a/aspectj/src/test/java/com/baeldung/aspectj/test/AccountTest.java +++ b/spring-aop/src/test/java/org/baeldung/aspectj/AccountTest.java @@ -1,11 +1,10 @@ -package com.baeldung.aspectj.test; - -import static org.junit.Assert.*; +package org.baeldung.aspectj; import org.junit.Before; import org.junit.Test; -import com.baeldung.aspectj.Account; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class AccountTest { private Account account; diff --git a/aspectj/src/test/java/com/baeldung/aspectj/test/SecuredMethodTest.java b/spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodTest.java similarity index 75% rename from aspectj/src/test/java/com/baeldung/aspectj/test/SecuredMethodTest.java rename to spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodTest.java index 924bb279fd..7ecb2a3ee3 100644 --- a/aspectj/src/test/java/com/baeldung/aspectj/test/SecuredMethodTest.java +++ b/spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodTest.java @@ -1,9 +1,7 @@ -package com.baeldung.aspectj.test; +package org.baeldung.aspectj; import org.junit.Test; -import com.baeldung.aspectj.SecuredMethod; - public class SecuredMethodTest { @Test public void testMethod() throws Exception { diff --git a/spring-boot/src/main/java/org/baeldung/Application.java b/spring-boot/src/main/java/org/baeldung/Application.java index c47bb90830..8b49f4d6ab 100644 --- a/spring-boot/src/main/java/org/baeldung/Application.java +++ b/spring-boot/src/main/java/org/baeldung/Application.java @@ -1,11 +1,12 @@ package org.baeldung; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import com.baeldung.autoconfiguration.MySQLAutoconfiguration; -@org.springframework.boot.autoconfigure.SpringBootApplication(exclude=MySQLAutoconfiguration.class) +@SpringBootApplication(exclude=MySQLAutoconfiguration.class) public class Application { private static ApplicationContext applicationContext; diff --git a/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java index 4ce0678bdd..c5cca3c5fb 100644 --- a/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java @@ -1,9 +1,5 @@ package org.baeldung; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasSize; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; - import org.baeldung.domain.Modes; import org.junit.Before; import org.junit.Test; @@ -21,12 +17,18 @@ import org.springframework.web.context.WebApplicationContext; import java.nio.charset.Charset; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; + @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) @WebAppConfiguration public class SpringBootApplicationIntegrationTest { + @Autowired private WebApplicationContext webApplicationContext; + private MockMvc mockMvc; @Before