Here are the examples of the java api org.springframework.aop.MethodMatcher taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
54 Examples
19
Source : ComposablePointcutTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* @author Rod Johnson
* @author Chris Beams
*/
public clreplaced ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("get");
}
};
public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().equals("getAge");
}
};
public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().equals("absquatulate");
}
};
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("set");
}
};
@Test
public void testMatchAll() throws NoSuchMethodException {
Pointcut pc = new ComposablePointcut();
replacedertTrue(pc.getClreplacedFilter().matches(Object.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(Object.clreplaced.getMethod("hashCode"), Exception.clreplaced));
}
@Test
public void testFilterByClreplaced() throws NoSuchMethodException {
ComposablePointcut pc = new ComposablePointcut();
replacedertTrue(pc.getClreplacedFilter().matches(Object.clreplaced));
ClreplacedFilter cf = new RootClreplacedFilter(Exception.clreplaced);
pc.intersection(cf);
replacedertFalse(pc.getClreplacedFilter().matches(Object.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(Exception.clreplaced));
pc.intersection(new RootClreplacedFilter(NestedRuntimeException.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(Exception.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(String.clreplaced));
pc.union(new RootClreplacedFilter(String.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(Exception.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(String.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced));
}
@Test
public void testUnionMethodMatcher() {
// Matches the getAge() method in any clreplaced
ComposablePointcut pc = new ComposablePointcut(ClreplacedFilter.TRUE, GET_AGE_METHOD_MATCHER);
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.union(GETTER_METHOD_MATCHER);
// Should now match all getter methods
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.union(ABSQUATULATE_METHOD_MATCHER);
// Should now match absquatulate() as well
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
// But it doesn't match everything
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.clreplaced));
}
@Test
public void testIntersectionMethodMatcher() {
ComposablePointcut pc = new ComposablePointcut();
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.intersection(GETTER_METHOD_MATCHER);
replacedertFalse(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.intersection(GET_AGE_METHOD_MATCHER);
// Use the Pointcuts matches method
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
}
@Test
public void testEqualsAndHashCode() throws Exception {
ComposablePointcut pc1 = new ComposablePointcut();
ComposablePointcut pc2 = new ComposablePointcut();
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
pc1.intersection(GETTER_METHOD_MATCHER);
replacedertFalse(pc1.equals(pc2));
replacedertFalse(pc1.hashCode() == pc2.hashCode());
pc2.intersection(GETTER_METHOD_MATCHER);
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
pc1.union(GET_AGE_METHOD_MATCHER);
pc2.union(GET_AGE_METHOD_MATCHER);
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
}
}
19
Source : MethodMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Match all methods that <i>either</i> (or both) of the given MethodMatchers matches.
* @param mm1 the first MethodMatcher
* @param mm2 the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that either
* of the given MethodMatchers matches
*/
public static MethodMatcher union(MethodMatcher mm1, MethodMatcher mm2) {
return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new UnionIntroductionAwareMethodMatcher(mm1, mm2) : new UnionMethodMatcher(mm1, mm2));
}
19
Source : MethodMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Match all methods that <i>both</i> of the given MethodMatchers match.
* @param mm1 the first MethodMatcher
* @param mm2 the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that both
* of the given MethodMatchers match
*/
public static MethodMatcher intersection(MethodMatcher mm1, MethodMatcher mm2) {
return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new IntersectionIntroductionAwareMethodMatcher(mm1, mm2) : new IntersectionMethodMatcher(mm1, mm2));
}
19
Source : ComposablePointcut.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Apply an intersection with the given MethodMatcher.
* @param other the MethodMatcher to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(MethodMatcher other) {
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other);
return this;
}
19
Source : ComposablePointcut.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Apply a union with the given MethodMatcher.
* @param other the MethodMatcher to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(MethodMatcher other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, other);
return this;
}
19
Source : ComposablePointcutTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
/**
* @author Rod Johnson
* @author Chris Beams
*/
public clreplaced ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("get");
}
};
public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().equals("getAge");
}
};
public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().equals("absquatulate");
}
};
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, @Nullable Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("set");
}
};
@Test
public void testMatchAll() throws NoSuchMethodException {
Pointcut pc = new ComposablePointcut();
replacedertThat(pc.getClreplacedFilter().matches(Object.clreplaced)).isTrue();
replacedertThat(pc.getMethodMatcher().matches(Object.clreplaced.getMethod("hashCode"), Exception.clreplaced)).isTrue();
}
@Test
public void testFilterByClreplaced() throws NoSuchMethodException {
ComposablePointcut pc = new ComposablePointcut();
replacedertThat(pc.getClreplacedFilter().matches(Object.clreplaced)).isTrue();
ClreplacedFilter cf = new RootClreplacedFilter(Exception.clreplaced);
pc.intersection(cf);
replacedertThat(pc.getClreplacedFilter().matches(Object.clreplaced)).isFalse();
replacedertThat(pc.getClreplacedFilter().matches(Exception.clreplaced)).isTrue();
pc.intersection(new RootClreplacedFilter(NestedRuntimeException.clreplaced));
replacedertThat(pc.getClreplacedFilter().matches(Exception.clreplaced)).isFalse();
replacedertThat(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced)).isTrue();
replacedertThat(pc.getClreplacedFilter().matches(String.clreplaced)).isFalse();
pc.union(new RootClreplacedFilter(String.clreplaced));
replacedertThat(pc.getClreplacedFilter().matches(Exception.clreplaced)).isFalse();
replacedertThat(pc.getClreplacedFilter().matches(String.clreplaced)).isTrue();
replacedertThat(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced)).isTrue();
}
@Test
public void testUnionMethodMatcher() {
// Matches the getAge() method in any clreplaced
ComposablePointcut pc = new ComposablePointcut(ClreplacedFilter.TRUE, GET_AGE_METHOD_MATCHER);
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isFalse();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isFalse();
pc.union(GETTER_METHOD_MATCHER);
// Should now match all getter methods
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isFalse();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isTrue();
pc.union(ABSQUATULATE_METHOD_MATCHER);
// Should now match absquatulate() as well
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isTrue();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isTrue();
// But it doesn't match everything
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.clreplaced)).isFalse();
}
@Test
public void testIntersectionMethodMatcher() {
ComposablePointcut pc = new ComposablePointcut();
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isTrue();
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isTrue();
pc.intersection(GETTER_METHOD_MATCHER);
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isFalse();
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isTrue();
pc.intersection(GET_AGE_METHOD_MATCHER);
// Use the Pointcuts matches method
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced)).isFalse();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced)).isTrue();
replacedertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced)).isFalse();
}
@Test
public void testEqualsAndHashCode() throws Exception {
ComposablePointcut pc1 = new ComposablePointcut();
ComposablePointcut pc2 = new ComposablePointcut();
replacedertThat(pc2).isEqualTo(pc1);
replacedertThat(pc2.hashCode()).isEqualTo(pc1.hashCode());
pc1.intersection(GETTER_METHOD_MATCHER);
replacedertThat(pc1.equals(pc2)).isFalse();
replacedertThat(pc1.hashCode() == pc2.hashCode()).isFalse();
pc2.intersection(GETTER_METHOD_MATCHER);
replacedertThat(pc2).isEqualTo(pc1);
replacedertThat(pc2.hashCode()).isEqualTo(pc1.hashCode());
pc1.union(GET_AGE_METHOD_MATCHER);
pc2.union(GET_AGE_METHOD_MATCHER);
replacedertThat(pc2).isEqualTo(pc1);
replacedertThat(pc2.hashCode()).isEqualTo(pc1.hashCode());
}
}
19
Source : ComposablePointcutTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* @author Rod Johnson
* @author Chris Beams
*/
public final clreplaced ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("get");
}
};
public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Clreplaced<?> targetClreplaced) {
return m.getName().equals("getAge");
}
};
public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Clreplaced<?> targetClreplaced) {
return m.getName().equals("absquatulate");
}
};
public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
public boolean matches(Method m, Clreplaced<?> targetClreplaced) {
return m.getName().startsWith("set");
}
};
@Test
public void testMatchAll() throws NoSuchMethodException {
Pointcut pc = new ComposablePointcut();
replacedertTrue(pc.getClreplacedFilter().matches(Object.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(Object.clreplaced.getMethod("hashCode", (Clreplaced[]) null), Exception.clreplaced));
}
@Test
public void testFilterByClreplaced() throws NoSuchMethodException {
ComposablePointcut pc = new ComposablePointcut();
replacedertTrue(pc.getClreplacedFilter().matches(Object.clreplaced));
ClreplacedFilter cf = new RootClreplacedFilter(Exception.clreplaced);
pc.intersection(cf);
replacedertFalse(pc.getClreplacedFilter().matches(Object.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(Exception.clreplaced));
pc.intersection(new RootClreplacedFilter(NestedRuntimeException.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(Exception.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(String.clreplaced));
pc.union(new RootClreplacedFilter(String.clreplaced));
replacedertFalse(pc.getClreplacedFilter().matches(Exception.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(String.clreplaced));
replacedertTrue(pc.getClreplacedFilter().matches(NestedRuntimeException.clreplaced));
}
@Test
public void testUnionMethodMatcher() {
// Matches the getAge() method in any clreplaced
ComposablePointcut pc = new ComposablePointcut(ClreplacedFilter.TRUE, GET_AGE_METHOD_MATCHER);
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced, null));
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced, null));
pc.union(GETTER_METHOD_MATCHER);
// Should now match all getter methods
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced, null));
pc.union(ABSQUATULATE_METHOD_MATCHER);
// Should now match absquatulate() as well
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced, null));
// But it doesn't match everything
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.clreplaced, null));
}
@Test
public void testIntersectionMethodMatcher() {
ComposablePointcut pc = new ComposablePointcut();
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.intersection(GETTER_METHOD_MATCHER);
replacedertFalse(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced));
replacedertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced));
pc.intersection(GET_AGE_METHOD_MATCHER);
// Use the Pointcuts matches method
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.clreplaced, null));
replacedertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.clreplaced, null));
replacedertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.clreplaced, null));
}
@Test
public void testEqualsAndHashCode() throws Exception {
ComposablePointcut pc1 = new ComposablePointcut();
ComposablePointcut pc2 = new ComposablePointcut();
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
pc1.intersection(GETTER_METHOD_MATCHER);
replacedertFalse(pc1.equals(pc2));
replacedertFalse(pc1.hashCode() == pc2.hashCode());
pc2.intersection(GETTER_METHOD_MATCHER);
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
pc1.union(GET_AGE_METHOD_MATCHER);
pc2.union(GET_AGE_METHOD_MATCHER);
replacedertEquals(pc1, pc2);
replacedertEquals(pc1.hashCode(), pc2.hashCode());
}
}
19
Source : MethodMatchers.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Match all methods that <i>either</i> (or both) of the given MethodMatchers matches.
* @param mm1 the first MethodMatcher
* @param mm2 the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that either
* of the given MethodMatchers matches
*/
public static MethodMatcher union(MethodMatcher mm1, MethodMatcher mm2) {
return new UnionMethodMatcher(mm1, mm2);
}
19
Source : MethodMatchers.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Match all methods that <i>both</i> of the given MethodMatchers match.
* @param mm1 the first MethodMatcher
* @param mm2 the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that both
* of the given MethodMatchers match
*/
public static MethodMatcher intersection(MethodMatcher mm1, MethodMatcher mm2) {
return new IntersectionMethodMatcher(mm1, mm2);
}
18
Source : AspectJExpressionPointcutTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
private void replacedertMatchesGetAge(MethodMatcher methodMatcher) {
replacedertTrue("Expression should match getAge() method", methodMatcher.matches(getAge, TestBean.clreplaced));
}
18
Source : MethodMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Match all methods that <i>either</i> (or both) of the given MethodMatchers matches.
* @param mm1 the first MethodMatcher
* @param cf1 the corresponding ClreplacedFilter for the first MethodMatcher
* @param mm2 the second MethodMatcher
* @param cf2 the corresponding ClreplacedFilter for the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that either
* of the given MethodMatchers matches
*/
static MethodMatcher union(MethodMatcher mm1, ClreplacedFilter cf1, MethodMatcher mm2, ClreplacedFilter cf2) {
return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new ClreplacedFilterAwareUnionIntroductionAwareMethodMatcher(mm1, cf1, mm2, cf2) : new ClreplacedFilterAwareUnionMethodMatcher(mm1, cf1, mm2, cf2));
}
18
Source : ComposablePointcut.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Convenient clreplaced for building up pointcuts. All methods return
* ComposablePointcut, so we can use a concise idiom like:
*
* {@code
* Pointcut pc = new ComposablePointcut().union(clreplacedFilter).intersection(methodMatcher).intersection(pointcut);
* }
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Rob Harrop
* @since 11.11.2003
* @see Pointcuts
*/
public clreplaced ComposablePointcut implements Pointcut, Serializable {
/**
* use serialVersionUID from Spring 1.2 for interoperability.
*/
private static final long serialVersionUID = -2743223737633663832L;
private ClreplacedFilter clreplacedFilter;
private MethodMatcher methodMatcher;
/**
* Create a default ComposablePointcut, with {@code ClreplacedFilter.TRUE}
* and {@code MethodMatcher.TRUE}.
*/
public ComposablePointcut() {
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut based on the given Pointcut.
* @param pointcut the original Pointcut
*/
public ComposablePointcut(Pointcut pointcut) {
replacedert.notNull(pointcut, "Pointcut must not be null");
this.clreplacedFilter = pointcut.getClreplacedFilter();
this.methodMatcher = pointcut.getMethodMatcher();
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter,
* with {@code MethodMatcher.TRUE}.
* @param clreplacedFilter the ClreplacedFilter to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut for the given MethodMatcher,
* with {@code ClreplacedFilter.TRUE}.
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(MethodMatcher methodMatcher) {
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = methodMatcher;
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter and MethodMatcher.
* @param clreplacedFilter the ClreplacedFilter to use
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter, MethodMatcher methodMatcher) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = methodMatcher;
}
/**
* Apply a union with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other);
return this;
}
/**
* Apply an intersection with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other);
return this;
}
/**
* Apply a union with the given MethodMatcher.
* @param other the MethodMatcher to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(MethodMatcher other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, other);
return this;
}
/**
* Apply an intersection with the given MethodMatcher.
* @param other the MethodMatcher to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(MethodMatcher other) {
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other);
return this;
}
/**
* Apply a union with the given Pointcut.
* <p>Note that for a Pointcut union, methods will only match if their
* original ClreplacedFilter (from the originating Pointcut) matches as well.
* MethodMatchers and ClreplacedFilters from different Pointcuts will never
* get interleaved with each other.
* @param other the Pointcut to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(Pointcut other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, this.clreplacedFilter, other.getMethodMatcher(), other.getClreplacedFilter());
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other.getClreplacedFilter());
return this;
}
/**
* Apply an intersection with the given Pointcut.
* @param other the Pointcut to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(Pointcut other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other.getClreplacedFilter());
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher());
return this;
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ComposablePointcut)) {
return false;
}
ComposablePointcut otherPointcut = (ComposablePointcut) other;
return (this.clreplacedFilter.equals(otherPointcut.clreplacedFilter) && this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@Override
public int hashCode() {
return this.clreplacedFilter.hashCode() * 37 + this.methodMatcher.hashCode();
}
@Override
public String toString() {
return "ComposablePointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
}
18
Source : AnnotationMatchingPointcut.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Simple Pointcut that looks for a specific Java 5 annotation
* being present on a {@link #forClreplacedAnnotation clreplaced} or
* {@link #forMethodAnnotation method}.
*
* @author Juergen Hoeller
* @since 2.0
* @see AnnotationClreplacedFilter
* @see AnnotationMethodMatcher
*/
public clreplaced AnnotationMatchingPointcut implements Pointcut {
private final ClreplacedFilter clreplacedFilter;
private final MethodMatcher methodMatcher;
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType) {
this(clreplacedAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType, boolean checkInherited) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType) {
this(clreplacedAnnotationType, methodAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @since 5.0
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
* @see AnnotationMethodMatcher#AnnotationMethodMatcher(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType, boolean checkInherited) {
replacedert.isTrue((clreplacedAnnotationType != null || methodAnnotationType != null), "Either Clreplaced annotation type or Method annotation type needs to be specified (or both)");
if (clreplacedAnnotationType != null) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
} else {
this.clreplacedFilter = new AnnotationCandidateClreplacedFilter(methodAnnotationType);
}
if (methodAnnotationType != null) {
this.methodMatcher = new AnnotationMethodMatcher(methodAnnotationType, checkInherited);
} else {
this.methodMatcher = MethodMatcher.TRUE;
}
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut)) {
return false;
}
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
return (this.clreplacedFilter.equals(otherPointcut.clreplacedFilter) && this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@Override
public int hashCode() {
return this.clreplacedFilter.hashCode() * 37 + this.methodMatcher.hashCode();
}
@Override
public String toString() {
return "AnnotationMatchingPointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the clreplaced level.
* @param annotationType the annotation type to look for at the clreplaced level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forClreplacedAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(annotationType);
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the method level.
* @param annotationType the annotation type to look for at the method level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forMethodAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(null, annotationType);
}
/**
* {@link ClreplacedFilter} that delegates to {@link AnnotationUtils#isCandidateClreplaced}
* for filtering clreplacedes whose methods are not worth searching to begin with.
*/
private static clreplaced AnnotationCandidateClreplacedFilter implements ClreplacedFilter {
private final Clreplaced<? extends Annotation> annotationType;
public AnnotationCandidateClreplacedFilter(Clreplaced<? extends Annotation> annotationType) {
this.annotationType = annotationType;
}
@Override
public boolean matches(Clreplaced<?> clazz) {
return AnnotationUtils.isCandidateClreplaced(clazz, this.annotationType);
}
}
}
18
Source : InterceptorAndDynamicMethodMatcher.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Internal framework clreplaced, combining a MethodInterceptor instance
* with a MethodMatcher for use as an element in the advisor chain.
*
* @author Rod Johnson
*/
clreplaced InterceptorAndDynamicMethodMatcher {
final MethodInterceptor interceptor;
final MethodMatcher methodMatcher;
public InterceptorAndDynamicMethodMatcher(MethodInterceptor interceptor, MethodMatcher methodMatcher) {
this.interceptor = interceptor;
this.methodMatcher = methodMatcher;
}
}
18
Source : AspectJExpressionPointcutTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
private void replacedertMatchesGetAge(MethodMatcher methodMatcher) {
replacedertThat(methodMatcher.matches(getAge, TestBean.clreplaced)).as("Expression should match getAge() method").isTrue();
}
18
Source : ComposablePointcut.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
/**
* Convenient clreplaced for building up pointcuts.
*
* <p>All methods return {@code ComposablePointcut}, so we can use concise idioms
* like in the following example.
*
* <pre clreplaced="code">Pointcut pc = new ComposablePointcut()
* .union(clreplacedFilter)
* .intersection(methodMatcher)
* .intersection(pointcut);</pre>
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Rob Harrop
* @since 11.11.2003
* @see Pointcuts
*/
public clreplaced ComposablePointcut implements Pointcut, Serializable {
/**
* use serialVersionUID from Spring 1.2 for interoperability.
*/
private static final long serialVersionUID = -2743223737633663832L;
private ClreplacedFilter clreplacedFilter;
private MethodMatcher methodMatcher;
/**
* Create a default ComposablePointcut, with {@code ClreplacedFilter.TRUE}
* and {@code MethodMatcher.TRUE}.
*/
public ComposablePointcut() {
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut based on the given Pointcut.
* @param pointcut the original Pointcut
*/
public ComposablePointcut(Pointcut pointcut) {
replacedert.notNull(pointcut, "Pointcut must not be null");
this.clreplacedFilter = pointcut.getClreplacedFilter();
this.methodMatcher = pointcut.getMethodMatcher();
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter,
* with {@code MethodMatcher.TRUE}.
* @param clreplacedFilter the ClreplacedFilter to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut for the given MethodMatcher,
* with {@code ClreplacedFilter.TRUE}.
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(MethodMatcher methodMatcher) {
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = methodMatcher;
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter and MethodMatcher.
* @param clreplacedFilter the ClreplacedFilter to use
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter, MethodMatcher methodMatcher) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = methodMatcher;
}
/**
* Apply a union with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other);
return this;
}
/**
* Apply an intersection with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other);
return this;
}
/**
* Apply a union with the given MethodMatcher.
* @param other the MethodMatcher to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(MethodMatcher other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, other);
return this;
}
/**
* Apply an intersection with the given MethodMatcher.
* @param other the MethodMatcher to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(MethodMatcher other) {
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other);
return this;
}
/**
* Apply a union with the given Pointcut.
* <p>Note that for a Pointcut union, methods will only match if their
* original ClreplacedFilter (from the originating Pointcut) matches as well.
* MethodMatchers and ClreplacedFilters from different Pointcuts will never
* get interleaved with each other.
* @param other the Pointcut to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(Pointcut other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, this.clreplacedFilter, other.getMethodMatcher(), other.getClreplacedFilter());
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other.getClreplacedFilter());
return this;
}
/**
* Apply an intersection with the given Pointcut.
* @param other the Pointcut to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(Pointcut other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other.getClreplacedFilter());
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher());
return this;
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ComposablePointcut)) {
return false;
}
ComposablePointcut otherPointcut = (ComposablePointcut) other;
return (this.clreplacedFilter.equals(otherPointcut.clreplacedFilter) && this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@Override
public int hashCode() {
return this.clreplacedFilter.hashCode() * 37 + this.methodMatcher.hashCode();
}
@Override
public String toString() {
return getClreplaced().getName() + ": " + this.clreplacedFilter + ", " + this.methodMatcher;
}
}
18
Source : AnnotationMatchingPointcut.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
/**
* Simple Pointcut that looks for a specific Java 5 annotation
* being present on a {@link #forClreplacedAnnotation clreplaced} or
* {@link #forMethodAnnotation method}.
*
* @author Juergen Hoeller
* @author Sam Brannen
* @since 2.0
* @see AnnotationClreplacedFilter
* @see AnnotationMethodMatcher
*/
public clreplaced AnnotationMatchingPointcut implements Pointcut {
private final ClreplacedFilter clreplacedFilter;
private final MethodMatcher methodMatcher;
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType) {
this(clreplacedAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType, boolean checkInherited) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation types.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType) {
this(clreplacedAnnotationType, methodAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation types.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @since 5.0
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
* @see AnnotationMethodMatcher#AnnotationMethodMatcher(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType, boolean checkInherited) {
replacedert.isTrue((clreplacedAnnotationType != null || methodAnnotationType != null), "Either Clreplaced annotation type or Method annotation type needs to be specified (or both)");
if (clreplacedAnnotationType != null) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
} else {
this.clreplacedFilter = new AnnotationCandidateClreplacedFilter(methodAnnotationType);
}
if (methodAnnotationType != null) {
this.methodMatcher = new AnnotationMethodMatcher(methodAnnotationType, checkInherited);
} else {
this.methodMatcher = MethodMatcher.TRUE;
}
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut)) {
return false;
}
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
return (this.clreplacedFilter.equals(otherPointcut.clreplacedFilter) && this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@Override
public int hashCode() {
return this.clreplacedFilter.hashCode() * 37 + this.methodMatcher.hashCode();
}
@Override
public String toString() {
return "AnnotationMatchingPointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the clreplaced level.
* @param annotationType the annotation type to look for at the clreplaced level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forClreplacedAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(annotationType);
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the method level.
* @param annotationType the annotation type to look for at the method level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forMethodAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(null, annotationType);
}
/**
* {@link ClreplacedFilter} that delegates to {@link AnnotationUtils#isCandidateClreplaced}
* for filtering clreplacedes whose methods are not worth searching to begin with.
* @since 5.2
*/
private static clreplaced AnnotationCandidateClreplacedFilter implements ClreplacedFilter {
private final Clreplaced<? extends Annotation> annotationType;
AnnotationCandidateClreplacedFilter(Clreplaced<? extends Annotation> annotationType) {
this.annotationType = annotationType;
}
@Override
public boolean matches(Clreplaced<?> clazz) {
return AnnotationUtils.isCandidateClreplaced(clazz, this.annotationType);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof AnnotationCandidateClreplacedFilter)) {
return false;
}
AnnotationCandidateClreplacedFilter that = (AnnotationCandidateClreplacedFilter) obj;
return this.annotationType.equals(that.annotationType);
}
@Override
public int hashCode() {
return this.annotationType.hashCode();
}
@Override
public String toString() {
return getClreplaced().getName() + ": " + this.annotationType;
}
}
}
18
Source : AnnotationMatchingPointcut.java
with MIT License
from mindcarver
with MIT License
from mindcarver
/**
* Simple Pointcut that looks for a specific Java 5 annotation
* being present on a {@link #forClreplacedAnnotation clreplaced} or
* {@link #forMethodAnnotation method}.
*
* @author Juergen Hoeller
* @since 2.0
* @see AnnotationClreplacedFilter
* @see AnnotationMethodMatcher
*/
public clreplaced AnnotationMatchingPointcut implements Pointcut {
private final ClreplacedFilter clreplacedFilter;
private final MethodMatcher methodMatcher;
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType) {
this(clreplacedAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType, boolean checkInherited) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType) {
this(clreplacedAnnotationType, methodAnnotationType, false);
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
* @param checkInherited whether to also check the superclreplacedes and interfaces
* as well as meta-annotations for the annotation type
* @since 5.0
* @see AnnotationClreplacedFilter#AnnotationClreplacedFilter(Clreplaced, boolean)
* @see AnnotationMethodMatcher#AnnotationMethodMatcher(Clreplaced, boolean)
*/
public AnnotationMatchingPointcut(@Nullable Clreplaced<? extends Annotation> clreplacedAnnotationType, @Nullable Clreplaced<? extends Annotation> methodAnnotationType, boolean checkInherited) {
replacedert.isTrue((clreplacedAnnotationType != null || methodAnnotationType != null), "Either Clreplaced annotation type or Method annotation type needs to be specified (or both)");
if (clreplacedAnnotationType != null) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
} else {
this.clreplacedFilter = ClreplacedFilter.TRUE;
}
if (methodAnnotationType != null) {
this.methodMatcher = new AnnotationMethodMatcher(methodAnnotationType, checkInherited);
} else {
this.methodMatcher = MethodMatcher.TRUE;
}
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut)) {
return false;
}
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
return (this.clreplacedFilter.equals(otherPointcut.clreplacedFilter) && this.methodMatcher.equals(otherPointcut.methodMatcher));
}
@Override
public int hashCode() {
return this.clreplacedFilter.hashCode() * 37 + this.methodMatcher.hashCode();
}
@Override
public String toString() {
return "AnnotationMatchingPointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the clreplaced level.
* @param annotationType the annotation type to look for at the clreplaced level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forClreplacedAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(annotationType);
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the method level.
* @param annotationType the annotation type to look for at the method level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forMethodAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(null, annotationType);
}
}
18
Source : MethodMatchers.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Match all methods that <i>either</i> (or both) of the given MethodMatchers matches.
* @param mm1 the first MethodMatcher
* @param cf1 the corresponding ClreplacedFilter for the first MethodMatcher
* @param mm2 the second MethodMatcher
* @param cf2 the corresponding ClreplacedFilter for the second MethodMatcher
* @return a distinct MethodMatcher that matches all methods that either
* of the given MethodMatchers matches
*/
static MethodMatcher union(MethodMatcher mm1, ClreplacedFilter cf1, MethodMatcher mm2, ClreplacedFilter cf2) {
return new ClreplacedFilterAwareUnionMethodMatcher(mm1, cf1, mm2, cf2);
}
18
Source : ComposablePointcut.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Convenient clreplaced for building up pointcuts. All methods return
* ComposablePointcut, so we can use a concise idiom like:
*
* {@code
* Pointcut pc = new ComposablePointcut().union(clreplacedFilter).intersection(methodMatcher).intersection(pointcut);
* }
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Rob Harrop
* @since 11.11.2003
* @see Pointcuts
*/
public clreplaced ComposablePointcut implements Pointcut, Serializable {
/**
* use serialVersionUID from Spring 1.2 for interoperability
*/
private static final long serialVersionUID = -2743223737633663832L;
private ClreplacedFilter clreplacedFilter;
private MethodMatcher methodMatcher;
/**
* Create a default ComposablePointcut, with {@code ClreplacedFilter.TRUE}
* and {@code MethodMatcher.TRUE}.
*/
public ComposablePointcut() {
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut based on the given Pointcut.
* @param pointcut the original Pointcut
*/
public ComposablePointcut(Pointcut pointcut) {
replacedert.notNull(pointcut, "Pointcut must not be null");
this.clreplacedFilter = pointcut.getClreplacedFilter();
this.methodMatcher = pointcut.getMethodMatcher();
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter,
* with {@code MethodMatcher.TRUE}.
* @param clreplacedFilter the ClreplacedFilter to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a ComposablePointcut for the given MethodMatcher,
* with {@code ClreplacedFilter.TRUE}.
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(MethodMatcher methodMatcher) {
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = ClreplacedFilter.TRUE;
this.methodMatcher = methodMatcher;
}
/**
* Create a ComposablePointcut for the given ClreplacedFilter and MethodMatcher.
* @param clreplacedFilter the ClreplacedFilter to use
* @param methodMatcher the MethodMatcher to use
*/
public ComposablePointcut(ClreplacedFilter clreplacedFilter, MethodMatcher methodMatcher) {
replacedert.notNull(clreplacedFilter, "ClreplacedFilter must not be null");
replacedert.notNull(methodMatcher, "MethodMatcher must not be null");
this.clreplacedFilter = clreplacedFilter;
this.methodMatcher = methodMatcher;
}
/**
* Apply a union with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other);
return this;
}
/**
* Apply an intersection with the given ClreplacedFilter.
* @param other the ClreplacedFilter to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(ClreplacedFilter other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other);
return this;
}
/**
* Apply a union with the given MethodMatcher.
* @param other the MethodMatcher to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(MethodMatcher other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, other);
return this;
}
/**
* Apply an intersection with the given MethodMatcher.
* @param other the MethodMatcher to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(MethodMatcher other) {
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other);
return this;
}
/**
* Apply a union with the given Pointcut.
* <p>Note that for a Pointcut union, methods will only match if their
* original ClreplacedFilter (from the originating Pointcut) matches as well.
* MethodMatchers and ClreplacedFilters from different Pointcuts will never
* get interleaved with each other.
* @param other the Pointcut to apply a union with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut union(Pointcut other) {
this.methodMatcher = MethodMatchers.union(this.methodMatcher, this.clreplacedFilter, other.getMethodMatcher(), other.getClreplacedFilter());
this.clreplacedFilter = ClreplacedFilters.union(this.clreplacedFilter, other.getClreplacedFilter());
return this;
}
/**
* Apply an intersection with the given Pointcut.
* @param other the Pointcut to apply an intersection with
* @return this composable pointcut (for call chaining)
*/
public ComposablePointcut intersection(Pointcut other) {
this.clreplacedFilter = ClreplacedFilters.intersection(this.clreplacedFilter, other.getClreplacedFilter());
this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher());
return this;
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ComposablePointcut)) {
return false;
}
ComposablePointcut that = (ComposablePointcut) other;
return ObjectUtils.nullSafeEquals(that.clreplacedFilter, this.clreplacedFilter) && ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
}
@Override
public int hashCode() {
int code = 17;
if (this.clreplacedFilter != null) {
code = 37 * code + this.clreplacedFilter.hashCode();
}
if (this.methodMatcher != null) {
code = 37 * code + this.methodMatcher.hashCode();
}
return code;
}
@Override
public String toString() {
return "ComposablePointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
}
18
Source : AnnotationMatchingPointcut.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Simple Pointcut that looks for a specific Java 5 annotation
* being present on a {@link #forClreplacedAnnotation clreplaced} or
* {@link #forMethodAnnotation method}.
*
* @author Juergen Hoeller
* @since 2.0
* @see AnnotationClreplacedFilter
* @see AnnotationMethodMatcher
*/
public clreplaced AnnotationMatchingPointcut implements Pointcut {
private final ClreplacedFilter clreplacedFilter;
private final MethodMatcher methodMatcher;
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType);
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* @param checkInherited whether to explicitly check the superclreplacedes and
* interfaces for the annotation type as well (even if the annotation type
* is not marked as inherited itself)
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType, boolean checkInherited) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType, checkInherited);
this.methodMatcher = MethodMatcher.TRUE;
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* @param clreplacedAnnotationType the annotation type to look for at the clreplaced level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
* (can be {@code null})
*/
public AnnotationMatchingPointcut(Clreplaced<? extends Annotation> clreplacedAnnotationType, Clreplaced<? extends Annotation> methodAnnotationType) {
replacedert.isTrue((clreplacedAnnotationType != null || methodAnnotationType != null), "Either Clreplaced annotation type or Method annotation type needs to be specified (or both)");
if (clreplacedAnnotationType != null) {
this.clreplacedFilter = new AnnotationClreplacedFilter(clreplacedAnnotationType);
} else {
this.clreplacedFilter = ClreplacedFilter.TRUE;
}
if (methodAnnotationType != null) {
this.methodMatcher = new AnnotationMethodMatcher(methodAnnotationType);
} else {
this.methodMatcher = MethodMatcher.TRUE;
}
}
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
@Override
public MethodMatcher getMethodMatcher() {
return this.methodMatcher;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationMatchingPointcut)) {
return false;
}
AnnotationMatchingPointcut that = (AnnotationMatchingPointcut) other;
return ObjectUtils.nullSafeEquals(that.clreplacedFilter, this.clreplacedFilter) && ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
}
@Override
public int hashCode() {
int code = 17;
if (this.clreplacedFilter != null) {
code = 37 * code + this.clreplacedFilter.hashCode();
}
if (this.methodMatcher != null) {
code = 37 * code + this.methodMatcher.hashCode();
}
return code;
}
@Override
public String toString() {
return "AnnotationMatchingPointcut: " + this.clreplacedFilter + ", " + this.methodMatcher;
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the clreplaced level.
* @param annotationType the annotation type to look for at the clreplaced level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forClreplacedAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(annotationType);
}
/**
* Factory method for an AnnotationMatchingPointcut that matches
* for the specified annotation at the method level.
* @param annotationType the annotation type to look for at the method level
* @return the corresponding AnnotationMatchingPointcut
*/
public static AnnotationMatchingPointcut forMethodAnnotation(Clreplaced<? extends Annotation> annotationType) {
replacedert.notNull(annotationType, "Annotation type must not be null");
return new AnnotationMatchingPointcut(null, annotationType);
}
}
17
Source : MethodMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Apply the given MethodMatcher to the given Method, supporting an
* {@link org.springframework.aop.IntroductionAwareMethodMatcher}
* (if applicable).
* @param mm the MethodMatcher to apply (may be an IntroductionAwareMethodMatcher)
* @param method the candidate method
* @param targetClreplaced the target clreplaced
* @param hasIntroductions {@code true} if the object on whose behalf we are
* asking is the subject on one or more introductions; {@code false} otherwise
* @return whether or not this method matches statically
*/
public static boolean matches(MethodMatcher mm, Method method, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
replacedert.notNull(mm, "MethodMatcher must not be null");
return (mm instanceof IntroductionAwareMethodMatcher ? ((IntroductionAwareMethodMatcher) mm).matches(method, targetClreplaced, hasIntroductions) : mm.matches(method, targetClreplaced));
}
17
Source : MethodMatchers.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Apply the given MethodMatcher to the given Method, supporting an
* {@link org.springframework.aop.IntroductionAwareMethodMatcher}
* (if applicable).
* @param mm the MethodMatcher to apply (may be an IntroductionAwareMethodMatcher)
* @param method the candidate method
* @param targetClreplaced the target clreplaced (may be {@code null}, in which case
* the candidate clreplaced must be taken to be the method's declaring clreplaced)
* @param hasIntroductions {@code true} if the object on whose behalf we are
* asking is the subject on one or more introductions; {@code false} otherwise
* @return whether or not this method matches statically
*/
public static boolean matches(MethodMatcher mm, Method method, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
replacedert.notNull(mm, "MethodMatcher must not be null");
return ((mm instanceof IntroductionAwareMethodMatcher && ((IntroductionAwareMethodMatcher) mm).matches(method, targetClreplaced, hasIntroductions)) || mm.matches(method, targetClreplaced));
}
17
Source : MyPointCut.java
with Apache License 2.0
from huifer
with Apache License 2.0
from huifer
/**
* 描述:
*
* @author huifer
* @date 2019-03-03
*/
@Setter
public clreplaced MyPointCut implements Pointcut {
/**
* 类型过滤器
*/
private ClreplacedFilter clreplacedFilter;
/**
* 方法过滤器
*/
private MethodMatcher matcher;
/**
* @return 返回类过滤器
*/
@Override
public ClreplacedFilter getClreplacedFilter() {
return this.clreplacedFilter;
}
/**
* @return 返回方法过滤器
*/
@Override
public MethodMatcher getMethodMatcher() {
return this.matcher;
}
}
16
Source : MethodMatchersTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testSingle() throws Exception {
MethodMatcher defaultMm = MethodMatcher.TRUE;
replacedertTrue(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced));
replacedertTrue(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
defaultMm = MethodMatchers.intersection(defaultMm, new StartsWithMatcher("get"));
replacedertTrue(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced));
replacedertFalse(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
}
16
Source : MethodMatchersTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testStaticMethodMatcherUnion() throws Exception {
MethodMatcher getterMatcher = new StartsWithMatcher("get");
MethodMatcher setterMatcher = new StartsWithMatcher("set");
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
replacedertFalse("Union is a static matcher", union.isRuntime());
replacedertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
replacedertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.clreplaced));
replacedertFalse("Didn't matched absquatulate method", union.matches(IOTHER_ABSQUATULATE, TestBean.clreplaced));
}
16
Source : MethodMatchersTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testUnionEquals() {
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
replacedertTrue(first.equals(second));
replacedertTrue(second.equals(first));
}
16
Source : MethodMatchersTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testDefaultMatchesAll() throws Exception {
MethodMatcher defaultMm = MethodMatcher.TRUE;
replacedertTrue(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced));
replacedertTrue(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
}
16
Source : AbstractAspectJAdvice.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Build a 'safe' pointcut that excludes the AspectJ advice method itself.
* @return a composable pointcut that builds on the original AspectJ expression pointcut
* @see #getPointcut()
*/
public final Pointcut buildSafePointcut() {
Pointcut pc = getPointcut();
MethodMatcher safeMethodMatcher = MethodMatchers.intersection(new AdviceExcludingMethodMatcher(this.aspectJAdviceMethod), pc.getMethodMatcher());
return new ComposablePointcut(pc.getClreplacedFilter(), safeMethodMatcher);
}
16
Source : MethodMatchersTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testStaticMethodMatcherUnion() throws Exception {
MethodMatcher getterMatcher = new StartsWithMatcher("get");
MethodMatcher setterMatcher = new StartsWithMatcher("set");
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
replacedertThat(union.isRuntime()).as("Union is a static matcher").isFalse();
replacedertThat(union.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).as("Matched setAge method").isTrue();
replacedertThat(union.matches(ITESTBEAN_GETAGE, TestBean.clreplaced)).as("Matched getAge method").isTrue();
replacedertThat(union.matches(IOTHER_ABSQUATULATE, TestBean.clreplaced)).as("Didn't matched absquatulate method").isFalse();
}
16
Source : MethodMatchersTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testUnionEquals() {
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
replacedertThat(first.equals(second)).isTrue();
replacedertThat(second.equals(first)).isTrue();
}
16
Source : MethodMatchersTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testSingle() throws Exception {
MethodMatcher defaultMm = MethodMatcher.TRUE;
replacedertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced)).isTrue();
replacedertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).isTrue();
defaultMm = MethodMatchers.intersection(defaultMm, new StartsWithMatcher("get"));
replacedertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced)).isTrue();
replacedertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).isFalse();
}
16
Source : MethodMatchersTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testDefaultMatchesAll() throws Exception {
MethodMatcher defaultMm = MethodMatcher.TRUE;
replacedertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.clreplaced)).isTrue();
replacedertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).isTrue();
}
15
Source : MethodMatchersTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testDynamicAndStaticMethodMatcherIntersection() throws Exception {
MethodMatcher mm1 = MethodMatcher.TRUE;
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
replacedertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
replacedertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
replacedertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Integer(5)));
// Knock out dynamic part
intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
replacedertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
replacedertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
replacedertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Integer(5)));
}
15
Source : MethodMatchersTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testDynamicAndStaticMethodMatcherIntersection() throws Exception {
MethodMatcher mm1 = MethodMatcher.TRUE;
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
replacedertThat(intersection.isRuntime()).as("Intersection is a dynamic matcher").isTrue();
replacedertThat(intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).as("2Matched setAge method").isTrue();
replacedertThat(intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Integer(5))).as("3Matched setAge method").isTrue();
// Knock out dynamic part
intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
replacedertThat(intersection.isRuntime()).as("Intersection is a dynamic matcher").isTrue();
replacedertThat(intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced)).as("2Matched setAge method").isTrue();
replacedertThat(intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Integer(5))).as("3 - not Matched setAge method").isFalse();
}
15
Source : AbstractRegistryCenter.java
with Apache License 2.0
from lxchinesszz
with Apache License 2.0
from lxchinesszz
/**
* @author liuxin
* @version Id: AbstractRegistryCenter.java, v 0.1 2019-04-23 10:17
*/
@Slf4j
public abstract clreplaced AbstractRegistryCenter implements RegistryCenter, BeanFactoryAware {
@Autowired
protected NameSpaceHandler nameSpaceHandler;
private BeanFactory beanFactory;
private MethodMatcher methodMatcher;
@PostConstruct
public void initMethodMater() {
methodMatcher = AnnotationMatchingPointcut.forMethodAnnotation(EasySentinel.clreplaced).getMethodMatcher();
}
@Override
public String getNameSpace() {
return nameSpaceHandler.getNameSpace();
}
@Override
public String getServiceName() {
return nameSpaceHandler.getAppName();
}
@Override
public void registry() {
String nameSpace = nameSpaceHandler.getNameSpace();
String serverHost = nameSpaceHandler.getServerHost();
EasySentinelInstance easySentinelInstance = buildEasySentinelInstance();
log.info("local easySentinelInstance:{}", prettyPrint(easySentinelInstance));
doRegistry(pullResource(), easySentinelInstance);
log.info("{},in {} registry success,easySentinelInstance", nameSpace, serverHost);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
public EasySentinelInstance buildEasySentinelInstance() {
EasySentinelInstance esi = new EasySentinelInstance(nameSpaceHandler.getAppName(), nameSpaceHandler.getServerHost());
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) this.beanFactory;
buildEasySentinelInstance(esi, beanFactory.getBeanNamesForAnnotation(Controller.clreplaced));
return esi;
}
private void buildEasySentinelInstance(EasySentinelInstance esi, String[] controllerBeanNames) {
for (int i = 0; i < controllerBeanNames.length; i++) {
String controllerBeanName = controllerBeanNames[i];
Object bean = beanFactory.getBean(controllerBeanName);
Method[] methods = bean.getClreplaced().getSuperclreplaced().getMethods();
Stream<Method> methodStream = Arrays.stream(methods).filter(m -> methodMatcher.matches(m, bean.getClreplaced()));
methodStream.forEach(m -> {
EasySentinel easySentinel = AnnotationUtils.getAnnotation(m, EasySentinel.clreplaced);
if (null != easySentinel) {
String resourceName = easySentinel.resourceName();
if (StringUtils.isEmpty(resourceName)) {
resourceName = NameSpaceHandler.getResourceName(m);
}
esi.setCover(easySentinel.cover());
esi.addResourceName(new ResourceNameMeta(easySentinel.Qps(), resourceName, NameSpaceHandler.getResourceName(m)));
}
});
}
}
protected String toGson(ResourceMetaInfo resourceMetaInfo) {
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.disableHtmlEscaping().create();
return gson.toJson(resourceMetaInfo);
}
protected String prettyPrint(Object object) {
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.disableHtmlEscaping().setPrettyPrinting().create();
return gson.toJson(object);
}
@Override
public abstract ResourceMetaInfo pullResource();
public abstract void doRegistry(ResourceMetaInfo resourceMetaInfo, EasySentinelInstance easySentinelInstance);
}
15
Source : MethodMatchersTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testDynamicAndStaticMethodMatcherIntersection() throws Exception {
MethodMatcher mm1 = MethodMatcher.TRUE;
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
replacedertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
replacedertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
replacedertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Object[] { new Integer(5) }));
// Knock out dynamic part
intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
replacedertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
replacedertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced));
replacedertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.clreplaced, new Object[] { new Integer(5) }));
}
13
Source : Pointcuts.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Perform the least expensive check for a pointcut match.
* @param pointcut the pointcut to match
* @param method the candidate method
* @param targetClreplaced the target clreplaced
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Clreplaced<?> targetClreplaced, Object... args) {
replacedert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
}
if (pointcut.getClreplacedFilter().matches(targetClreplaced)) {
// Only check if it gets past first hurdle.
MethodMatcher mm = pointcut.getMethodMatcher();
if (mm.matches(method, targetClreplaced)) {
// We may need additional runtime (argument) check.
return (!mm.isRuntime() || mm.matches(method, targetClreplaced, args));
}
}
return false;
}
13
Source : Pointcuts.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Perform the least expensive check for a pointcut match.
* @param pointcut the pointcut to match
* @param method the candidate method
* @param targetClreplaced the target clreplaced
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Clreplaced<?> targetClreplaced, Object[] args) {
replacedert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
}
if (pointcut.getClreplacedFilter().matches(targetClreplaced)) {
// Only check if it gets past first hurdle.
MethodMatcher mm = pointcut.getMethodMatcher();
if (mm.matches(method, targetClreplaced)) {
// We may need additional runtime (argument) check.
return (!mm.isRuntime() || mm.matches(method, targetClreplaced, args));
}
}
return false;
}
12
Source : AspectJExpressionPointcutTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertTrue("Should match with setSomeNumber with Double input", methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Double(12)));
replacedertFalse("Should not match setSomeNumber with Integer input", methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Integer(11)));
replacedertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.clreplaced));
replacedertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
12
Source : AspectJExpressionPointcutTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testMatchWithTypePattern() throws Exception {
String expression = "execution(* *..TestBean.*Age(..))";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertFalse("Should not be a runtime match", methodMatcher.isRuntime());
replacedertMatchesGetAge(methodMatcher);
replacedertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.clreplaced));
}
12
Source : AspectJExpressionPointcutTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertFalse("Should not be a runtime match", methodMatcher.isRuntime());
replacedertMatchesGetAge(methodMatcher);
replacedertFalse("Expression should match setAge() method", methodMatcher.matches(setAge, TestBean.clreplaced));
}
12
Source : AopUtils.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Can the given pointcut apply at all on the given clreplaced?
* <p>This is an important test as it can be used to optimize
* out a pointcut for a clreplaced.
* @param pc the static or dynamic pointcut to check
* @param targetClreplaced the clreplaced to test
* @param hasIntroductions whether or not the advisor chain
* for this bean includes any introductions
* @return whether the pointcut can apply on any method
*/
public static boolean canApply(Pointcut pc, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
replacedert.notNull(pc, "Pointcut must not be null");
if (!pc.getClreplacedFilter().matches(targetClreplaced)) {
return false;
}
// 从切点对象中获取需要匹配的方法
MethodMatcher methodMatcher = pc.getMethodMatcher();
if (methodMatcher == MethodMatcher.TRUE) {
// No need to iterate the methods if we're matching any method anyway...
return true;
}
IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null;
if (methodMatcher instanceof IntroductionAwareMethodMatcher) {
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
}
Set<Clreplaced<?>> clreplacedes = new LinkedHashSet<>();
if (!Proxy.isProxyClreplaced(targetClreplaced)) {
clreplacedes.add(ClreplacedUtils.getUserClreplaced(targetClreplaced));
}
clreplacedes.addAll(ClreplacedUtils.getAllInterfacesForClreplacedreplacedet(targetClreplaced));
for (Clreplaced<?> clazz : clreplacedes) {
Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz);
for (Method method : methods) {
if (introductionAwareMethodMatcher != null ? introductionAwareMethodMatcher.matches(method, targetClreplaced, hasIntroductions) : methodMatcher.matches(method, targetClreplaced)) {
return true;
}
}
}
return false;
}
12
Source : AspectJExpressionPointcutTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testMatchWithTypePattern() throws Exception {
String expression = "execution(* *..TestBean.*Age(..))";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertThat(methodMatcher.isRuntime()).as("Should not be a runtime match").isFalse();
replacedertMatchesGetAge(methodMatcher);
replacedertThat(methodMatcher.matches(setAge, TestBean.clreplaced)).as("Expression should match setAge(int) method").isTrue();
}
12
Source : AspectJExpressionPointcutTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertThat(methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Double(12))).as("Should match with setSomeNumber with Double input").isTrue();
replacedertThat(methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Integer(11))).as("Should not match setSomeNumber with Integer input").isFalse();
replacedertThat(methodMatcher.matches(getAge, TestBean.clreplaced)).as("Should not match getAge").isFalse();
replacedertThat(methodMatcher.isRuntime()).as("Should be a runtime match").isTrue();
}
12
Source : AspectJExpressionPointcutTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertThat(methodMatcher.isRuntime()).as("Should not be a runtime match").isFalse();
replacedertMatchesGetAge(methodMatcher);
replacedertThat(methodMatcher.matches(setAge, TestBean.clreplaced)).as("Expression should match setAge() method").isFalse();
}
12
Source : AopUtils.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
/**
* Can the given pointcut apply at all on the given clreplaced?
* <p>This is an important test as it can be used to optimize
* out a pointcut for a clreplaced.
*
* @param pc the static or dynamic pointcut to check
* @param targetClreplaced the clreplaced to test
* @param hasIntroductions whether or not the advisor chain for this bean includes any
* introductions
* @return whether the pointcut can apply on any method
*/
public static boolean canApply(Pointcut pc, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
replacedert.notNull(pc, "Pointcut must not be null");
if (!pc.getClreplacedFilter().matches(targetClreplaced)) {
return false;
}
MethodMatcher methodMatcher = pc.getMethodMatcher();
if (methodMatcher == MethodMatcher.TRUE) {
// No need to iterate the methods if we're matching any method anyway...
return true;
}
IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null;
if (methodMatcher instanceof IntroductionAwareMethodMatcher) {
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
}
Set<Clreplaced<?>> clreplacedes = new LinkedHashSet<>();
if (!Proxy.isProxyClreplaced(targetClreplaced)) {
clreplacedes.add(ClreplacedUtils.getUserClreplaced(targetClreplaced));
}
clreplacedes.addAll(ClreplacedUtils.getAllInterfacesForClreplacedreplacedet(targetClreplaced));
for (Clreplaced<?> clazz : clreplacedes) {
Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz);
for (Method method : methods) {
if (introductionAwareMethodMatcher != null ? introductionAwareMethodMatcher.matches(method, targetClreplaced, hasIntroductions) : methodMatcher.matches(method, targetClreplaced)) {
return true;
}
}
}
return false;
}
12
Source : MethodMatchers.java
with Apache License 2.0
from newrelic
with Apache License 2.0
from newrelic
public static boolean matches(MethodMatcher mm, Method method, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
AgentBridge.getAgent().getLogger().log(Level.FINER, "spring-aop entry: {0}.{1}", targetClreplaced, method);
boolean matched = Weaver.callOriginal();
if (matched && targetClreplaced != null && !targetClreplaced.isInterface()) {
// Probably never an interface...
try {
Method concreteMethod = targetClreplaced.getDeclaredMethod(method.getName(), method.getParameterTypes());
Clreplaced<?> declaringClreplaced = concreteMethod.getDeclaringClreplaced();
String clreplacedName = declaringClreplaced.getName();
boolean coreClreplaced = clreplacedName == null || clreplacedName.startsWith("java") || clreplacedName.startsWith("javax") || clreplacedName.startsWith("sun") || clreplacedName.startsWith("com.sun");
if (!coreClreplaced) {
AgentBridge.instrumentation.instrument(concreteMethod, "Spring/Java/");
}
} catch (NoSuchMethodException e) {
} catch (Exception e) {
NewRelic.getAgent().getLogger().log(Level.FINER, "Spring AOP Instrumentation Error: {0}", e);
}
return matched;
} else {
return matched;
}
}
12
Source : AopUtils.java
with MIT License
from mindcarver
with MIT License
from mindcarver
/**
* Can the given pointcut apply at all on the given clreplaced?
* <p>This is an important test as it can be used to optimize
* out a pointcut for a clreplaced.
* @param pc the static or dynamic pointcut to check
* @param targetClreplaced the clreplaced to test
* @param hasIntroductions whether or not the advisor chain
* for this bean includes any introductions
* @return whether the pointcut can apply on any method
*/
public static boolean canApply(Pointcut pc, Clreplaced<?> targetClreplaced, boolean hasIntroductions) {
replacedert.notNull(pc, "Pointcut must not be null");
if (!pc.getClreplacedFilter().matches(targetClreplaced)) {
return false;
}
MethodMatcher methodMatcher = pc.getMethodMatcher();
if (methodMatcher == MethodMatcher.TRUE) {
// No need to iterate the methods if we're matching any method anyway...
return true;
}
IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null;
if (methodMatcher instanceof IntroductionAwareMethodMatcher) {
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
}
Set<Clreplaced<?>> clreplacedes = new LinkedHashSet<>();
if (!Proxy.isProxyClreplaced(targetClreplaced)) {
clreplacedes.add(ClreplacedUtils.getUserClreplaced(targetClreplaced));
}
clreplacedes.addAll(ClreplacedUtils.getAllInterfacesForClreplacedreplacedet(targetClreplaced));
for (Clreplaced<?> clazz : clreplacedes) {
Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz);
for (Method method : methods) {
if (introductionAwareMethodMatcher != null ? introductionAwareMethodMatcher.matches(method, targetClreplaced, hasIntroductions) : methodMatcher.matches(method, targetClreplaced)) {
return true;
}
}
}
return false;
}
12
Source : AspectJExpressionPointcutTests.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClreplacedFilter clreplacedFilter = pointcut.getClreplacedFilter();
MethodMatcher methodMatcher = pointcut.getMethodMatcher();
replacedertMatchesTestBeanClreplaced(clreplacedFilter);
// not currently testable in a reliable fashion
// replacedertDoesNotMatchStringClreplaced(clreplacedFilter);
replacedertTrue("Should match with setSomeNumber with Double input", methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Object[] { new Double(12) }));
replacedertFalse("Should not match setSomeNumber with Integer input", methodMatcher.matches(setSomeNumber, TestBean.clreplaced, new Object[] { new Integer(11) }));
replacedertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.clreplaced, null));
replacedertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
See More Examples