org.aspectj.weaver.tools.JoinPointMatch Java Examples

The following examples show how to use org.aspectj.weaver.tools.JoinPointMatch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AspectJExpressionPointcut.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm) {
	// Note: Can't use JoinPointMatch.getClass().getName() as the key, since
	// Spring AOP does all the matching at a join point, and then all the invocations
	// under this scenario, if we just use JoinPointMatch as the key, then
	// 'last man wins' which is not what we want at all.
	// Using the expression is guaranteed to be safe, since 2 identical expressions
	// are guaranteed to bind in exactly the same way.
	invocation.setUserAttribute(resolveExpression(), jpm);
}
 
Example #2
Source File: AbstractAspectJAdvice.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Get the current join point match at the join point we are being dispatched on.
 */
protected JoinPointMatch getJoinPointMatch() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	return getJoinPointMatch((ProxyMethodInvocation) mi);
}
 
Example #3
Source File: AspectJExpressionPointcut.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) {
	try {
		return this.primary.matchesJoinPoint(thisObject, targetObject, args);
	}
	catch (ReflectionWorldException ex) {
		return this.other.matchesJoinPoint(thisObject, targetObject, args);
	}
}
 
Example #4
Source File: AspectJExpressionPointcut.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm) {
	// Note: Can't use JoinPointMatch.getClass().getName() as the key, since
	// Spring AOP does all the matching at a join point, and then all the invocations
	// under this scenario, if we just use JoinPointMatch as the key, then
	// 'last man wins' which is not what we want at all.
	// Using the expression is guaranteed to be safe, since 2 identical expressions
	// are guaranteed to bind in exactly the same way.
	invocation.setUserAttribute(getExpression(), jpm);
}
 
Example #5
Source File: AspectJAroundAdvice.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
Example #6
Source File: AbstractAspectJAdvice.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the current join point match at the join point we are being dispatched on.
 */
protected JoinPointMatch getJoinPointMatch() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	return getJoinPointMatch((ProxyMethodInvocation) mi);
}
 
Example #7
Source File: AspectJExpressionPointcut.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) {
	try {
		return this.primary.matchesJoinPoint(thisObject, targetObject, args);
	}
	catch (ReflectionWorldException ex) {
		return this.other.matchesJoinPoint(thisObject, targetObject, args);
	}
}
 
Example #8
Source File: AspectJExpressionPointcut.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm) {
	// Note: Can't use JoinPointMatch.getClass().getName() as the key, since
	// Spring AOP does all the matching at a join point, and then all the invocations
	// under this scenario, if we just use JoinPointMatch as the key, then
	// 'last man wins' which is not what we want at all.
	// Using the expression is guaranteed to be safe, since 2 identical expressions
	// are guaranteed to bind in exactly the same way.
	invocation.setUserAttribute(getExpression(), jpm);
}
 
Example #9
Source File: AspectJAroundAdvice.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
Example #10
Source File: AbstractAspectJAdvice.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Get the current join point match at the join point we are being dispatched on.
 */
@Nullable
protected JoinPointMatch getJoinPointMatch() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	return getJoinPointMatch((ProxyMethodInvocation) mi);
}
 
Example #11
Source File: AspectJAroundAdvice.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
Example #12
Source File: AspectJExpressionPointcut.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) {
	try {
		return this.primary.matchesJoinPoint(thisObject, targetObject, args);
	}
	catch (ReflectionWorldException ex) {
		return this.other.matchesJoinPoint(thisObject, targetObject, args);
	}
}
 
Example #13
Source File: AspectJExpressionPointcut.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm) {
	// Note: Can't use JoinPointMatch.getClass().getName() as the key, since
	// Spring AOP does all the matching at a join point, and then all the invocations
	// under this scenario, if we just use JoinPointMatch as the key, then
	// 'last man wins' which is not what we want at all.
	// Using the expression is guaranteed to be safe, since 2 identical expressions
	// are guaranteed to bind in exactly the same way.
	invocation.setUserAttribute(resolveExpression(), jpm);
}
 
Example #14
Source File: AspectJAroundAdvice.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi;
	ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi);
	JoinPointMatch jpm = getJoinPointMatch(pmi);
	return invokeAdviceMethod(pjp, jpm, null, null);
}
 
Example #15
Source File: AspectJExpressionPointcut.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) {
	try {
		return this.primary.matchesJoinPoint(thisObject, targetObject, args);
	}
	catch (ReflectionWorldException ex) {
		return this.other.matchesJoinPoint(thisObject, targetObject, args);
	}
}
 
Example #16
Source File: AbstractAspectJAdvice.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Get the current join point match at the join point we are being dispatched on.
 */
