-
Notifications
You must be signed in to change notification settings - Fork 388
[1-2단계 톰캣 구현하기] 감자(김주하) 미션 제출합니다. #509
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
Changes from all commits
aed1db7
7f082ec
e5368a4
3bf4a29
11864d5
b0b08ff
82c8a82
fed02f6
c1d7cb1
7e91356
476edc1
6aa1a44
d4dba28
42e833e
b3d504b
53fa353
da04710
b158638
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) { | ||
| CacheControl cacheControl = CacheControl.noCache().cachePrivate(); | ||
| WebContentInterceptor webContentInterceptor = new WebContentInterceptor(); | ||
| webContentInterceptor.addCacheMapping(cacheControl, "/**"); | ||
| registry.addInterceptor(webContentInterceptor); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,19 @@ | ||
| package cache.com.example.etag; | ||
|
|
||
| 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> filterRegistrationBean | ||
| = new FilterRegistrationBean<>( new ShallowEtagHeaderFilter()); | ||
| filterRegistrationBean.addUrlPatterns("/etag"); | ||
| filterRegistrationBean.addUrlPatterns("/resources/*"); | ||
| return filterRegistrationBean; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!DOCTYPE HTML> | ||
| <html lang="ko"> | ||
| <head> | ||
| <title>Getting Started: Serving Web Content</title> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
| </head> | ||
| <body> | ||
| Hello, World! | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| package org.apache.catalina; | ||
|
|
||
| import jakarta.servlet.http.HttpSession; | ||
| package org.apache.catalina.session; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
|
|
@@ -29,7 +27,7 @@ public interface Manager { | |
| * | ||
| * @param session Session to be added | ||
| */ | ||
| void add(HttpSession session); | ||
| void add(Session session); | ||
|
Member
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. [질문]
Member
Author
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. 확실히 기존 |
||
|
|
||
| /** | ||
| * Return the active Session, associated with this Manager, with the | ||
|
|
@@ -45,12 +43,12 @@ public interface Manager { | |
| * @return the request session or {@code null} if a session with the | ||
| * requested ID could not be found | ||
| */ | ||
| HttpSession findSession(String id) throws IOException; | ||
| Session findSession(String id); | ||
|
|
||
| /** | ||
| * Remove this Session from the active Sessions for this Manager. | ||
| * | ||
| * @param session Session to be removed | ||
| */ | ||
| void remove(HttpSession session); | ||
| void remove(Session session); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.apache.catalina.session; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class Session { | ||
|
|
||
| private final String id; | ||
| private final Map<String, Object> values = new HashMap<>(); | ||
|
|
||
| public Session(String id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public boolean contains(String name) { | ||
| return getAttribute(name) != null; | ||
| } | ||
|
|
||
| public Object getAttribute(String name) { | ||
| return values.get(name); | ||
| } | ||
|
|
||
| public void setAttribute(String name, Object value) { | ||
| values.put(name, value); | ||
| } | ||
|
|
||
| public void removeAttribute(String name) { | ||
| values.remove(name); | ||
| } | ||
|
|
||
| public void invalidate() { | ||
| values.clear(); | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.apache.catalina.session; | ||
|
|
||
| @FunctionalInterface | ||
| public interface SessionGenerator { | ||
| Session create(); | ||
| } |
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.
도메인 객체에 검증 책임을 잘 부여해 주셨네요👍