모든 매개 변수를 매개 변수로 허용하는 제네릭 메서드가 있습니다.
예를 들어, 메서드에 대한 호출을 매개 변수로 'String'유형으로 만 일치시키는 pointcut을 원합니다. 궁극적으로 요구 사항은 권고가 'String'매개 변수로 실행되는 범위를 제한하는 것입니다.AspecJ - 일반 매개 변수가있는 메서드와 일치하는 pointcut
public class Param<T> {
public T execute(T s){
return s;
}
}
Main 클래스 :
은 여기 내 일반적인 클래스와 방법 내 애플 부울 및 매개 변수로 문자열 모두이 방법으로 호출합니다.
public static void main(String[] args) {
Param<String> sp = new Param<String>();
String rs = sp.execute("myString"); //want a joint point
Param<Boolean> bp = new Param<Boolean>();
Boolean rb = bp.execute(true); //dont want a joint point
}
아래의 포인트 컷은 String 및 Boolean 매개 변수 모두에 유효합니다 (실제로 모든 유형에서 작동). 하지만 매개 변수가 String 유형 인 경우에만 메서드 호출을 가로 채기위한 pointcut을 원합니다. 사람 아래
@Pointcut("call(* com.amazon.auiqa.aspectj.generics.Param.execute(**))")
void param(){}
@Pointcut("execution(Object com.amazon.auiqa.aspectj.generics.Param.execute(Object))")
void param(){}
나를 위해 작동하지 않았다 : 내가 여기에 달성하기 위해 원하는 것을 달성 할 수있는 경우 궁금 해서요
@Pointcut("execution(String com.amazon.auiqa.aspectj.generics.Param.execute(String))")
@Pointcut("call(String com.amazon.auiqa.aspectj.generics.Param.execute(String))")
. 메서드 반환 형식을 사용하여 동일한 작업을 수행하고 싶습니다.
상기는 유사하다 일례이다. 실제 문제는 내 셀렌 테스트에 있습니다. 여러 가지 유형의 WebDriverWait.unitl (..) 호출이 있습니다. 예 : 'WebElement 요소 = new WebDriverWait (driver, timeOut) .until (ExpectedConditions.visibilityOfElementLocated (locator))); (ExpectedConditions.textToBePresentInElement (someElement, "someText")) .until 부울 isPresent = 새로운 WebDriverWait (드라이버, 제한 시간)' 나는 WebElment을 반환 단지 사람을 캡처하고 싶습니다. –