Skip to content

Commit

Permalink
Change HttpMethod parse to allow the definition of a default method.
Browse files Browse the repository at this point in the history
  • Loading branch information
alsoqz committed Oct 16, 2010
1 parent 164fd04 commit 7d938c2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Delete {
Expand Down
2 changes: 1 addition & 1 deletion vraptor-core/src/main/java/br/com/caelum/vraptor/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Guilherme Silveira
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Get {
Expand Down
2 changes: 1 addition & 1 deletion vraptor-core/src/main/java/br/com/caelum/vraptor/Head.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Head {
Expand Down
2 changes: 1 addition & 1 deletion vraptor-core/src/main/java/br/com/caelum/vraptor/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Guilherme Silveira
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Post {
Expand Down
2 changes: 1 addition & 1 deletion vraptor-core/src/main/java/br/com/caelum/vraptor/Put.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Guilherme Silveira
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Put {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Trace {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,30 @@ public List<Route> rulesFor(ResourceClass resource) {
}

protected List<Route> registerRulesFor(Class<?> baseType) {
HttpMethod commonHttpMethod = null;
for (HttpMethod m : HttpMethod.values()) {
if (baseType.isAnnotationPresent(m.getAnnotation())) {
commonHttpMethod = m;
break;
}
}
List<Route> routes = new ArrayList<Route>();
for (Method javaMethod : baseType.getMethods()) {
if (isEligible(javaMethod)) {
String[] uris = getURIsFor(javaMethod, baseType);

for (String uri : uris) {
boolean isNotHttpMethodAnnotationPresent = true;
RouteBuilder rule = router.builderFor(uri);
for (HttpMethod m : HttpMethod.values()) {
if (javaMethod.isAnnotationPresent(m.getAnnotation())) {
rule.with(m);
isNotHttpMethodAnnotationPresent = false;
}
}
}
if( isNotHttpMethodAnnotationPresent && commonHttpMethod!=null ){
rule.with( commonHttpMethod );
}
if (javaMethod.isAnnotationPresent(Path.class)) {
rule.withPriority(javaMethod.getAnnotation(Path.class).priority());
}
Expand Down
2 changes: 2 additions & 0 deletions vraptor-site/src/content/equipe.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<dt>Lucas H. G. Toniazzo - <fmt:message key="colaborador"/></dt>
<dt>Otávio Scherer Garcia - <fmt:message key="colaborador"/></dt>
<dt>Rafael Carneiro - <fmt:message key="colaborador"/></dt>
<dt>Allan de Queiroz - <fmt:message key="colaborador"/></dt>
<dd><a href="mailto:alsoqz@gmail.com">alsoqz@gmail.com</a></dd>
</dl>
</div>
</div>
Expand Down

0 comments on commit 7d938c2

Please sign in to comment.