Skip to content

创建pull #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5f1351a
文件介绍
chenhaoxiang Aug 21, 2016
37f4b7e
Tomcat7.0版本
chenhaoxiang Aug 22, 2016
a2fe0e8
网站注册,通过邮箱激活实例
chenhaoxiang Aug 22, 2016
83f0fec
网站注册,发送邮箱激活实例
chenhaoxiang Aug 22, 2016
e0c9af3
log4j的jar包
chenhaoxiang Aug 22, 2016
a5d7de3
log4j的使用实例
chenhaoxiang Aug 23, 2016
101815e
自己写的一个BeanUtils-代码方法详解
chenhaoxiang Aug 25, 2016
afb411b
【BeanUtils】自己写的一个BeanUtils-代码方法详解
chenhaoxiang Aug 25, 2016
a3bb5f2
【框架】[Hibernate]构架知识点详细解析与测试实例
chenhaoxiang Aug 27, 2016
def670a
【框架】[Hibernate]构架知识点详解入门与测试实例
chenhaoxiang Aug 27, 2016
7656800
利用Hibernate进行单表的增删改查
chenhaoxiang Aug 30, 2016
eadd0a9
利用Hibernate进行单表的增删改查
chenhaoxiang Aug 30, 2016
b7de4df
利用Hibernate进行一对多的级联操作-Web实例
chenhaoxiang Aug 30, 2016
8dcb6d1
Spring框架
chenhaoxiang Aug 31, 2016
008ae90
【框架】[Spring3]下载安装、开源框架与IoC控制反转详解
chenhaoxiang Aug 31, 2016
61555ab
Spring-AOP切面技术
chenhaoxiang Sep 2, 2016
785e47b
AOP拦截-使用切点:AspectJExpressionPointcut-切点语言
chenhaoxiang Sep 3, 2016
a134dbb
基于Spring框架的Web应用演示(附带cglib工具进行动态代理)
chenhaoxiang Sep 4, 2016
e251ac5
UltraISO
chenhaoxiang Sep 13, 2016
aa10c73
SpringBoot1.3.1书中实例
chenhaoxiang Nov 4, 2016
adb1dff
Spring基础-依赖注入和Java配置
chenhaoxiang Nov 9, 2016
700d195
csdn博客
chenhaoxiang Nov 9, 2016
b3aa0a2
增加了一些注释
chenhaoxiang Nov 9, 2016
b729dbf
Spring基础配置-AOP
chenhaoxiang Nov 9, 2016
059839f
Spring基础配置-AOP
chenhaoxiang Nov 9, 2016
73b8f13
【Spring】Spring常用配置-Bean的Scope
chenhaoxiang Nov 11, 2016
0742845
【Spring】Spring常用配置-Spring EL和资源调用
chenhaoxiang Nov 14, 2016
6bdc1dc
【Spring】Spring常用配置-Bean的初始化和销毁(生命周期)
chenhaoxiang Nov 14, 2016
2ccb6cc
【Spring】Spring常用配置-Profile
chenhaoxiang Nov 14, 2016
ababaef
【Spring】Spring常用配置-事件(Application Event)
chenhaoxiang Nov 15, 2016
7ee5bec
【Spring】Spring常用配置-事件(Application Event)
chenhaoxiang Nov 15, 2016
60661bc
【Spring】Spring高级话题-Spring Aware
chenhaoxiang Nov 16, 2016
9bb6b5c
【Spring】Spring高级话题-Spring Aware
chenhaoxiang Nov 16, 2016
4b7ed50
【Spring】Spring高级话题-多线程-TaskExecutor
chenhaoxiang Nov 18, 2016
70d7f3b
【Spring】Spring高级话题-多线程-TaskExecutor
chenhaoxiang Nov 18, 2016
5978331
【Spring】Spring高级话题-多线程-TaskExecutor
chenhaoxiang Nov 18, 2016
9e45863
Signed-off-by: chx <[email protected]>
chenhaoxiang Nov 27, 2016
82ecc5f
一个小小的vbs代码
chenhaoxiang Nov 27, 2016
b5e3cb1
vbs
chenhaoxiang Nov 27, 2016
c6861da
vbs
chenhaoxiang Nov 27, 2016
884197f
锁机的badusb代码
chenhaoxiang Nov 29, 2016
fb6980d
【Spring】Spring高级话题-条件注解-@Condition
chenhaoxiang Dec 7, 2016
5169cf6
【Spring】Spring高级话题-组合注解与元注解
chenhaoxiang Dec 8, 2016
085b5f8
【Spring】Spring高级话题-组合注解与元注解
chenhaoxiang Dec 8, 2016
7d630f0
【Spring】Spring高级话题-计划任务-@EnableScheduling
chenhaoxiang Dec 9, 2016
b5c6e0f
spring-测试
chenhaoxiang Dec 9, 2016
1187b15
spring--测试
chenhaoxiang Dec 9, 2016
d78ae7a
spring-测试
chenhaoxiang Dec 10, 2016
2016c97
【Spring】Spring高级话题-测试Spring项目
chenhaoxiang Dec 10, 2016
d0fd2f6
spring-Mvc
chenhaoxiang Dec 15, 2016
d1eaed5
QQ发说说,点击查看全文,自动添加好友
chenhaoxiang Dec 15, 2016
b41b689
QQ发说说,点击查看全文添加好友-源码
chenhaoxiang Dec 15, 2016
0620983
【SpringMVC】SpringMVC基础-SpringMVC项目快速搭建
chenhaoxiang Dec 19, 2016
8ba423f
说明
chenhaoxiang Dec 19, 2016
92b5e53
SpringMVC
chenhaoxiang Dec 19, 2016
457da39
改了一下springMVC,移动到springMVC了
chenhaoxiang Feb 20, 2017
402665d
修改了book项目,以及增加了一个小的项目-水平分表的解释小实践
chenhaoxiang Feb 5, 2018
7bacc16
修改book项目的说明文档编码
chenhaoxiang Feb 5, 2018
27218fe
修改说明文档编码
chenhaoxiang Feb 5, 2018
c35d76f
【MySQL性能优化】MySQL分库分表与水平分割取模案例
chenhaoxiang Feb 5, 2018
58b4f04
修改一下说明文档的编码
chenhaoxiang Feb 5, 2018
f7244f2
修改一下说明文档的编码
chenhaoxiang Feb 5, 2018
9be436e
【Druid】Druid监控SSM项目性能-配置与实例
chenhaoxiang Feb 6, 2018
d5f1ade
druid_spring_config项目sql
chenhaoxiang Feb 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AOP拦截-使用切点:AspectJExpressionPointcut-切点语言
  • Loading branch information
