use of org.aopalliance.intercept.MethodInterceptor in project stdlib by petergeneric.
the class AuthConstraintInterceptorModule method configure.
@Override
protected void configure() {
// Use interceptor that checks CurrentUser and calls AccessRefuser to deny access
final MethodInterceptor interceptor = new AuthConstraintMethodInterceptor(getProvider(CurrentUser.class), config, calls, granted, denied, authenticatedDenied);
// Collect all REST service interfaces we implement
Set<Class<?>> restIfaces = RestResourceRegistry.getResources().stream().map(RestResource::getResourceClass).collect(Collectors.toSet());
Matcher<Method> matcher = new WebMethodMatcher(restIfaces);
bindInterceptor(Matchers.any(), matcher, interceptor);
}
use of org.aopalliance.intercept.MethodInterceptor in project camunda-bpm-platform by camunda.
the class ProcessScope method createDirtyCheckingProxy.
private Object createDirtyCheckingProxy(final String name, final Object scopedObject) throws Throwable {
ProxyFactory proxyFactoryBean = new ProxyFactory(scopedObject);
proxyFactoryBean.setProxyTargetClass(this.proxyTargetClass);
proxyFactoryBean.addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
Object result = methodInvocation.proceed();
persistVariable(name, scopedObject);
return result;
}
});
return proxyFactoryBean.getProxy(this.classLoader);
}
use of org.aopalliance.intercept.MethodInterceptor in project spring-cloud-stream by spring-cloud.
the class DefaultPollableMessageSource method setSource.
public void setSource(MessageSource<?> source) {
ProxyFactory pf = new ProxyFactory(source);
class ReceiveAdvice implements MethodInterceptor {
private final List<ChannelInterceptor> interceptors = new ArrayList<>();
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Object result = invocation.proceed();
if (result instanceof Message) {
Message<?> received = (Message<?>) result;
for (ChannelInterceptor interceptor : this.interceptors) {
received = interceptor.preSend(received, null);
if (received == null) {
return null;
}
}
return received;
}
return result;
}
}
final ReceiveAdvice advice = new ReceiveAdvice();
advice.interceptors.addAll(this.interceptors);
NameMatchMethodPointcutAdvisor sourceAdvisor = new NameMatchMethodPointcutAdvisor(advice);
sourceAdvisor.addMethodName("receive");
pf.addAdvisor(sourceAdvisor);
this.source = (MessageSource<?>) pf.getProxy();
}
use of org.aopalliance.intercept.MethodInterceptor in project spring-data-commons by spring-projects.
the class SpelEvaluatingMethodInterceptorUnitTests method invokesMethodOnTarget.
// DATAREST-221, DATACMNS-630
@Test
public void invokesMethodOnTarget() throws Throwable {
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("propertyFromTarget"));
MethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, new Target(), null, parser, Projection.class);
assertThat(interceptor.invoke(invocation)).isEqualTo("property");
}
use of org.aopalliance.intercept.MethodInterceptor in project spring-data-commons by spring-projects.
the class SpelEvaluatingMethodInterceptorUnitTests method forwardsParameterIntoSpElExpressionEvaluation.
// DATACMNS-1150
@Test
public void forwardsParameterIntoSpElExpressionEvaluation() throws Throwable {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerSingleton("someBean", new SomeBean());
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("invokeBeanWithParameter", Integer.class));
when(invocation.getArguments()).thenReturn(new Object[] { 1 });
MethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, new Target(), factory, parser, Projection.class);
assertThat(interceptor.invoke(invocation)).isEqualTo("property1");
}
Aggregations