-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
3859f6a
commit 30b0cac
Showing
10 changed files
with
132 additions
and
72 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.idea/libraries/Maven__org_springframework_spring_context_4_3_4_RELEASE.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
.idea/libraries/Maven__org_springframework_spring_expression_4_3_4_RELEASE.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
.idea/libraries/Maven__org_springframework_spring_test_4_3_4_RELEASE.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.qinjiangbo.test; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* @date: 12/01/2017 1:40 PM | ||
* @author: [email protected] | ||
*/ | ||
@Aspect | ||
@Component | ||
public class BookAspect { | ||
|
||
@Before("execution(* com.qinjiangbo.test.*.*(..))") | ||
public void logBefore(JoinPoint joinPoint) { | ||
System.out.println(joinPoint.getSignature().getName() | ||
+ "(" + Arrays.asList(joinPoint.getArgs()) + ")"); | ||
} | ||
} |
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,15 @@ | ||
package com.qinjiangbo.test; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @date: 12/01/2017 1:39 PM | ||
* @author: [email protected] | ||
*/ | ||
@Component | ||
public class BookService { | ||
|
||
public void searchBook(long bookId) { | ||
System.out.println("searching book " + bookId); | ||
} | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:aop="http://www.springframework.org/schema/aop" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context.xsd | ||
http://www.springframework.org/schema/aop | ||
http://www.springframework.org/schema/aop/spring-aop.xsd"> | ||
|
||
<context:annotation-config/> | ||
<context:component-scan base-package="com.qinjiangbo.test"/> | ||
|
||
<aop:aspectj-autoproxy proxy-target-class="true"/> | ||
</beans> |
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,23 @@ | ||
import com.qinjiangbo.test.BookService; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
/** | ||
* @date: 12/01/2017 1:42 PM | ||
* @author: [email protected] | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration({"classpath:spring-aop.xml"}) | ||
public class BookAspectTest { | ||
|
||
@Autowired | ||
private BookService bookService; | ||
|
||
@Test | ||
public void testSearch() { | ||
bookService.searchBook(17783l); | ||
} | ||
} |