-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[톰캣 구현하기 - 3,4단계] 도이(유도영) 미션 제출합니다. #453
Changes from all commits
92b35c9
cd9a2f7
d7c55aa
1e30f69
3dea82f
fd68631
bb4c233
edfeb63
cc56b3a
8bb0991
ce2dd69
1ba138f
eac7d14
a86e454
a9dc6d0
0133924
f7942be
dd3e648
589135d
026e4dd
b0bda83
3fe2930
6c5730f
73535c5
54a9418
5bb6dab
de048a2
ee2a088
85a3522
2da62d8
3ff6f80
031c166
2745e8c
4e64504
a474269
48f7d39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
package cache.com.example.cachecontrol; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.CacheControl; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import org.springframework.web.servlet.mvc.WebContentInterceptor; | ||
|
||
@Configuration | ||
public class CacheWebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addInterceptors(final InterceptorRegistry registry) { | ||
WebContentInterceptor interceptor = new WebContentInterceptor(); | ||
|
||
interceptor.addCacheMapping(CacheControl.noCache().cachePrivate(), "/*"); | ||
registry.addInterceptor(interceptor); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
package cache.com.example.etag; | ||
|
||
import static cache.com.example.version.CacheBustingWebConfig.PREFIX_STATIC_RESOURCES; | ||
|
||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.filter.ShallowEtagHeaderFilter; | ||
|
||
@Configuration | ||
public class EtagFilterConfiguration { | ||
|
||
// @Bean | ||
// public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
// return null; | ||
// } | ||
@Bean | ||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
FilterRegistrationBean<ShallowEtagHeaderFilter> registration = new FilterRegistrationBean<>(); | ||
|
||
registration.setFilter(new ShallowEtagHeaderFilter()); | ||
registration.addUrlPatterns("/etag", PREFIX_STATIC_RESOURCES + "/*"); | ||
|
||
return registration; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package nextstep; | ||
|
||
import java.util.Set; | ||
import nextstep.jwp.servlet.LoginRequestServlet; | ||
import nextstep.jwp.servlet.RegisterRequestServlet; | ||
import org.apache.catalina.startup.Tomcat; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
public static void main(final String[] args) { | ||
final var tomcat = new Tomcat(); | ||
tomcat.start(); | ||
tomcat.start(Set.of(new LoginRequestServlet(), new RegisterRequestServlet())); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nextstep.jwp.controller; | ||
|
||
public interface Controller { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 Controller를 별도의 인터페이스로 분리하신 이유가 있으신가요? 각각의 Controller에 Implement를 하고 별도로 사용하진 않는 것 같아서요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금은 catalina에서 도메인 컨트롤러의 static 메서드를 호출하는 방식을 사용하고 있는데, 여기에 쪼금 더 합리화하자면 Spring에서 |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Application에서 Servlet을 주입받는군요.
진짜 코드가 맛있네요. 패키지에 신경을 쓰셨다는게 눈에 보여요.
정말 단순한 궁금증인데, Servlet들을 start로 넘기신 이유가 있을까요?
Tomcat 생성자에 넣을 수도 있을 것 같아서요.
(별 의미 없을 수도 있을 것 같은데, 혹시 도이라면 이유가 있을까? 궁금해서 코멘트 남깁니다.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
생성자로 받게 된다면, 서블릿들을 Tomcat의 멤버변수로 가지게 될텐데 (서블릿의 상태를 관리하는 다른 기능이 없기 때문에) 지금으로서는 그럴 이유가 없다고 생각했어요! 그래서 start 메서드를 통해 Http11Processor까지 전달해주기만 했습니다.