@Nullable
protected JoinPointMatch getJoinPointMatch() {
	MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
	if (!(mi instanceof ProxyMethodInvocation)) {
		throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
	}
	return getJoinPointMatch((ProxyMethodInvocation) mi);
}
 
Example #17
Source File: AbstractAspectJAdvice.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
	return (JoinPointMatch) pmi.getUserAttribute(this.pointcut.getExpression());
}
 
Example #18
Source File: AbstractAspectJAdvice.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected Object invokeAdviceMethod(JoinPoint jp, JoinPointMatch jpMatch, Object returnValue, Throwable t)
		throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(jp, jpMatch, returnValue, t));
}
 
Example #19
Source File: AbstractAspectJAdvice.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected Object invokeAdviceMethod(JoinPoint jp, @Nullable JoinPointMatch jpMatch,
		@Nullable Object returnValue, @Nullable Throwable t) throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(jp, jpMatch, returnValue, t));
}
 
Example #20
Source File: AbstractAspectJAdvice.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
	return (JoinPointMatch) pmi.getUserAttribute(this.pointcut.getExpression());
}
 
Example #21
Source File: AbstractAspectJAdvice.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected Object invokeAdviceMethod(JoinPoint jp, JoinPointMatch jpMatch, Object returnValue, Throwable t)
		throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(jp, jpMatch, returnValue, t));
}
 
Example #22
Source File: AbstractAspectJAdvice.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Nullable
protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
	String expression = this.pointcut.getExpression();
	return (expression != null ? (JoinPointMatch) pmi.getUserAttribute(expression) : null);
}
 
Example #23
Source File: AbstractAspectJAdvice.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Nullable
protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi) {
	String expression = this.pointcut.getExpression();
	return (expression != null ? (JoinPointMatch) pmi.getUserAttribute(expression) : null);
}
 
Example #24
Source File: AbstractAspectJAdvice.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected Object invokeAdviceMethod(JoinPoint jp, @Nullable JoinPointMatch jpMatch,
		@Nullable Object returnValue, @Nullable Throwable t) throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(jp, jpMatch, returnValue, t));
}
 
Example #25
Source File: AbstractAspectJAdvice.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Invoke the advice method.
 * @param jpMatch the JoinPointMatch that matched this execution join point
 * @param returnValue the return value from the method execution (may be null)
 * @param ex the exception thrown by the method execution (may be null)
 * @return the invocation result
 * @throws Throwable in case of invocation failure
 */
protected Object invokeAdviceMethod(
		@Nullable JoinPointMatch jpMatch, @Nullable Object returnValue, @Nullable Throwable ex)
		throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(getJoinPoint(), jpMatch, returnValue, ex));
}
 
Example #26
Source File: AbstractAspectJAdvice.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Invoke the advice method.
 * @param jpMatch the JoinPointMatch that matched this execution join point
 * @param returnValue the return value from the method execution (may be null)
 * @param ex the exception thrown by the method execution (may be null)
 * @return the invocation result
 * @throws Throwable in case of invocation failure
 */
protected Object invokeAdviceMethod(
		@Nullable JoinPointMatch jpMatch, @Nullable Object returnValue, @Nullable Throwable ex)
		throws Throwable {

	return invokeAdviceMethodWithGivenArgs(argBinding(getJoinPoint(), jpMatch, returnValue, ex));
}
 
Example #27
Source File: AbstractAspectJAdvice.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Invoke the advice method.
 * @param jpMatch the JoinPointMatch that matched this execution join point
 * @param returnValue the return value from the method execution (may be null)
 * @param ex the exception thrown by the method execution (may be null)
 * @return the invocation result
 * @throws Throwable in case of invocation failure
 */
protected Object invokeAdviceMethod(JoinPointMatch jpMatch, Object returnValue, Throwable ex) throws Throwable {
	return invokeAdviceMethodWithGivenArgs(argBinding(getJoinPoint(), jpMatch, returnValue, ex));
}
 
Example #28
Source File: AbstractAspectJAdvice.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Invoke the advice method.
 * @param jpMatch the JoinPointMatch that matched this execution join point
 * @param returnValue the return value from the method execution (may be null)
 * @param ex the exception thrown by the method execution (may be null)
 * @return the invocation result
 * @throws Throwable in case of invocation failure
 */
protected Object invokeAdviceMethod(JoinPointMatch jpMatch, Object returnValue, Throwable ex) throws Throwable {
	return invokeAdviceMethodWithGivenArgs(argBinding(getJoinPoint(), jpMatch, returnValue, ex));
}