Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dando suporte a ignorar uri stats

  • Loading branch information...
commit 6ec2f3d47e7bea9b40f36b48b5b9b59a6867ea35 1 parent 9f6b0e2
@mauricioaniche mauricioaniche authored
View
4 src/main/java/br/com/caelum/vraptor/dash/uristats/BaseURIStatInterceptor.java
@@ -35,8 +35,8 @@ public BaseURIStatInterceptor(Container container,
this.response = response;
}
- public boolean accepts(ResourceMethod arg0) {
- return true;
+ public boolean accepts(ResourceMethod rm) {
+ return !rm.getResource().getType().isAnnotationPresent(NoURIStats.class);
}
public void intercept(InterceptorStack stack, ResourceMethod method,
View
11 src/main/java/br/com/caelum/vraptor/dash/uristats/NoURIStats.java
@@ -0,0 +1,11 @@
+package br.com.caelum.vraptor.dash.uristats;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention (RetentionPolicy.RUNTIME)
+@Target (ElementType.TYPE)
+public @interface NoURIStats {
+}
View
22 src/test/java/br/com/caelum/vraptor/dash/uristats/BaseURIStatInterceptorTest.java
@@ -0,0 +1,22 @@
+package br.com.caelum.vraptor.dash.uristats;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+import br.com.caelum.vraptor.resource.DefaultResourceClass;
+import br.com.caelum.vraptor.resource.DefaultResourceMethod;
+
+public class BaseURIStatInterceptorTest {
+
+ @Test
+ public void should_ignore_annotated_controllers() {
+ BaseURIStatInterceptor interceptor = new BaseURIStatInterceptor(null, null, null);
+
+ boolean accept = interceptor.accepts(
+ new DefaultResourceMethod(new DefaultResourceClass(NotLoggedResource.class),
+ null));
+
+ assertFalse(accept);
+ }
+}
View
9 src/test/java/br/com/caelum/vraptor/dash/uristats/NotLoggedResource.java
@@ -0,0 +1,9 @@
+package br.com.caelum.vraptor.dash.uristats;
+
+import br.com.caelum.vraptor.Resource;
+
+@Resource
+@NoURIStats
+public class NotLoggedResource {
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.