@Test public void testBindShiroInterceptor() { ShiroAopModule underTest = new ShiroAopModule() { @Override protected void configureInterceptors(AnnotationResolver resolver) { bindShiroInterceptor(new MyAnnotationMethodInterceptor()); } }; List<Element> elements = Elements.getElements(underTest); for (Element element : elements) { if (element instanceof InterceptorBinding) { InterceptorBinding binding = (InterceptorBinding) element; assertTrue(binding.getClassMatcher().matches(getClass())); Method method = null; Class<? extends Annotation> theAnnotation = null; for (Class<? extends Annotation> annotation : protectedMethods.keySet()) { if (binding.getMethodMatcher().matches(protectedMethods.get(annotation))) { method = protectedMethods.get(annotation); theAnnotation = annotation; protectedMethods.remove(annotation); break; } } if (method == null) { fail("Did not expect interceptor binding " + binding.getInterceptors()); } List<MethodInterceptor> interceptors = binding.getInterceptors(); assertEquals(1, interceptors.size()); assertTrue(interceptors.get(0) instanceof AopAllianceMethodInterceptorAdapter); assertTrue(interceptorTypes.get(theAnnotation).isInstance(((AopAllianceMethodInterceptorAdapter) interceptors.get(0)).shiroInterceptor)); } } assertTrue("Not all interceptors were bound.", protectedMethods.isEmpty()); }
protected final void bindShiroInterceptor(final AnnotationMethodInterceptor methodInterceptor) { bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { public boolean matches(Method method) { Class<? extends Annotation> annotation = methodInterceptor.getHandler().getAnnotationClass(); return method.getAnnotation(annotation) != null || method.getDeclaringClass().getAnnotation(annotation) != null; } }, new AopAllianceMethodInterceptorAdapter(methodInterceptor)); }
ShiroAopModule extends AbstractModule { protected final void bindShiroInterceptor(final AnnotationMethodInterceptor methodInterceptor) { bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { public boolean matches(Method method) { Class<? extends Annotation> annotation = methodInterceptor.getHandler().getAnnotationClass(); return method.getAnnotation(annotation) != null || method.getDeclaringClass().getAnnotation(annotation) != null; } }, new AopAllianceMethodInterceptorAdapter(methodInterceptor)); } }
ShiroAopModule extends AbstractModule { protected final void bindShiroInterceptor(final AnnotationMethodInterceptor methodInterceptor) { bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { public boolean matches(Method method) { Class<? extends Annotation> annotation = methodInterceptor.getHandler().getAnnotationClass(); return method.getAnnotation(annotation) != null || method.getDeclaringClass().getAnnotation(annotation) != null; } }, new AopAllianceMethodInterceptorAdapter(methodInterceptor)); }  }
ShiroAopModule extends AbstractModule { protected final void bindShiroInterceptor(final AnnotationMethodInterceptor methodInterceptor) { bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { public boolean matches(Method method) { Class<? extends Annotation> annotation = methodInterceptor.getHandler().getAnnotationClass(); return method.getAnnotation(annotation) != null || method.getDeclaringClass().getAnnotation(annotation) != null; } }, new AopAllianceMethodInterceptorAdapter(methodInterceptor)); }   }
ShiroAopModule extends AbstractModule { protected final void bindShiroInterceptor(final AnnotationMethodInterceptor methodInterceptor) { bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() { public boolean matches(Method method) { Class<? extends Annotation> annotation = methodInterceptor.getHandler().getAnnotationClass(); return method.getAnnotation(annotation) != null || method.getDeclaringClass().getAnnotation(annotation) != null; } }, new AopAllianceMethodInterceptorAdapter(methodInterceptor)); }    }