forked from YaleGuo/Minis
-
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.
implements PointCut and AutoProxyCreator.
- Loading branch information
Showing
25 changed files
with
561 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.minis.aop; | ||
|
||
public interface AopProxyFactory { | ||
AopProxy createAopProxy(Object target,Advisor adviseor); | ||
AopProxy createAopProxy(Object target, PointcutAdvisor adviseor); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.minis.aop; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
public interface MethodMatcher { | ||
boolean matches(Method method, Class<?> targetClass); | ||
} |
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 com.minis.aop; | ||
|
||
import java.lang.reflect.Method; | ||
import com.minis.util.PatternMatchUtils; | ||
|
||
public class NameMatchMethodPointcut implements MethodMatcher,Pointcut{ | ||
private String mappedName = ""; | ||
|
||
public void setMappedName(String mappedName) { | ||
this.mappedName = mappedName; | ||
} | ||
|
||
@Override | ||
public boolean matches(Method method, Class<?> targetClass) { | ||
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
protected boolean isMatch(String methodName, String mappedName) { | ||
return PatternMatchUtils.simpleMatch(mappedName, methodName); | ||
} | ||
|
||
@Override | ||
public MethodMatcher getMethodMatcher() { | ||
return this; | ||
} | ||
|
||
} |
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,58 @@ | ||
package com.minis.aop; | ||
|
||
public class NameMatchMethodPointcutAdvisor implements PointcutAdvisor{ | ||
private Advice advice = null; | ||
private MethodInterceptor methodInterceptor; | ||
private String mappedName; | ||
private final NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); | ||
|
||
public NameMatchMethodPointcutAdvisor() { | ||
} | ||
|
||
public NameMatchMethodPointcutAdvisor(Advice advice) { | ||
this.advice = advice; | ||
} | ||
|
||
public void setMethodInterceptor(MethodInterceptor methodInterceptor) { | ||
this.methodInterceptor = methodInterceptor; | ||
} | ||
|
||
public MethodInterceptor getMethodInterceptor() { | ||
return this.methodInterceptor; | ||
} | ||
|
||
|
||
public void setAdvice(Advice advice) { | ||
this.advice = advice; | ||
|
||
MethodInterceptor mi = null; | ||
|
||
if (advice instanceof BeforeAdvice) { | ||
mi = new MethodBeforeAdviceInterceptor((MethodBeforeAdvice)advice); | ||
} | ||
else if (advice instanceof AfterAdvice){ | ||
mi = new AfterReturningAdviceInterceptor((AfterReturningAdvice)advice); | ||
} | ||
else if (advice instanceof MethodInterceptor) { | ||
mi = (MethodInterceptor)advice; | ||
} | ||
|
||
setMethodInterceptor(mi); | ||
} | ||
|
||
@Override | ||
public Advice getAdvice() { | ||
return this.advice; | ||
} | ||
|
||
@Override | ||
public Pointcut getPointcut() { | ||
return pointcut; | ||
} | ||
|
||
public void setMappedName(String mappedName) { | ||
this.mappedName = mappedName; | ||
this.pointcut.setMappedName(this.mappedName); | ||
} | ||
|
||
} |
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,8 @@ | ||
package com.minis.aop; | ||
|
||
public interface Pointcut { | ||
//ClassFilter getClassFilter(); | ||
|
||
MethodMatcher getMethodMatcher(); | ||
|
||
} |
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,5 @@ | ||
package com.minis.aop; | ||
|
||
public interface PointcutAdvisor extends Advisor { | ||
Pointcut getPointcut(); | ||
} |
Oops, something went wrong.