forked from google/guice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run google-java-format on all Guice code.
configure a presubmit to ensure that it stays formatted. Highlights include: * simplified import order * method annotations are now consistently defined on the preceding line * javadoc reformatted to 100 chars column width One test that contained line numbers in error messages had to be modified and the formatter didn't like some of the more complicated preprocessor directives (MOE and AOP). To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132693141
- Loading branch information
1 parent
751b555
commit 462a195
Showing
36 changed files
with
613 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
/* | ||
* Copyright (C) 2010 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -20,11 +20,11 @@ | |
|
||
/** | ||
* Abstract implementation for all servlet module bindings | ||
* | ||
* | ||
* @author [email protected] (Sam Berlin) | ||
*/ | ||
class AbstractServletModuleBinding<T> implements ServletModuleBinding { | ||
|
||
private final Map<String, String> initParams; | ||
private final T target; | ||
private final UriPatternMatcher patternMatcher; | ||
|
@@ -54,10 +54,9 @@ protected T getTarget() { | |
public UriPatternType getUriPatternType() { | ||
return patternMatcher.getPatternType(); | ||
} | ||
|
||
@Override | ||
public boolean matchesUri(String uri) { | ||
return patternMatcher.matches(uri); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
/* | ||
* Copyright (C) 2010 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -18,19 +18,16 @@ | |
|
||
import com.google.common.collect.Maps; | ||
import com.google.inject.OutOfScopeException; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import javax.servlet.ServletInputStream; | ||
import javax.servlet.http.Cookie; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletRequestWrapper; | ||
import javax.servlet.http.HttpSession; | ||
|
||
/** | ||
* A wrapper for requests that makes requests immutable, taking a snapshot | ||
* of the original request. | ||
* A wrapper for requests that makes requests immutable, taking a snapshot of the original request. | ||
* | ||
* @author [email protected] (Dhanji R. Prasanna) | ||
*/ | ||
|
@@ -63,31 +60,38 @@ public ContinuingHttpServletRequest(HttpServletRequest request) { | |
} | ||
} | ||
|
||
@Override public HttpSession getSession() { | ||
@Override | ||
public HttpSession getSession() { | ||
throw new OutOfScopeException("Cannot access the session in a continued request"); | ||
} | ||
|
||
@Override public HttpSession getSession(boolean create) { | ||
@Override | ||
public HttpSession getSession(boolean create) { | ||
throw new UnsupportedOperationException("Cannot access the session in a continued request"); | ||
} | ||
|
||
@Override public ServletInputStream getInputStream() throws IOException { | ||
@Override | ||
public ServletInputStream getInputStream() throws IOException { | ||
throw new UnsupportedOperationException("Cannot access raw request on a continued request"); | ||
} | ||
|
||
@Override public void setAttribute(String name, Object o) { | ||
@Override | ||
public void setAttribute(String name, Object o) { | ||
attributes.put(name, o); | ||
} | ||
|
||
@Override public void removeAttribute(String name) { | ||
@Override | ||
public void removeAttribute(String name) { | ||
attributes.remove(name); | ||
} | ||
|
||
@Override public Object getAttribute(String name) { | ||
@Override | ||
public Object getAttribute(String name) { | ||
return attributes.get(name); | ||
} | ||
|
||
@Override public Cookie[] getCookies() { | ||
@Override | ||
public Cookie[] getCookies() { | ||
// NOTE(dhanji): Cookies themselves are mutable. However a ContinuingHttpServletRequest | ||
// snapshots the original set of cookies it received and imprisons them in immutable | ||
// form. Unfortunately, the cookie array itself is mutable and there is no way for us | ||
|
@@ -112,31 +116,38 @@ public ImmutableCookie(Cookie original) { | |
} | ||
} | ||
|
||
@Override public void setComment(String purpose) { | ||
@Override | ||
public void setComment(String purpose) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setDomain(String pattern) { | ||
@Override | ||
public void setDomain(String pattern) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setMaxAge(int expiry) { | ||
@Override | ||
public void setMaxAge(int expiry) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setPath(String uri) { | ||
@Override | ||
public void setPath(String uri) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setSecure(boolean flag) { | ||
@Override | ||
public void setSecure(boolean flag) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setValue(String newValue) { | ||
@Override | ||
public void setValue(String newValue) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
|
||
@Override public void setVersion(int v) { | ||
@Override | ||
public void setVersion(int v) { | ||
throw new UnsupportedOperationException("Cannot modify cookies on a continued request"); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
/* | ||
* Copyright (C) 2008 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -16,33 +16,30 @@ | |
package com.google.inject.servlet; | ||
|
||
import com.google.inject.ImplementedBy; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.FilterChain; | ||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
|
||
/** | ||
* An internal dispatcher for guice-servlet registered servlets and filters. | ||
* By default, we assume a Guice 1.0 style servlet module is in play. In other | ||
* words, we dispatch directly to the web.xml pipeline after setting up scopes. | ||
* An internal dispatcher for guice-servlet registered servlets and filters. By default, we assume a | ||
* Guice 1.0 style servlet module is in play. In other words, we dispatch directly to the web.xml | ||
* pipeline after setting up scopes. | ||
* | ||
* <p> | ||
* If on the other hand, {@link ServletModule} is used to register managed | ||
* servlets and/or filters, then a different pipeline is bound instead. Which, | ||
* after dispatching to Guice-injected filters and servlets continues to the web.xml | ||
* pipeline (if necessary). | ||
* <p>If on the other hand, {@link ServletModule} is used to register managed servlets and/or | ||
* filters, then a different pipeline is bound instead. Which, after dispatching to Guice-injected | ||
* filters and servlets continues to the web.xml pipeline (if necessary). | ||
* | ||
* @author [email protected] (Dhanji R. Prasanna) | ||
*/ | ||
@ImplementedBy(DefaultFilterPipeline.class) | ||
interface FilterPipeline { | ||
void initPipeline(ServletContext context) throws ServletException; | ||
|
||
void destroyPipeline(); | ||
|
||
void dispatch(ServletRequest request, ServletResponse response, | ||
FilterChain defaultFilterChain) throws IOException, ServletException; | ||
void dispatch(ServletRequest request, ServletResponse response, FilterChain defaultFilterChain) | ||
throws IOException, ServletException; | ||
} |
Oops, something went wrong.