Java Code Examples for org.springframework.aop.Pointcut#TRUE
The following examples show how to use
org.springframework.aop.Pointcut#TRUE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Pointcuts.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Perform the least expensive check for a pointcut match. * @param pointcut the pointcut to match * @param method the candidate method * @param targetClass the target class * @param args arguments to the method * @return whether there's a runtime match */ public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object[] args) { Assert.notNull(pointcut, "Pointcut must not be null"); if (pointcut == Pointcut.TRUE) { return true; } if (pointcut.getClassFilter().matches(targetClass)) { // Only check if it gets past first hurdle. MethodMatcher mm = pointcut.getMethodMatcher(); if (mm.matches(method, targetClass)) { // We may need additional runtime (argument) check. return (!mm.isRuntime() || mm.matches(method, targetClass, args)); } } return false; }
Example 2
Source File: Pointcuts.java From spring-analysis-note with MIT License | 6 votes |
/** * Perform the least expensive check for a pointcut match. * @param pointcut the pointcut to match * @param method the candidate method * @param targetClass the target class * @param args arguments to the method * @return whether there's a runtime match */ public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object... args) { Assert.notNull(pointcut, "Pointcut must not be null"); if (pointcut == Pointcut.TRUE) { return true; } if (pointcut.getClassFilter().matches(targetClass)) { // Only check if it gets past first hurdle. MethodMatcher mm = pointcut.getMethodMatcher(); if (mm.matches(method, targetClass)) { // We may need additional runtime (argument) check. return (!mm.isRuntime() || mm.matches(method, targetClass, args)); } } return false; }
Example 3
Source File: Pointcuts.java From java-technology-stack with MIT License | 6 votes |
/** * Perform the least expensive check for a pointcut match. * @param pointcut the pointcut to match * @param method the candidate method * @param targetClass the target class * @param args arguments to the method * @return whether there's a runtime match */ public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object... args) { Assert.notNull(pointcut, "Pointcut must not be null"); if (pointcut == Pointcut.TRUE) { return true; } if (pointcut.getClassFilter().matches(targetClass)) { // Only check if it gets past first hurdle. MethodMatcher mm = pointcut.getMethodMatcher(); if (mm.matches(method, targetClass)) { // We may need additional runtime (argument) check. return (!mm.isRuntime() || mm.matches(method, targetClass, args)); } } return false; }
Example 4
Source File: Pointcuts.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Perform the least expensive check for a pointcut match. * @param pointcut the pointcut to match * @param method the candidate method * @param targetClass the target class * @param args arguments to the method * @return whether there's a runtime match */ public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object... args) { Assert.notNull(pointcut, "Pointcut must not be null"); if (pointcut == Pointcut.TRUE) { return true; } if (pointcut.getClassFilter().matches(targetClass)) { // Only check if it gets past first hurdle. MethodMatcher mm = pointcut.getMethodMatcher(); if (mm.matches(method, targetClass)) { // We may need additional runtime (argument) check. return (!mm.isRuntime() || mm.matches(method, targetClass, args)); } } return false; }
Example 5
Source File: AspectMetadata.java From spring-analysis-note with MIT License | 4 votes |
/** * Create a new AspectMetadata instance for the given aspect class. * @param aspectClass the aspect class * @param aspectName the name of the aspect */ public AspectMetadata(Class<?> aspectClass, String aspectName) { this.aspectName = aspectName; Class<?> currClass = aspectClass; AjType<?> ajType = null; while (currClass != Object.class) { AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass); if (ajTypeToCheck.isAspect()) { ajType = ajTypeToCheck; break; } currClass = currClass.getSuperclass(); } if (ajType == null) { throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect"); } if (ajType.getDeclarePrecedence().length > 0) { throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP"); } this.aspectClass = ajType.getJavaClass(); this.ajType = ajType; switch (this.ajType.getPerClause().getKind()) { case SINGLETON: this.perClausePointcut = Pointcut.TRUE; return; case PERTARGET: case PERTHIS: AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setLocation(aspectClass.getName()); ajexp.setExpression(findPerClause(aspectClass)); ajexp.setPointcutDeclarationScope(aspectClass); this.perClausePointcut = ajexp; return; case PERTYPEWITHIN: // Works with a type pattern this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass))); return; default: throw new AopConfigException( "PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass); } }
Example 6
Source File: AspectMetadata.java From java-technology-stack with MIT License | 4 votes |
/** * Create a new AspectMetadata instance for the given aspect class. * @param aspectClass the aspect class * @param aspectName the name of the aspect */ public AspectMetadata(Class<?> aspectClass, String aspectName) { this.aspectName = aspectName; Class<?> currClass = aspectClass; AjType<?> ajType = null; while (currClass != Object.class) { AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass); if (ajTypeToCheck.isAspect()) { ajType = ajTypeToCheck; break; } currClass = currClass.getSuperclass(); } if (ajType == null) { throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect"); } if (ajType.getDeclarePrecedence().length > 0) { throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP"); } this.aspectClass = ajType.getJavaClass(); this.ajType = ajType; switch (this.ajType.getPerClause().getKind()) { case SINGLETON: this.perClausePointcut = Pointcut.TRUE; return; case PERTARGET: case PERTHIS: AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setLocation(aspectClass.getName()); ajexp.setExpression(findPerClause(aspectClass)); ajexp.setPointcutDeclarationScope(aspectClass); this.perClausePointcut = ajexp; return; case PERTYPEWITHIN: // Works with a type pattern this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass))); return; default: throw new AopConfigException( "PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass); } }
Example 7
Source File: AspectMetadata.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Create a new AspectMetadata instance for the given aspect class. * @param aspectClass the aspect class * @param aspectName the name of the aspect */ public AspectMetadata(Class<?> aspectClass, String aspectName) { this.aspectName = aspectName; Class<?> currClass = aspectClass; AjType<?> ajType = null; while (currClass != Object.class) { AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass); if (ajTypeToCheck.isAspect()) { ajType = ajTypeToCheck; break; } currClass = currClass.getSuperclass(); } if (ajType == null) { throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect"); } this.ajType = ajType; if (this.ajType.getDeclarePrecedence().length > 0) { throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP"); } switch (this.ajType.getPerClause().getKind()) { case SINGLETON : this.perClausePointcut = Pointcut.TRUE; return; case PERTARGET : case PERTHIS : AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setLocation("@Aspect annotation on " + aspectClass.getName()); ajexp.setExpression(findPerClause(aspectClass)); this.perClausePointcut = ajexp; return; case PERTYPEWITHIN : // Works with a type pattern this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass))); return; default : throw new AopConfigException( "PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass); } }
Example 8
Source File: AspectMetadata.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Create a new AspectMetadata instance for the given aspect class. * @param aspectClass the aspect class * @param aspectName the name of the aspect */ public AspectMetadata(Class<?> aspectClass, String aspectName) { this.aspectName = aspectName; Class<?> currClass = aspectClass; AjType<?> ajType = null; while (currClass != Object.class) { AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass); if (ajTypeToCheck.isAspect()) { ajType = ajTypeToCheck; break; } currClass = currClass.getSuperclass(); } if (ajType == null) { throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect"); } if (ajType.getDeclarePrecedence().length > 0) { throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP"); } this.aspectClass = ajType.getJavaClass(); this.ajType = ajType; switch (this.ajType.getPerClause().getKind()) { case SINGLETON: this.perClausePointcut = Pointcut.TRUE; return; case PERTARGET: case PERTHIS: AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setLocation(aspectClass.getName()); ajexp.setExpression(findPerClause(aspectClass)); ajexp.setPointcutDeclarationScope(aspectClass); this.perClausePointcut = ajexp; return; case PERTYPEWITHIN: // Works with a type pattern this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass))); return; default: throw new AopConfigException( "PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass); } }
Example 9
Source File: DefaultBeanFactoryPointcutAdvisor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdviceBeanName */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 10
Source File: DefaultPointcutAdvisor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdvice */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 11
Source File: DefaultPointcutAdvisor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Create a DefaultPointcutAdvisor that matches all methods. * <p>{@code Pointcut.TRUE} will be used as Pointcut. * @param advice the Advice to use */ public DefaultPointcutAdvisor(Advice advice) { this(Pointcut.TRUE, advice); }
Example 12
Source File: DefaultBeanFactoryPointcutAdvisor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdviceBeanName */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 13
Source File: DefaultPointcutAdvisor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdvice */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 14
Source File: DefaultPointcutAdvisor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create a DefaultPointcutAdvisor that matches all methods. * <p>{@code Pointcut.TRUE} will be used as Pointcut. * @param advice the Advice to use */ public DefaultPointcutAdvisor(Advice advice) { this(Pointcut.TRUE, advice); }
Example 15
Source File: DefaultBeanFactoryPointcutAdvisor.java From java-technology-stack with MIT License | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdviceBeanName */ public void setPointcut(@Nullable Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 16
Source File: DefaultPointcutAdvisor.java From java-technology-stack with MIT License | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdvice */ public void setPointcut(@Nullable Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 17
Source File: DefaultPointcutAdvisor.java From java-technology-stack with MIT License | 2 votes |
/** * Create a DefaultPointcutAdvisor that matches all methods. * <p>{@code Pointcut.TRUE} will be used as Pointcut. * @param advice the Advice to use */ public DefaultPointcutAdvisor(Advice advice) { this(Pointcut.TRUE, advice); }
Example 18
Source File: DefaultBeanFactoryPointcutAdvisor.java From spring-analysis-note with MIT License | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdviceBeanName */ public void setPointcut(@Nullable Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 19
Source File: DefaultPointcutAdvisor.java From spring-analysis-note with MIT License | 2 votes |
/** * Specify the pointcut targeting the advice. * <p>Default is {@code Pointcut.TRUE}. * @see #setAdvice */ public void setPointcut(@Nullable Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); }
Example 20
Source File: DefaultPointcutAdvisor.java From spring-analysis-note with MIT License | 2 votes |
/** * Create a DefaultPointcutAdvisor that matches all methods. * <p>{@code Pointcut.TRUE} will be used as Pointcut. * @param advice the Advice to use */ public DefaultPointcutAdvisor(Advice advice) { this(Pointcut.TRUE, advice); }