chenhaoxiang committed Sep 3, 2016
commit 785e47befb9654063b71f32b80136aa2f4288afc
3 changes: 2 additions & 1 deletion Spring/mySpringAopDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ http://blog.csdn.net/qq_26525215/article/details/52412901
http://blog.csdn.net/qq_26525215/article/details/52420658



【框架】[Spring]AOP拦截-使用切点:AspectJExpressionPointcut-切点语言:
http://blog.csdn.net/qq_26525215/article/details/52422395



Expand Down
Binary file modified Spring/mySpringAopDemo/mySpringAopDemo.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cn.hncu.xmlImpl.aspectj;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class AroundAdvice implements MethodInterceptor{
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
System.out.println("前面拦截....");
Object resObj = invocation.proceed();//放行
System.out.println("后面拦截.....");
return resObj;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package cn.hncu.xmlImpl.aspectj;

import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.aop.support.DefaultPointcutAdvisor;

public class AspectjDemo {

@Test
public void demo(){

ProxyFactoryBean factory = new ProxyFactoryBean();
factory.setTarget(new Person());

//声明一个aspectj切点
AspectJExpressionPointcut cut = new AspectJExpressionPointcut();

//设置需要拦截的方法-用切点语言来写
cut.setExpression("execution( int cn.hncu.xmlImpl.aspectj.Person.run() )");//拦截:空参返回值为int的run方法
//cut.setExpression("execution( void cn.hncu.xmlImpl.aspectj.Person.*() )");//拦截:空参空返回值的任意方法
//cut.setExpression("execution (void cn.hncu.xmlImpl.aspectj.Person.*(String))");//拦截:只有1个String类型参数,空返回值的任意方法
//cut.setExpression("execution( void cn.hncu.xmlImpl.aspectj.Person.*(*) )");//拦截:有1个参数(类型不限),空返回值的任意方法
//cut.setExpression("execution( void cn.hncu.xmlImpl.aspectj.Person.*(*,*) )");//拦截:有2个参数(类型不限),空返回值的任意方法
//cut.setExpression("execution( void cn.hncu.xmlImpl.aspectj.Person.*(..) )");//拦截:任意(个数和类型)参数,空返回值的任意方法
//cut.setExpression("execution( int cn.hncu.xmlImpl.aspectj.Person.*(*,..) )");//拦截:至少有1个参数(类型不限),返回值类型是int的任意方法
//cut.setExpression("execution( * cn.hncu.xmlImpl.aspectj.Person.*(*,..) )");//拦截:至少有1个参数(类型不限),返回值类型任意的方法
//cut.setExpression("execution( * cn.hncu..*son.*(*,..) )");//拦截:cn.hncu包下,类名以"son"结束,至少有1个参数(类型不限),返回值类型任意的方法

Advice advice = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
System.out.println("放行前拦截...");
Object obj = invocation.proceed();//放行
System.out.println("放行后拦截...");
return obj;
}
};

//切面=切点+通知
Advisor advisor = new DefaultPointcutAdvisor(cut,advice);
factory.addAdvisor(advisor);
Person p = (Person) factory.getObject();

p.run();
p.run(10);
p.say();
p.sayHi("Jack");
p.say("Tom", 666);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cn.hncu.xmlImpl.aspectj;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AspectjXmlDemo {
@Test
public void demo1(){
ApplicationContext ctx = new ClassPathXmlApplicationContext("cn/hncu/xmlImpl/aspectj/aspectj.xml");
Person p = ctx.getBean(Person.class);
p.run();
p.run(10);
p.say();
p.sayHi("Jack");
p.say("Tom", 666);
}
}
24 changes: 24 additions & 0 deletions Spring/mySpringAopDemo/src/cn/hncu/xmlImpl/aspectj/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.hncu.xmlImpl.aspectj;

public class Person {
public int run(){
System.out.println("返回值为int-我在run...");
return 0;
}

public void run(int i){
System.out.println("我在run...<"+i+">");
}

public void say(){
System.out.println("我在say...");
}
public void sayHi(String name){
System.out.println("Hi,"+name+",你好");
}
public int say(String name, int i){
System.out.println(name+ "----"+ i);
return 0;
}

}
28 changes: 28 additions & 0 deletions Spring/mySpringAopDemo/src/cn/hncu/xmlImpl/aspectj/aspectj.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!-- 自动代理 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"></bean>

<bean id="p" class="cn.hncu.xmlImpl.aspectj.Person"></bean>

<!-- 切面=切点+通知 (把切点和通知写成内部bean)-->
<bean id="cut" class="org.springframework.aop.aspectj.AspectJExpressionPointcut">
<!-- 拦截:cn.hncu包下,类名以"son"结束,至少有1个参数(类型不限),返回值类型任意的方法 -->
<property name="expression" value="execution( * cn.hncu..*son.*(*,..) )"></property>
</bean>

<bean id="advisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="pointcut" ref="cut"></property>
<property name="advice">
<bean id="advice" class="cn.hncu.xmlImpl.aspectj.AroundAdvice"></bean>
</property>
</bean>


</beans>
23 changes: 23 additions & 0 deletions Spring/mySpringAopDemo/src/cn/hncu/xmlImpl/aspectj/aspectj2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

<!-- 自动代理 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"></bean>

<bean id="p" class="cn.hncu.xmlImpl.aspectj.Person"></bean>

<!-- 切面=切点+通知 (※※采用面向切点语言进行配置切面)-->
<bean id="advisor" class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
<property name="expression" value="execution( * cn.hncu..*son.*(*,..) )"></property>
<property name="advice">
<bean id="advice" class="cn.hncu.xmlImpl.aspectj.AroundAdvice"></bean>
</property>
</bean>

</beans>