├── sp4-chap07 ├── src │ └── main │ │ ├── java │ │ ├── chap07 │ │ │ ├── Calculator.java │ │ │ ├── RecCalculator.java │ │ │ ├── ImpeCalculator.java │ │ │ └── ExeTimeCalculator.java │ │ ├── main │ │ │ ├── MainProxy.java │ │ │ ├── MainXmlOrder.java │ │ │ ├── MainXmlAspect.java │ │ │ ├── MainJavaAspect.java │ │ │ └── MainXmlPojo.java │ │ ├── config │ │ │ └── JavaConfig.java │ │ └── aspect │ │ │ ├── CacheAspect.java │ │ │ ├── ExeTimeAspect.java │ │ │ └── ExeTimeAspect2.java │ │ └── resources │ │ ├── aopAspect.xml │ │ └── aopPojo.xml └── pom.xml ├── sp4-chap03 ├── src │ └── main │ │ ├── java │ │ ├── spring │ │ │ ├── MemberNotFoundException.java │ │ │ ├── IdPasswordNotMatchingException.java │ │ │ ├── AlreadyExistingMemberException.java │ │ │ ├── MemberPrinter.java │ │ │ ├── MemberListPrinter.java │ │ │ ├── ChangePasswordService.java │ │ │ ├── MemberInfoPrinter.java │ │ │ ├── MemberRegisterService.java │ │ │ ├── MemberDao.java │ │ │ ├── VersionPrinter.java │ │ │ ├── RegisterRequest.java │ │ │ └── Member.java │ │ └── assembler │ │ │ └── Assembler.java │ │ └── resources │ │ ├── conf1.xml │ │ ├── configImport.xml │ │ ├── appCtx.xml │ │ └── conf2.xml └── pom.xml ├── sp4-chap08 └── src │ ├── main │ ├── java │ │ ├── spring │ │ │ ├── MemberNotFoundException.java │ │ │ ├── IdPasswordNotMatchingException.java │ │ │ ├── AlreadyExistingMemberException.java │ │ │ ├── MemberPrinter.java │ │ │ ├── MemberListPrinter.java │ │ │ ├── MemberRowMapper.java │ │ │ ├── MemberInfoPrinter.java │ │ │ ├── ChangePasswordService.java │ │ │ ├── MemberRegisterService.java │ │ │ ├── RegisterRequest.java │ │ │ └── Member.java │ │ └── main │ │ │ ├── MainForCPS.java │ │ │ └── MainForJC.java │ └── resources │ │ └── log4j.xml │ └── sql │ └── ddl.sql ├── sp4-chap11 └── src │ └── main │ ├── java │ ├── spring │ │ ├── MemberNotFoundException.java │ │ ├── IdPasswordNotMatchingException.java │ │ ├── AlreadyExistingMemberException.java │ │ ├── ChangePasswordService.java │ │ ├── MemberRegisterService.java │ │ ├── RegisterRequest.java │ │ └── Member.java │ └── survey │ │ ├── Respondent.java │ │ ├── AnsweredData.java │ │ └── Question.java │ ├── webapp │ ├── WEB-INF │ │ └── view │ │ │ ├── main.jsp │ │ │ ├── register │ │ │ ├── step3.jsp │ │ │ └── step1.jsp │ │ │ └── survey │ │ │ └── submitted.jsp │ └── index.jsp │ └── resources │ ├── log4j.xml │ ├── spring-mvc.xml │ └── spring-controller.xml ├── sp4-chap12 └── src │ └── main │ ├── java │ ├── spring │ │ ├── MemberNotFoundException.java │ │ ├── IdPasswordNotMatchingException.java │ │ ├── AlreadyExistingMemberException.java │ │ ├── AuthInfo.java │ │ ├── AuthService.java │ │ ├── ChangePasswordService.java │ │ ├── MemberRegisterService.java │ │ ├── RegisterRequest.java │ │ └── Member.java │ ├── survey │ │ ├── Respondent.java │ │ ├── AnsweredData.java │ │ └── Question.java │ ├── controller │ │ ├── LogoutController.java │ │ ├── ChangePwdCommand.java │ │ ├── LoginCommandValidator.java │ │ ├── ChangePwdCommandValidator.java │ │ └── LoginCommand.java │ └── interceptor │ │ └── AuthCheckInterceptor.java │ ├── webapp │ ├── index.jsp │ └── WEB-INF │ │ └── view │ │ ├── login │ │ ├── loginSuccess.jsp │ │ └── loginForm.jsp │ │ ├── edit │ │ ├── changedPwd.jsp │ │ └── changePwdForm.jsp │ │ ├── survey │ │ └── submitted.jsp │ │ ├── register │ │ ├── step3.jsp │ │ └── step1.jsp │ │ └── main.jsp │ └── resources │ ├── log4j.xml │ ├── message │ └── label.properties │ └── spring-mvc.xml ├── sp4-chap13 └── src │ ├── main │ ├── java │ │ ├── spring │ │ │ ├── MemberNotFoundException.java │ │ │ ├── IdPasswordNotMatchingException.java │ │ │ ├── AlreadyExistingMemberException.java │ │ │ ├── AuthInfo.java │ │ │ ├── AuthService.java │ │ │ ├── ChangePasswordService.java │ │ │ ├── MemberRegisterService.java │ │ │ ├── RegisterRequest.java │ │ │ └── Member.java │ │ ├── survey │ │ │ ├── Respondent.java │ │ │ ├── AnsweredData.java │ │ │ └── Question.java │ │ ├── controller │ │ │ ├── LogoutController.java │ │ │ ├── ChangePwdCommand.java │ │ │ ├── ListCommand.java │ │ │ ├── LoginCommandValidator.java │ │ │ ├── ChangePwdCommandValidator.java │ │ │ ├── LoginCommand.java │ │ │ └── MemberListController.java │ │ └── interceptor │ │ │ └── AuthCheckInterceptor.java │ ├── webapp │ │ ├── WEB-INF │ │ │ └── view │ │ │ │ ├── member │ │ │ │ ├── invalidId.jsp │ │ │ │ ├── noMember.jsp │ │ │ │ ├── memberDetail.jsp │ │ │ │ └── memberList.jsp │ │ │ │ ├── login │ │ │ │ ├── loginSuccess.jsp │ │ │ │ └── loginForm.jsp │ │ │ │ ├── edit │ │ │ │ ├── changedPwd.jsp │ │ │ │ └── changePwdForm.jsp │ │ │ │ ├── survey │ │ │ │ └── submitted.jsp │ │ │ │ ├── register │ │ │ │ ├── step3.jsp │ │ │ │ └── step1.jsp │ │ │ │ └── main.jsp │ │ └── index.jsp │ └── resources │ │ ├── log4j.xml │ │ ├── message │ │ └── label.properties │ │ └── spring-mvc.xml │ └── sql │ └── initData.sql ├── sp4-chap14 └── src │ └── main │ ├── java │ ├── spring │ │ ├── MemberNotFoundException.java │ │ ├── IdPasswordNotMatchingException.java │ │ ├── AlreadyExistingMemberException.java │ │ ├── AuthInfo.java │ │ ├── AuthService.java │ │ ├── ChangePasswordService.java │ │ ├── MemberRegisterService.java │ │ ├── RegisterRequest.java │ │ └── Member.java │ ├── survey │ │ ├── Respondent.java │ │ ├── AnsweredData.java │ │ └── Question.java │ ├── controller │ │ ├── LogoutController.java │ │ ├── ChangePwdCommand.java │ │ ├── ListCommand.java │ │ ├── LoginCommandValidator.java │ │ ├── ChangePwdCommandValidator.java │ │ ├── LoginCommand.java │ │ └── MemberListController.java │ └── interceptor │ │ └── AuthCheckInterceptor.java │ ├── webapp │ ├── WEB-INF │ │ └── view │ │ │ ├── member │ │ │ ├── invalidId.jsp │ │ │ ├── noMember.jsp │ │ │ ├── memberDetail.jsp │ │ │ └── memberList.jsp │ │ │ ├── login │ │ │ ├── loginSuccess.jsp │ │ │ └── loginForm.jsp │ │ │ ├── edit │ │ │ ├── changedPwd.jsp │ │ │ └── changePwdForm.jsp │ │ │ ├── survey │ │ │ └── submitted.jsp │ │ │ ├── register │ │ │ ├── step3.jsp │ │ │ └── step1.jsp │ │ │ └── main.jsp │ └── index.jsp │ └── resources │ ├── log4j.xml │ └── message │ └── label.properties ├── sp4-chap16 └── src │ └── main │ ├── java │ ├── spring │ │ ├── MemberNotFoundException.java │ │ ├── IdPasswordNotMatchingException.java │ │ ├── AlreadyExistingMemberException.java │ │ ├── AuthInfo.java │ │ ├── AuthService.java │ │ ├── ChangePasswordService.java │ │ ├── MemberRegisterService.java │ │ ├── RegisterRequest.java │ │ └── Member.java │ ├── survey │ │ ├── Respondent.java │ │ ├── AnsweredData.java │ │ └── Question.java │ ├── controller │ │ ├── LogoutController.java │ │ ├── ChangePwdCommand.java │ │ ├── ListCommand.java │ │ ├── LoginCommandValidator.java │ │ ├── ChangePwdCommandValidator.java │ │ ├── LoginCommand.java │ │ └── MemberListController.java │ ├── main │ │ ├── MainDevXmlProfile2.java │ │ ├── MainDevJavaProfile2.java │ │ ├── MainXmlPropertyFile.java │ │ ├── MainDevXmlProfile1.java │ │ ├── MainJavaPropertyFile.java │ │ └── MainDevJavaProfile1.java │ ├── interceptor │ │ └── AuthCheckInterceptor.java │ └── config │ │ ├── DsDevConfig.java │ │ └── DsRealConfig.java │ ├── resources │ ├── db.properties │ ├── log4j.xml │ ├── spring-ds-dev.xml │ ├── spring-ds-real.xml │ ├── message │ │ └── label.properties │ ├── spring-ds-prop.xml │ └── spring-mvc.xml │ └── webapp │ ├── WEB-INF │ └── view │ │ ├── member │ │ ├── invalidId.jsp │ │ ├── noMember.jsp │ │ └── memberDetail.jsp │ │ ├── login │ │ ├── loginSuccess.jsp │ │ └── loginForm.jsp │ │ ├── edit │ │ ├── changedPwd.jsp │ │ └── changePwdForm.jsp │ │ ├── survey │ │ └── submitted.jsp │ │ ├── register │ │ ├── step3.jsp │ │ └── step1.jsp │ │ └── main.jsp │ └── index.jsp ├── sp4-chap04 ├── src │ └── main │ │ ├── java │ │ ├── spring │ │ │ ├── IdPasswordNotMatchingException.java │ │ │ ├── AlreadyExistingMemberException.java │ │ │ ├── MemberPrinter.java │ │ │ ├── MemberDao.java │ │ │ ├── MemberRegisterService.java │ │ │ ├── MemberInfoPrinter.java │ │ │ ├── RegisterRequest.java │ │ │ └── Member.java │ │ └── main │ │ │ ├── Main4.java │ │ │ ├── Main.java │ │ │ ├── Main3.java │ │ │ ├── Main5.java │ │ │ └── Main2.java │ │ └── resources │ │ ├── appCtx1.xml │ │ ├── appCtx5.xml │ │ ├── appCtx2.xml │ │ ├── appCtx3.xml │ │ └── appCtx4.xml └── pom.xml ├── sp4-chap05 ├── src │ └── main │ │ ├── java │ │ ├── spring │ │ │ ├── IdPasswordNotMatchingException.java │ │ │ ├── AlreadyExistingMemberException.java │ │ │ ├── MemberPrinter.java │ │ │ ├── MemberInfoPrinter.java │ │ │ ├── MemberRegisterService.java │ │ │ ├── MemberDao.java │ │ │ ├── RegisterRequest.java │ │ │ └── Member.java │ │ ├── config │ │ │ ├── ConfigPart1.java │ │ │ ├── ConfigPartMain.java │ │ │ ├── JavaSubConf.java │ │ │ ├── ConfigPartSub.java │ │ │ ├── JavaMainConf.java │ │ │ ├── JavaConfig2.java │ │ │ ├── ConfigPart2.java │ │ │ ├── JavaConfig.java │ │ │ └── JavaConfig3.java │ │ └── main │ │ │ ├── Main.java │ │ │ ├── Main3.java │ │ │ ├── MainJavaXml.java │ │ │ ├── MainTwoConfs2.java │ │ │ ├── Main2.java │ │ │ ├── MainTwoConfs.java │ │ │ └── MainXmlJava.java │ │ └── resources │ │ ├── sub-conf.xml │ │ └── main-conf.xml └── pom.xml ├── .gitignore ├── sp4-chap09 └── src │ └── main │ ├── webapp │ └── WEB-INF │ │ └── view │ │ └── hello.jsp │ ├── resources │ ├── spring-controller.xml │ └── spring-mvc.xml │ └── java │ └── chap09 │ └── HelloController.java ├── sp4-chap02 ├── src │ └── main │ │ ├── java │ │ └── chap02 │ │ │ ├── Greeter.java │ │ │ ├── Main.java │ │ │ └── Main2.java │ │ └── resources │ │ └── applicationContext.xml └── pom.xml ├── sp4-chap06 ├── src │ └── main │ │ ├── java │ │ ├── main │ │ │ ├── Main.java │ │ │ └── Main2.java │ │ ├── conf │ │ │ ├── JavaConfig.java │ │ │ └── JavaConfigPrototype.java │ │ └── spring │ │ │ ├── Client2.java │ │ │ └── Client.java │ │ └── resources │ │ ├── springconfPrototype.xml │ │ └── springconf.xml └── pom.xml └── README.md /sp4-chap07/src/main/java/chap07/Calculator.java: -------------------------------------------------------------------------------- 1 | package chap07; 2 | 3 | public interface Calculator { 4 | 5 | public long factorial(long num); 6 | 7 | } -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/MemberNotFoundException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberNotFoundException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/IdPasswordNotMatchingException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class IdPasswordNotMatchingException extends RuntimeException { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | .settings 8 | .classpath 9 | .project 10 | .DS_Store -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/db.properties: -------------------------------------------------------------------------------- 1 | db.driver=com.mysql.jdbc.Driver 2 | db.jdbcUrl=jdbc:mysql://localhost/spring4fs?characterEncoding=utf8 3 | db.user=spring4 4 | db.password=spring4 5 | -------------------------------------------------------------------------------- /sp4-chap09/src/main/webapp/WEB-INF/view/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | Hello 6 | 7 | 8 | 인사말: ${greeting} 9 | 10 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/member/invalidId.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 오류 6 | 7 | 8 |

9 | 잘못된 요청입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/member/invalidId.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 오류 6 | 7 | 8 |

9 | 잘못된 요청입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/member/invalidId.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 오류 6 | 7 | 8 |

9 | 잘못된 요청입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/member/noMember.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 회원 없음 6 | 7 | 8 |

9 | 존재하지 않는 회원입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/member/noMember.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 회원 없음 6 | 7 | 8 |

9 | 존재하지 않는 회원입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/member/noMember.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 회원 없음 6 | 7 | 8 |

9 | 존재하지 않는 회원입니다. 10 |

11 | 12 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/AlreadyExistingMemberException.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AlreadyExistingMemberException extends RuntimeException { 4 | 5 | public AlreadyExistingMemberException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/chap07/RecCalculator.java: -------------------------------------------------------------------------------- 1 | package chap07; 2 | 3 | public class RecCalculator implements Calculator { 4 | 5 | @Override 6 | public long factorial(long num) { 7 | if (num == 0) 8 | return 1; 9 | else 10 | return num * factorial(num - 1); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/chap07/ImpeCalculator.java: -------------------------------------------------------------------------------- 1 | package chap07; 2 | 3 | public class ImpeCalculator implements Calculator { 4 | 5 | @Override 6 | public long factorial(long num) { 7 | long result = 1; 8 | for (long i = 1; i <= num; i++) { 9 | result *= i; 10 | } 11 | return result; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sp4-chap02/src/main/java/chap02/Greeter.java: -------------------------------------------------------------------------------- 1 | package chap02; 2 | 3 | public class Greeter { 4 | 5 | private String format; 6 | 7 | public String greet(String guest) { 8 | return String.format(format, guest); 9 | } 10 | 11 | public void setFormat(String format) { 12 | this.format = format; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberPrinter { 4 | 5 | public void print(Member member) { 6 | System.out.printf( 7 | "회원 정보: 아이디=%d, 이메일=%s, 이름=%s, 등록일=%tF\n", 8 | member.getId(), member.getEmail(), 9 | member.getName(), member.getRegisterDate()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/MemberPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberPrinter { 4 | 5 | public void print(Member member) { 6 | System.out.printf( 7 | "회원 정보: 아이디=%d, 이메일=%s, 이름=%s, 등록일=%tF\n", 8 | member.getId(), member.getEmail(), 9 | member.getName(), member.getRegisterDate()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/MemberPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberPrinter { 4 | 5 | public void print(Member member) { 6 | System.out.printf( 7 | "회원 정보: 아이디=%d, 이메일=%s, 이름=%s, 등록일=%tF\n", 8 | member.getId(), member.getEmail(), 9 | member.getName(), member.getRegisterDate()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberPrinter { 4 | 5 | public void print(Member member) { 6 | System.out.printf( 7 | "회원 정보: 아이디=%d, 이메일=%s, 이름=%s, 등록일=%tF\n", 8 | member.getId(), member.getEmail(), 9 | member.getName(), member.getRegisterDate()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 인덱스 7 | 8 | 9 |

12장 예제

10 | 13 | 14 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/webapp/WEB-INF/view/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 메인 7 | 8 | 9 |

환영합니다.

10 |

">[회원 가입하기] 11 | 12 | -------------------------------------------------------------------------------- /sp4-chap09/src/main/resources/spring-controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 인덱스 7 | 8 | 9 |

11장 예제

10 | 14 | 15 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/webapp/WEB-INF/view/register/step3.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 회원가입 7 | 8 | 9 |

${registerRequest.name}님 10 | 회원 가입을 완료했습니다.

11 |

[첫 화면 이동]

12 | 13 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 인덱스 7 | 8 | 9 |

13장 예제

10 | 14 | 15 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 인덱스 7 | 8 | 9 |

14장 예제

10 | 14 | 15 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 인덱스 7 | 8 | 9 |

16장 예제

10 | 14 | 15 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/webapp/WEB-INF/view/register/step1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | 3 | 4 | 5 | 회원가입 6 | 7 | 8 |

약관

9 |

약관 내용

10 |
11 | 14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /sp4-chap08/src/sql/ddl.sql: -------------------------------------------------------------------------------- 1 | create user 'spring4'@'localhost' identified by 'spring4'; 2 | 3 | create database spring4fs character set=utf8; 4 | 5 | grant all privileges on spring4fs.* to 'spring4'@'localhost'; 6 | 7 | create table spring4fs.MEMBER ( 8 | ID int auto_increment primary key, 9 | EMAIL varchar(255), 10 | PASSWORD varchar(100), 11 | NAME varchar(100), 12 | REGDATE datetime, 13 | unique key (EMAIL) 14 | ) engine=InnoDB character set = utf8; -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/survey/Respondent.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | public class Respondent { 4 | 5 | private int age; 6 | private String location; 7 | 8 | public int getAge() { 9 | return age; 10 | } 11 | 12 | public void setAge(int age) { 13 | this.age = age; 14 | } 15 | 16 | public String getLocation() { 17 | return location; 18 | } 19 | 20 | public void setLocation(String location) { 21 | this.location = location; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/survey/Respondent.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | public class Respondent { 4 | 5 | private int age; 6 | private String location; 7 | 8 | public int getAge() { 9 | return age; 10 | } 11 | 12 | public void setAge(int age) { 13 | this.age = age; 14 | } 15 | 16 | public String getLocation() { 17 | return location; 18 | } 19 | 20 | public void setLocation(String location) { 21 | this.location = location; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/survey/Respondent.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | public class Respondent { 4 | 5 | private int age; 6 | private String location; 7 | 8 | public int getAge() { 9 | return age; 10 | } 11 | 12 | public void setAge(int age) { 13 | this.age = age; 14 | } 15 | 16 | public String getLocation() { 17 | return location; 18 | } 19 | 20 | public void setLocation(String location) { 21 | this.location = location; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/survey/Respondent.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | public class Respondent { 4 | 5 | private int age; 6 | private String location; 7 | 8 | public int getAge() { 9 | return age; 10 | } 11 | 12 | public void setAge(int age) { 13 | this.age = age; 14 | } 15 | 16 | public String getLocation() { 17 | return location; 18 | } 19 | 20 | public void setLocation(String location) { 21 | this.location = location; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/survey/Respondent.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | public class Respondent { 4 | 5 | private int age; 6 | private String location; 7 | 8 | public int getAge() { 9 | return age; 10 | } 11 | 12 | public void setAge(int age) { 13 | this.age = age; 14 | } 15 | 16 | public String getLocation() { 17 | return location; 18 | } 19 | 20 | public void setLocation(String location) { 21 | this.location = location; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/controller/LogoutController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | @Controller 9 | public class LogoutController { 10 | 11 | @RequestMapping("/logout") 12 | public String logout(HttpSession session) { 13 | session.invalidate(); 14 | return "redirect:/main"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/LogoutController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | @Controller 9 | public class LogoutController { 10 | 11 | @RequestMapping("/logout") 12 | public String logout(HttpSession session) { 13 | session.invalidate(); 14 | return "redirect:/main"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/LogoutController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | @Controller 9 | public class LogoutController { 10 | 11 | @RequestMapping("/logout") 12 | public String logout(HttpSession session) { 13 | session.invalidate(); 14 | return "redirect:/main"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/LogoutController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | @Controller 9 | public class LogoutController { 10 | 11 | @RequestMapping("/logout") 12 | public String logout(HttpSession session) { 13 | session.invalidate(); 14 | return "redirect:/main"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import spring.Client; 6 | 7 | public class Main { 8 | 9 | public static void main(String[] args) { 10 | GenericXmlApplicationContext ctx = 11 | new GenericXmlApplicationContext("classpath:springconf.xml"); 12 | Client client = ctx.getBean("client", Client.class); 13 | client.send(); 14 | ctx.close(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap02/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/conf/JavaConfig.java: -------------------------------------------------------------------------------- 1 | package conf; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import spring.Client2; 7 | 8 | @Configuration 9 | public class JavaConfig { 10 | 11 | @Bean(initMethod = "connect", destroyMethod = "close") 12 | public Client2 client2() { 13 | Client2 client2 = new Client2(); 14 | client2.setHost("서버2"); 15 | return client2; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sp4-chap13/src/sql/initData.sql: -------------------------------------------------------------------------------- 1 | truncate table spring4fs.MEMBER; 2 | 3 | insert into spring4fs.MEMBER values (1, 'madvirus@madvirus.net', '1234', '최범균', '2014-12-01 13:01:02'); 4 | insert into spring4fs.MEMBER values (2, 'bkchoi@bkchio.com', '5678', '최BK', '2014-12-03 18:31:49'); 5 | insert into spring4fs.MEMBER values (3, 'gildong@some.com', '1234', '홍길동', '2014-11-19 00:21:02'); 6 | insert into spring4fs.MEMBER values (4, 'kingsejon@chosunking.org', '1234', '세종대왕', '2014-12-08 19:00:00'); 7 | -------------------------------------------------------------------------------- /sp4-chap02/src/main/java/chap02/Main.java: -------------------------------------------------------------------------------- 1 | package chap02; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:applicationContext.xml"); 9 | Greeter g = ctx.getBean("greeter", Greeter.class); 10 | String msg = g.greet("스프링"); 11 | System.out.println(msg); 12 | ctx.close(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/resources/springconfPrototype.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/resources/conf1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/main/MainProxy.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import chap07.ImpeCalculator; 4 | import chap07.RecCalculator; 5 | import chap07.ExeTimeCalculator; 6 | 7 | public class MainProxy { 8 | 9 | public static void main(String[] args) { 10 | ExeTimeCalculator ttCal1 = new ExeTimeCalculator(new ImpeCalculator()); 11 | System.out.println(ttCal1.factorial(20)); 12 | 13 | ExeTimeCalculator ttCal2 = new ExeTimeCalculator(new RecCalculator()); 14 | System.out.println(ttCal2.factorial(20)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/main/MainXmlOrder.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import chap07.Calculator; 6 | 7 | public class MainXmlOrder { 8 | 9 | public static void main(String[] args) { 10 | GenericXmlApplicationContext ctx = 11 | new GenericXmlApplicationContext("classpath:aopOrder.xml"); 12 | 13 | Calculator impeCal = ctx.getBean("impeCal", Calculator.class); 14 | impeCal.factorial(5); 15 | impeCal.factorial(5); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/AuthInfo.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthInfo { 4 | 5 | private Long id; 6 | private String email; 7 | private String name; 8 | 9 | public AuthInfo(Long id, String email, String name) { 10 | this.id = id; 11 | this.email = email; 12 | this.name = name; 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/AuthInfo.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthInfo { 4 | 5 | private Long id; 6 | private String email; 7 | private String name; 8 | 9 | public AuthInfo(Long id, String email, String name) { 10 | this.id = id; 11 | this.email = email; 12 | this.name = name; 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/AuthInfo.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthInfo { 4 | 5 | private Long id; 6 | private String email; 7 | private String name; 8 | 9 | public AuthInfo(Long id, String email, String name) { 10 | this.id = id; 11 | this.email = email; 12 | this.name = name; 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/AuthInfo.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthInfo { 4 | 5 | private Long id; 6 | private String email; 7 | private String name; 8 | 9 | public AuthInfo(Long id, String email, String name) { 10 | this.id = id; 11 | this.email = email; 12 | this.name = name; 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/conf/JavaConfigPrototype.java: -------------------------------------------------------------------------------- 1 | package conf; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Scope; 6 | 7 | import spring.Client2; 8 | 9 | @Configuration 10 | public class JavaConfigPrototype { 11 | 12 | @Bean 13 | @Scope("prototype") 14 | public Client2 client2() { 15 | Client2 client2 = new Client2(); 16 | client2.setHost("서버2"); 17 | return client2; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap02/src/main/java/chap02/Main2.java: -------------------------------------------------------------------------------- 1 | package chap02; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | public class Main2 { 6 | 7 | public static void main(String[] args) { 8 | GenericXmlApplicationContext ctx = 9 | new GenericXmlApplicationContext("classpath:applicationContext.xml"); 10 | Greeter g1 = ctx.getBean("greeter", Greeter.class); 11 | Greeter g2 = ctx.getBean("greeter", Greeter.class); 12 | System.out.println("(g1 == g2) = " + (g1 == g2)); 13 | ctx.close(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/survey/AnsweredData.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.List; 4 | 5 | public class AnsweredData { 6 | 7 | private List responses; 8 | private Respondent res; 9 | 10 | public List getResponses() { 11 | return responses; 12 | } 13 | 14 | public void setResponses(List responses) { 15 | this.responses = responses; 16 | } 17 | 18 | public Respondent getRes() { 19 | return res; 20 | } 21 | 22 | public void setRes(Respondent res) { 23 | this.res = res; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/survey/AnsweredData.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.List; 4 | 5 | public class AnsweredData { 6 | 7 | private List responses; 8 | private Respondent res; 9 | 10 | public List getResponses() { 11 | return responses; 12 | } 13 | 14 | public void setResponses(List responses) { 15 | this.responses = responses; 16 | } 17 | 18 | public Respondent getRes() { 19 | return res; 20 | } 21 | 22 | public void setRes(Respondent res) { 23 | this.res = res; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/survey/AnsweredData.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.List; 4 | 5 | public class AnsweredData { 6 | 7 | private List responses; 8 | private Respondent res; 9 | 10 | public List getResponses() { 11 | return responses; 12 | } 13 | 14 | public void setResponses(List responses) { 15 | this.responses = responses; 16 | } 17 | 18 | public Respondent getRes() { 19 | return res; 20 | } 21 | 22 | public void setRes(Respondent res) { 23 | this.res = res; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/survey/AnsweredData.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.List; 4 | 5 | public class AnsweredData { 6 | 7 | private List responses; 8 | private Respondent res; 9 | 10 | public List getResponses() { 11 | return responses; 12 | } 13 | 14 | public void setResponses(List responses) { 15 | this.responses = responses; 16 | } 17 | 18 | public Respondent getRes() { 19 | return res; 20 | } 21 | 22 | public void setRes(Respondent res) { 23 | this.res = res; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/survey/AnsweredData.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.List; 4 | 5 | public class AnsweredData { 6 | 7 | private List responses; 8 | private Respondent res; 9 | 10 | public List getResponses() { 11 | return responses; 12 | } 13 | 14 | public void setResponses(List responses) { 15 | this.responses = responses; 16 | } 17 | 18 | public Respondent getRes() { 19 | return res; 20 | } 21 | 22 | public void setRes(Respondent res) { 23 | this.res = res; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberListPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Collection; 4 | 5 | public class MemberListPrinter { 6 | 7 | private MemberDao memberDao; 8 | private MemberPrinter printer; 9 | 10 | public MemberListPrinter(MemberDao memberDao, MemberPrinter printer) { 11 | this.memberDao = memberDao; 12 | this.printer = printer; 13 | } 14 | 15 | public void printAll() { 16 | Collection members = memberDao.selectAll(); 17 | for (Member m : members) { 18 | printer.print(m); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/ConfigPart1.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import spring.MemberDao; 7 | import spring.MemberRegisterService; 8 | 9 | @Configuration 10 | public class ConfigPart1 { 11 | 12 | @Bean 13 | public MemberDao memberDao() { 14 | return new MemberDao(); 15 | } 16 | 17 | @Bean 18 | public MemberRegisterService memberRegSvc() { 19 | return new MemberRegisterService(memberDao()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberListPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Collection; 4 | 5 | public class MemberListPrinter { 6 | 7 | private MemberDao memberDao; 8 | private MemberPrinter printer; 9 | 10 | public MemberListPrinter(MemberDao memberDao, MemberPrinter printer) { 11 | this.memberDao = memberDao; 12 | this.printer = printer; 13 | } 14 | 15 | public void printAll() { 16 | Collection members = memberDao.selectAll(); 17 | for (Member m : members) { 18 | printer.print(m); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/resources/configImport.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class ChangePasswordService { 4 | 5 | private MemberDao memberDao; 6 | 7 | public ChangePasswordService(MemberDao memberDao) { 8 | this.memberDao = memberDao; 9 | } 10 | 11 | public void changePassword(String email, String oldPwd, String newPwd) { 12 | Member member = memberDao.selectByEmail(email); 13 | if (member == null) 14 | throw new MemberNotFoundException(); 15 | 16 | member.changePassword(oldPwd, newPwd); 17 | 18 | memberDao.update(member); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/spring/Client2.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class Client2 { 4 | 5 | private String host; 6 | 7 | public void setHost(String host) { 8 | this.host = host; 9 | System.out.println("Client2.setHost() 실행"); 10 | } 11 | 12 | public void connect() throws Exception { 13 | System.out.println("Client2.connect() 실행"); 14 | } 15 | 16 | public void send() { 17 | System.out.println("Client2.send() to " + host); 18 | } 19 | 20 | public void close() throws Exception { 21 | System.out.println("Client2.close() 실행"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/main/MainXmlAspect.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import chap07.Calculator; 6 | 7 | public class MainXmlAspect { 8 | 9 | public static void main(String[] args) { 10 | GenericXmlApplicationContext ctx = 11 | new GenericXmlApplicationContext("classpath:aopAspect.xml"); 12 | 13 | Calculator impeCal = ctx.getBean("impeCal", Calculator.class); 14 | long fiveFact = impeCal.factorial(5); 15 | System.out.println("impeCal.factorial(5) = " + fiveFact); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/login/loginSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/login/loginSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/login/loginSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/login/loginSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/main/Main2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | 6 | import spring.Client2; 7 | import conf.JavaConfig; 8 | 9 | public class Main2 { 10 | 11 | public static void main(String[] args) { 12 | AbstractApplicationContext ctx = 13 | new AnnotationConfigApplicationContext(JavaConfig.class); 14 | Client2 client = ctx.getBean("client2", Client2.class); 15 | client.send(); 16 | ctx.close(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/webapp/WEB-INF/view/survey/submitted.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 응답 내용 7 | 8 | 9 |

응답 내용:

10 |
    11 | 13 |
  • ${status.index + 1}번 문항: ${response}
  • 14 |
    15 |
16 |

응답자 위치: ${ansData.res.location}

17 |

응답자 나이: ${ansData.res.age}

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/edit/changedPwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/survey/submitted.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 응답 내용 7 | 8 | 9 |

응답 내용:

10 |
    11 | 13 |
  • ${status.index + 1}번 문항: ${response}
  • 14 |
    15 |
16 |

응답자 위치: ${ansData.res.location}

17 |

응답자 나이: ${ansData.res.age}

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/edit/changedPwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/survey/submitted.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 응답 내용 7 | 8 | 9 |

응답 내용:

10 |
    11 | 13 |
  • ${status.index + 1}번 문항: ${response}
  • 14 |
    15 |
16 |

응답자 위치: ${ansData.res.location}

17 |

응답자 나이: ${ansData.res.age}

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/edit/changedPwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/survey/submitted.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 응답 내용 7 | 8 | 9 |

응답 내용:

10 |
    11 | 13 |
  • ${status.index + 1}번 문항: ${response}
  • 14 |
    15 |
16 |

응답자 위치: ${ansData.res.location}

17 |

응답자 나이: ${ansData.res.age}

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/edit/changedPwd.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 |

11 | 12 |

13 |

14 | 15 | [] 16 | 17 |

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/survey/submitted.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 응답 내용 7 | 8 | 9 |

응답 내용:

10 |
    11 | 13 |
  • ${status.index + 1}번 문항: ${response}
  • 14 |
    15 |
16 |

응답자 위치: ${ansData.res.location}

17 |

응답자 나이: ${ansData.res.age}

18 | 19 | -------------------------------------------------------------------------------- /sp4-chap09/src/main/java/chap09/HelloController.java: -------------------------------------------------------------------------------- 1 | package chap09; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | 11 | @RequestMapping("/hello") 12 | public String hello(Model model, 13 | @RequestParam(value = "name", required = false) String name) { 14 | model.addAttribute("greeting", "안녕하세요, " + name); 15 | return "hello"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/controller/ChangePwdCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class ChangePwdCommand { 4 | 5 | private String currentPassword; 6 | private String newPassword; 7 | 8 | public String getCurrentPassword() { 9 | return currentPassword; 10 | } 11 | 12 | public void setCurrentPassword(String currentPassword) { 13 | this.currentPassword = currentPassword; 14 | } 15 | 16 | public String getNewPassword() { 17 | return newPassword; 18 | } 19 | 20 | public void setNewPassword(String newPassword) { 21 | this.newPassword = newPassword; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/ChangePwdCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class ChangePwdCommand { 4 | 5 | private String currentPassword; 6 | private String newPassword; 7 | 8 | public String getCurrentPassword() { 9 | return currentPassword; 10 | } 11 | 12 | public void setCurrentPassword(String currentPassword) { 13 | this.currentPassword = currentPassword; 14 | } 15 | 16 | public String getNewPassword() { 17 | return newPassword; 18 | } 19 | 20 | public void setNewPassword(String newPassword) { 21 | this.newPassword = newPassword; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/ChangePwdCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class ChangePwdCommand { 4 | 5 | private String currentPassword; 6 | private String newPassword; 7 | 8 | public String getCurrentPassword() { 9 | return currentPassword; 10 | } 11 | 12 | public void setCurrentPassword(String currentPassword) { 13 | this.currentPassword = currentPassword; 14 | } 15 | 16 | public String getNewPassword() { 17 | return newPassword; 18 | } 19 | 20 | public void setNewPassword(String newPassword) { 21 | this.newPassword = newPassword; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/ChangePwdCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class ChangePwdCommand { 4 | 5 | private String currentPassword; 6 | private String newPassword; 7 | 8 | public String getCurrentPassword() { 9 | return currentPassword; 10 | } 11 | 12 | public void setCurrentPassword(String currentPassword) { 13 | this.currentPassword = currentPassword; 14 | } 15 | 16 | public String getNewPassword() { 17 | return newPassword; 18 | } 19 | 20 | public void setNewPassword(String newPassword) { 21 | this.newPassword = newPassword; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | import org.springframework.jdbc.core.RowMapper; 7 | 8 | public class MemberRowMapper implements RowMapper { 9 | 10 | @Override 11 | public Member mapRow(ResultSet rs, int rowNum) throws SQLException { 12 | Member member = new Member(rs.getString("EMAIL"), 13 | rs.getString("PASSWORD"), 14 | rs.getString("NAME"), 15 | rs.getTimestamp("REGDATE")); 16 | member.setId(rs.getLong("ID")); 17 | return member; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/resources/sub-conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/main/MainJavaAspect.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | 5 | import chap07.Calculator; 6 | import config.JavaConfig; 7 | 8 | public class MainJavaAspect { 9 | 10 | public static void main(String[] args) { 11 | AnnotationConfigApplicationContext ctx = 12 | new AnnotationConfigApplicationContext(JavaConfig.class); 13 | 14 | Calculator recCal = ctx.getBean("recCal", Calculator.class); 15 | long fiveFact = recCal.factorial(5); 16 | System.out.println("recCal.factorial(5) = " + fiveFact); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/chap07/ExeTimeCalculator.java: -------------------------------------------------------------------------------- 1 | package chap07; 2 | 3 | public class ExeTimeCalculator implements Calculator { 4 | 5 | private Calculator delegate; 6 | 7 | public ExeTimeCalculator(Calculator delegate) { 8 | this.delegate = delegate; 9 | } 10 | 11 | @Override 12 | public long factorial(long num) { 13 | long start = System.nanoTime(); 14 | long result = delegate.factorial(num); 15 | long end = System.nanoTime(); 16 | System.out.printf("%s.factorial(%d) 실행 시간 = %d\n", 17 | delegate.getClass().getSimpleName(), 18 | num, (end - start)); 19 | return result; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/register/step3.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="member.register" /> 8 | 9 | 10 |

11 | 13 |

14 |

15 | 16 | [] 17 | 18 |

19 | 20 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/register/step3.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="member.register" /> 8 | 9 | 10 |

11 | 13 |

14 |

15 | 16 | [] 17 | 18 |

19 | 20 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/register/step3.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="member.register" /> 8 | 9 | 10 |

11 | 13 |

14 |

15 | 16 | [] 17 | 18 |

19 | 20 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/register/step3.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="member.register" /> 8 | 9 | 10 |

11 | 13 |

14 |

15 | 16 | [] 17 | 18 |

19 | 20 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/resources/springconf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/ListCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | public class ListCommand { 8 | 9 | @DateTimeFormat(pattern="yyyyMMddHH") 10 | private Date from; 11 | @DateTimeFormat(pattern="yyyyMMddHH") 12 | private Date to; 13 | 14 | public Date getFrom() { 15 | return from; 16 | } 17 | 18 | public void setFrom(Date from) { 19 | this.from = from; 20 | } 21 | 22 | public Date getTo() { 23 | return to; 24 | } 25 | 26 | public void setTo(Date to) { 27 | this.to = to; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/ListCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | public class ListCommand { 8 | 9 | @DateTimeFormat(pattern="yyyyMMddHH") 10 | private Date from; 11 | @DateTimeFormat(pattern="yyyyMMddHH") 12 | private Date to; 13 | 14 | public Date getFrom() { 15 | return from; 16 | } 17 | 18 | public void setFrom(Date from) { 19 | this.from = from; 20 | } 21 | 22 | public Date getTo() { 23 | return to; 24 | } 25 | 26 | public void setTo(Date to) { 27 | this.to = to; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/ListCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | public class ListCommand { 8 | 9 | @DateTimeFormat(pattern="yyyyMMddHH") 10 | private Date from; 11 | @DateTimeFormat(pattern="yyyyMMddHH") 12 | private Date to; 13 | 14 | public Date getFrom() { 15 | return from; 16 | } 17 | 18 | public void setFrom(Date from) { 19 | this.from = from; 20 | } 21 | 22 | public Date getTo() { 23 | return to; 24 | } 25 | 26 | public void setTo(Date to) { 27 | this.to = to; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberInfoPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberInfoPrinter { 4 | 5 | private MemberDao memDao; 6 | private MemberPrinter printer; 7 | 8 | public void setMemberDao(MemberDao memberDao) { 9 | this.memDao = memberDao; 10 | } 11 | 12 | public void setPrinter(MemberPrinter printer) { 13 | this.printer = printer; 14 | } 15 | 16 | public void printMemberInfo(String email) { 17 | Member member = memDao.selectByEmail(email); 18 | if (member == null) { 19 | System.out.println("데이터 없음\n"); 20 | return; 21 | } 22 | printer.print(member); 23 | System.out.println(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/ConfigPartMain.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Import; 6 | 7 | import spring.MemberDao; 8 | import spring.MemberRegisterService; 9 | 10 | @Configuration 11 | @Import(ConfigPartSub.class) 12 | public class ConfigPartMain { 13 | 14 | @Bean 15 | public MemberDao memberDao() { 16 | return new MemberDao(); 17 | } 18 | 19 | @Bean 20 | public MemberRegisterService memberRegSvc() { 21 | return new MemberRegisterService(memberDao()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberInfoPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class MemberInfoPrinter { 4 | 5 | private MemberDao memDao; 6 | private MemberPrinter printer; 7 | 8 | public void setMemberDao(MemberDao memberDao) { 9 | this.memDao = memberDao; 10 | } 11 | 12 | public void setPrinter(MemberPrinter printer) { 13 | this.printer = printer; 14 | } 15 | 16 | public void printMemberInfo(String email) { 17 | Member member = memDao.selectByEmail(email); 18 | if (member == null) { 19 | System.out.println("데이터 없음\n"); 20 | return; 21 | } 22 | printer.print(member); 23 | System.out.println(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/register/step1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="member.register" /> 7 | 8 | 9 |

10 |

약관 내용

11 |
12 | 16 | " /> 17 |
18 | 19 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/register/step1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="member.register" /> 7 | 8 | 9 |

10 |

약관 내용

11 |
12 | 16 | " /> 17 |
18 | 19 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/register/step1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="member.register" /> 7 | 8 | 9 |

10 |

약관 내용

11 |
12 | 16 | " /> 17 |
18 | 19 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/register/step1.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 3 | 4 | 5 | 6 | <spring:message code="member.register" /> 7 | 8 | 9 |

10 |

약관 내용

11 |
12 | 16 | " /> 17 |
18 | 19 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/MemberInfoPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | 4 | public class MemberInfoPrinter { 5 | 6 | private MemberDao memDao; 7 | private MemberPrinter printer; 8 | 9 | public void setMemberDao(MemberDao memberDao) { 10 | this.memDao = memberDao; 11 | } 12 | 13 | public void setPrinter(MemberPrinter printer) { 14 | this.printer = printer; 15 | } 16 | 17 | public void printMemberInfo(String email) { 18 | Member member = memDao.selectByEmail(email); 19 | if (member == null) { 20 | System.out.println("데이터 없음\n"); 21 | return; 22 | } 23 | printer.print(member); 24 | System.out.println(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/config/JavaConfig.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 6 | 7 | import aspect.ExeTimeAspect2; 8 | import chap07.Calculator; 9 | import chap07.RecCalculator; 10 | 11 | @Configuration 12 | @EnableAspectJAutoProxy 13 | public class JavaConfig { 14 | 15 | @Bean 16 | public ExeTimeAspect2 exeTimeAspect() { 17 | return new ExeTimeAspect2(); 18 | } 19 | 20 | @Bean 21 | public Calculator recCal() { 22 | return new RecCalculator(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/AuthService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthService { 4 | 5 | private MemberDao memberDao; 6 | 7 | public void setMemberDao(MemberDao memberDao) { 8 | this.memberDao = memberDao; 9 | } 10 | 11 | public AuthInfo authenticate(String email, String password) { 12 | Member member = memberDao.selectByEmail(email); 13 | if (member == null) { 14 | throw new IdPasswordNotMatchingException(); 15 | } 16 | if (!member.matchPassword(password)) { 17 | throw new IdPasswordNotMatchingException(); 18 | } 19 | return new AuthInfo(member.getId(), member.getEmail(), member.getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/AuthService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthService { 4 | 5 | private MemberDao memberDao; 6 | 7 | public void setMemberDao(MemberDao memberDao) { 8 | this.memberDao = memberDao; 9 | } 10 | 11 | public AuthInfo authenticate(String email, String password) { 12 | Member member = memberDao.selectByEmail(email); 13 | if (member == null) { 14 | throw new IdPasswordNotMatchingException(); 15 | } 16 | if (!member.matchPassword(password)) { 17 | throw new IdPasswordNotMatchingException(); 18 | } 19 | return new AuthInfo(member.getId(), member.getEmail(), member.getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/AuthService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthService { 4 | 5 | private MemberDao memberDao; 6 | 7 | public void setMemberDao(MemberDao memberDao) { 8 | this.memberDao = memberDao; 9 | } 10 | 11 | public AuthInfo authenticate(String email, String password) { 12 | Member member = memberDao.selectByEmail(email); 13 | if (member == null) { 14 | throw new IdPasswordNotMatchingException(); 15 | } 16 | if (!member.matchPassword(password)) { 17 | throw new IdPasswordNotMatchingException(); 18 | } 19 | return new AuthInfo(member.getId(), member.getEmail(), member.getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/AuthService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class AuthService { 4 | 5 | private MemberDao memberDao; 6 | 7 | public void setMemberDao(MemberDao memberDao) { 8 | this.memberDao = memberDao; 9 | } 10 | 11 | public AuthInfo authenticate(String email, String password) { 12 | Member member = memberDao.selectByEmail(email); 13 | if (member == null) { 14 | throw new IdPasswordNotMatchingException(); 15 | } 16 | if (!member.matchPassword(password)) { 17 | throw new IdPasswordNotMatchingException(); 18 | } 19 | return new AuthInfo(member.getId(), member.getEmail(), member.getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/member/memberDetail.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 5 | 6 | 7 | 8 | 회원 정보 9 | 10 | 11 |

아이디: ${member.id}

12 |

이메일: ${member.email}

13 |

이름: ${member.name}

14 |

가입일:

16 | 17 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/member/memberDetail.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 5 | 6 | 7 | 8 | 회원 정보 9 | 10 | 11 |

아이디: ${member.id}

12 |

이메일: ${member.email}

13 |

이름: ${member.name}

14 |

가입일:

16 | 17 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/member/memberDetail.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 5 | 6 | 7 | 8 | 회원 정보 9 | 10 | 11 |

아이디: ${member.id}

12 |

이메일: ${member.email}

13 |

이름: ${member.name}

14 |

가입일:

16 | 17 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/resources/appCtx.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/ChangePasswordService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.transaction.annotation.Transactional; 4 | 5 | public class ChangePasswordService { 6 | 7 | private MemberDao memberDao; 8 | 9 | public ChangePasswordService(MemberDao memberDao) { 10 | this.memberDao = memberDao; 11 | } 12 | 13 | @Transactional 14 | public void changePassword(String email, String oldPwd, String newPwd) { 15 | Member member = memberDao.selectByEmail(email); 16 | if (member == null) 17 | throw new MemberNotFoundException(); 18 | 19 | member.changePassword(oldPwd, newPwd); 20 | 21 | memberDao.update(member); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class MemberRegisterService { 6 | private MemberDao memberDao; 7 | 8 | public MemberRegisterService(MemberDao memberDao) { 9 | this.memberDao = memberDao; 10 | } 11 | 12 | public void regist(RegisterRequest req) { 13 | Member member = memberDao.selectByEmail(req.getEmail()); 14 | if (member != null) { 15 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 16 | } 17 | Member newMember = new Member( 18 | req.getEmail(), req.getPassword(), req.getName(), 19 | new Date()); 20 | memberDao.insert(newMember); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class MemberRegisterService { 6 | private MemberDao memberDao; 7 | 8 | public MemberRegisterService(MemberDao memberDao) { 9 | this.memberDao = memberDao; 10 | } 11 | 12 | public void regist(RegisterRequest req) { 13 | Member member = memberDao.selectByEmail(req.getEmail()); 14 | if (member != null) { 15 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 16 | } 17 | Member newMember = new Member( 18 | req.getEmail(), req.getPassword(), req.getName(), 19 | new Date()); 20 | memberDao.insert(newMember); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/controller/LoginCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class LoginCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return LoginCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "password", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/LoginCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class LoginCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return LoginCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "password", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/LoginCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class LoginCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return LoginCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "password", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/LoginCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class LoginCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return LoginCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "password", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/MemberDao.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class MemberDao { 8 | 9 | private static long nextId = 0; 10 | 11 | private Map map = new HashMap<>(); 12 | 13 | public Member selectByEmail(String email) { 14 | return map.get(email); 15 | } 16 | 17 | public void insert(Member member) { 18 | member.setId(++nextId); 19 | map.put(member.getEmail(), member); 20 | } 21 | 22 | public void update(Member member) { 23 | map.put(member.getEmail(), member); 24 | } 25 | 26 | public Collection selectAll() { 27 | return map.values(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/MemberDao.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class MemberDao { 8 | 9 | private static long nextId = 0; 10 | 11 | private Map map = new HashMap<>(); 12 | 13 | public Member selectByEmail(String email) { 14 | return map.get(email); 15 | } 16 | 17 | public void insert(Member member) { 18 | member.setId(++nextId); 19 | map.put(member.getEmail(), member); 20 | } 21 | 22 | public void update(Member member) { 23 | map.put(member.getEmail(), member); 24 | } 25 | 26 | public Collection selectAll() { 27 | return map.values(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/MemberDao.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class MemberDao { 8 | 9 | private static long nextId = 0; 10 | 11 | private Map map = new HashMap<>(); 12 | 13 | public Member selectByEmail(String email) { 14 | return map.get(email); 15 | } 16 | 17 | public void insert(Member member) { 18 | member.setId(++nextId); 19 | map.put(member.getEmail(), member); 20 | } 21 | 22 | public void update(Member member) { 23 | map.put(member.getEmail(), member); 24 | } 25 | 26 | public Collection selectAll() { 27 | return map.values(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap09/src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/survey/Question.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Question { 7 | 8 | private String title; 9 | private List options; 10 | 11 | public Question(String title, List options) { 12 | this.title = title; 13 | this.options = options; 14 | } 15 | 16 | 17 | public Question(String title) { 18 | this(title, Collections.emptyList()); 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public List getOptions() { 26 | return options; 27 | } 28 | 29 | public boolean isChoice() { 30 | return options != null && !options.isEmpty(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/controller/ChangePwdCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class ChangePwdCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return ChangePwdCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currentPassword", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "newPassword", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/survey/Question.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Question { 7 | 8 | private String title; 9 | private List options; 10 | 11 | public Question(String title, List options) { 12 | this.title = title; 13 | this.options = options; 14 | } 15 | 16 | 17 | public Question(String title) { 18 | this(title, Collections.emptyList()); 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public List getOptions() { 26 | return options; 27 | } 28 | 29 | public boolean isChoice() { 30 | return options != null && !options.isEmpty(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/ChangePwdCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class ChangePwdCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return ChangePwdCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currentPassword", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "newPassword", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/survey/Question.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Question { 7 | 8 | private String title; 9 | private List options; 10 | 11 | public Question(String title, List options) { 12 | this.title = title; 13 | this.options = options; 14 | } 15 | 16 | 17 | public Question(String title) { 18 | this(title, Collections.emptyList()); 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public List getOptions() { 26 | return options; 27 | } 28 | 29 | public boolean isChoice() { 30 | return options != null && !options.isEmpty(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/ChangePwdCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class ChangePwdCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return ChangePwdCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currentPassword", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "newPassword", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/survey/Question.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Question { 7 | 8 | private String title; 9 | private List options; 10 | 11 | public Question(String title, List options) { 12 | this.title = title; 13 | this.options = options; 14 | } 15 | 16 | 17 | public Question(String title) { 18 | this(title, Collections.emptyList()); 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public List getOptions() { 26 | return options; 27 | } 28 | 29 | public boolean isChoice() { 30 | return options != null && !options.isEmpty(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/ChangePwdCommandValidator.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.validation.Errors; 4 | import org.springframework.validation.ValidationUtils; 5 | import org.springframework.validation.Validator; 6 | 7 | public class ChangePwdCommandValidator implements Validator { 8 | 9 | @Override 10 | public boolean supports(Class clazz) { 11 | return ChangePwdCommand.class.isAssignableFrom(clazz); 12 | } 13 | 14 | @Override 15 | public void validate(Object target, Errors errors) { 16 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currentPassword", "required"); 17 | ValidationUtils.rejectIfEmpty(errors, "newPassword", "required"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/survey/Question.java: -------------------------------------------------------------------------------- 1 | package survey; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | public class Question { 7 | 8 | private String title; 9 | private List options; 10 | 11 | public Question(String title, List options) { 12 | this.title = title; 13 | this.options = options; 14 | } 15 | 16 | 17 | public Question(String title) { 18 | this(title, Collections.emptyList()); 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public List getOptions() { 26 | return options; 27 | } 28 | 29 | public boolean isChoice() { 30 | return options != null && !options.isEmpty(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/JavaSubConf.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import spring.MemberDao; 8 | import spring.MemberPrinter; 9 | import spring.MemberRegisterService; 10 | 11 | @Configuration 12 | public class JavaSubConf { 13 | 14 | @Autowired 15 | private MemberDao memberDao; 16 | 17 | @Bean 18 | public MemberPrinter memberPrinter() { 19 | return new MemberPrinter(); 20 | } 21 | 22 | @Bean 23 | public MemberRegisterService memberRegSvc() { 24 | return new MemberRegisterService(memberDao); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/aspect/CacheAspect.java: -------------------------------------------------------------------------------- 1 | package aspect; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | 8 | public class CacheAspect { 9 | 10 | private Map cache = new HashMap<>(); 11 | 12 | public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { 13 | Long num = (Long) joinPoint.getArgs()[0]; 14 | if (cache.containsKey(num)) { 15 | System.out.printf("CacheAspect: Cache에서 구함[%d]\n", num); 16 | return cache.get(num); 17 | } 18 | 19 | Object result = joinPoint.proceed(); 20 | cache.put(num, result); 21 | System.out.printf("CacheAspect: Cache에 추가[%d]\n", num); 22 | return result; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/VersionPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class VersionPrinter { 4 | 5 | private int majorVersion; 6 | private int minorVersion; 7 | 8 | public VersionPrinter() { 9 | } 10 | 11 | public VersionPrinter(int majorVersion, int minorVersion) { 12 | this.majorVersion = majorVersion; 13 | this.minorVersion = minorVersion; 14 | } 15 | 16 | public void setMajorVersion(int majorVersion) { 17 | this.majorVersion = majorVersion; 18 | } 19 | 20 | public void setMinorVersion(int minorVersion) { 21 | this.minorVersion = minorVersion; 22 | } 23 | 24 | public void print() { 25 | System.out.printf("이 프로그램의 버전은 %d.%d입니다.\n\n", 26 | majorVersion, minorVersion); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/controller/LoginCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class LoginCommand { 4 | 5 | private String email; 6 | private String password; 7 | private boolean rememberEmail; 8 | 9 | public String getEmail() { 10 | return email; 11 | } 12 | 13 | public void setEmail(String email) { 14 | this.email = email; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public void setPassword(String password) { 22 | this.password = password; 23 | } 24 | 25 | public boolean isRememberEmail() { 26 | return rememberEmail; 27 | } 28 | 29 | public void setRememberEmail(boolean rememberEmail) { 30 | this.rememberEmail = rememberEmail; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/LoginCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class LoginCommand { 4 | 5 | private String email; 6 | private String password; 7 | private boolean rememberEmail; 8 | 9 | public String getEmail() { 10 | return email; 11 | } 12 | 13 | public void setEmail(String email) { 14 | this.email = email; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public void setPassword(String password) { 22 | this.password = password; 23 | } 24 | 25 | public boolean isRememberEmail() { 26 | return rememberEmail; 27 | } 28 | 29 | public void setRememberEmail(boolean rememberEmail) { 30 | this.rememberEmail = rememberEmail; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/LoginCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class LoginCommand { 4 | 5 | private String email; 6 | private String password; 7 | private boolean rememberEmail; 8 | 9 | public String getEmail() { 10 | return email; 11 | } 12 | 13 | public void setEmail(String email) { 14 | this.email = email; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public void setPassword(String password) { 22 | this.password = password; 23 | } 24 | 25 | public boolean isRememberEmail() { 26 | return rememberEmail; 27 | } 28 | 29 | public void setRememberEmail(boolean rememberEmail) { 30 | this.rememberEmail = rememberEmail; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/LoginCommand.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | public class LoginCommand { 4 | 5 | private String email; 6 | private String password; 7 | private boolean rememberEmail; 8 | 9 | public String getEmail() { 10 | return email; 11 | } 12 | 13 | public void setEmail(String email) { 14 | this.email = email; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public void setPassword(String password) { 22 | this.password = password; 23 | } 24 | 25 | public boolean isRememberEmail() { 26 | return rememberEmail; 27 | } 28 | 29 | public void setRememberEmail(boolean rememberEmail) { 30 | this.rememberEmail = rememberEmail; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/main/MainXmlPojo.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import chap07.Calculator; 6 | 7 | public class MainXmlPojo { 8 | 9 | public static void main(String[] args) { 10 | GenericXmlApplicationContext ctx = 11 | new GenericXmlApplicationContext("classpath:aopPojo.xml"); 12 | 13 | Calculator impeCal = ctx.getBean("impeCal", Calculator.class); 14 | long fiveFact1 = impeCal.factorial(5); 15 | System.out.println("impeCal.factorial(5) = " + fiveFact1); 16 | 17 | Calculator recCal = ctx.getBean("recCal", Calculator.class); 18 | long fiveFact2 = recCal.factorial(5); 19 | System.out.println("recCal.factorial(5) = " + fiveFact2); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainDevXmlProfile2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | 8 | public class MainDevXmlProfile2 { 9 | 10 | public static void main(String[] args) { 11 | GenericXmlApplicationContext context = new GenericXmlApplicationContext(); 12 | context.getEnvironment().setActiveProfiles("dev"); 13 | context.load("classpath:spring-nested-beans.xml"); 14 | context.refresh(); 15 | 16 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 17 | 18 | for (Member m : memberDao.selectAll()) { 19 | System.out.println(m.getEmail()); 20 | } 21 | 22 | context.close(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/aspect/ExeTimeAspect.java: -------------------------------------------------------------------------------- 1 | package aspect; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.Signature; 7 | 8 | public class ExeTimeAspect { 9 | 10 | public Object measure(ProceedingJoinPoint joinPoint) throws Throwable { 11 | long start = System.nanoTime(); 12 | try { 13 | Object result = joinPoint.proceed(); 14 | return result; 15 | } finally { 16 | long finish = System.nanoTime(); 17 | Signature sig = joinPoint.getSignature(); 18 | System.out.printf("%s.%s(%s) 실행 시간 : %d ns\n", 19 | joinPoint.getTarget().getClass().getSimpleName(), 20 | sig.getName(), Arrays.toString(joinPoint.getArgs()), 21 | (finish - start)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 메인 7 | 8 | 9 | 10 |

환영합니다.

11 |

12 | ">[회원 가입하기] 13 | ">[로그인] 14 |

15 |
16 | 17 | 18 |

${authInfo.name}님, 환영합니다.

19 |

20 | ">[비밀번호 변경] 21 | ">[로그아웃] 22 |

23 |
24 | 25 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 메인 7 | 8 | 9 | 10 |

환영합니다.

11 |

12 | ">[회원 가입하기] 13 | ">[로그인] 14 |

15 |
16 | 17 | 18 |

${authInfo.name}님, 환영합니다.

19 |

20 | ">[비밀번호 변경] 21 | ">[로그아웃] 22 |

23 |
24 | 25 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 메인 7 | 8 | 9 | 10 |

환영합니다.

11 |

12 | ">[회원 가입하기] 13 | ">[로그인] 14 |

15 |
16 | 17 | 18 |

${authInfo.name}님, 환영합니다.

19 |

20 | ">[비밀번호 변경] 21 | ">[로그아웃] 22 |

23 |
24 | 25 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 메인 7 | 8 | 9 | 10 |

환영합니다.

11 |

12 | ">[회원 가입하기] 13 | ">[로그인] 14 |

15 |
16 | 17 | 18 |

${authInfo.name}님, 환영합니다.

19 |

20 | ">[비밀번호 변경] 21 | ">[로그아웃] 22 |

23 |
24 | 25 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/spring-ds-dev.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/spring-ds-real.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/resources/aopAspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | public class MemberRegisterService { 8 | private MemberDao memberDao; 9 | 10 | public MemberRegisterService(MemberDao memberDao) { 11 | this.memberDao = memberDao; 12 | } 13 | 14 | @Transactional 15 | public void regist(RegisterRequest req) { 16 | Member member = memberDao.selectByEmail(req.getEmail()); 17 | if (member != null) { 18 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 19 | } 20 | Member newMember = new Member( 21 | req.getEmail(), req.getPassword(), req.getName(), 22 | new Date()); 23 | memberDao.insert(newMember); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/resources/spring-controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sp4-chap06/src/main/java/spring/Client.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import org.springframework.beans.factory.DisposableBean; 4 | import org.springframework.beans.factory.InitializingBean; 5 | 6 | public class Client implements InitializingBean, DisposableBean { 7 | 8 | private String host; 9 | 10 | public void setHost(String host) { 11 | this.host = host; 12 | System.out.println("Client.setHost() 실행"); 13 | } 14 | 15 | @Override 16 | public void afterPropertiesSet() throws Exception { 17 | System.out.println("Client.afterPropertiesSet() 실행"); 18 | } 19 | 20 | public void send() { 21 | System.out.println("Client.send() to " + host); 22 | } 23 | 24 | @Override 25 | public void destroy() throws Exception { 26 | System.out.println("Client.destroy() 실행"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainDevJavaProfile2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | import config.NestedProfileConfig; 8 | 9 | public class MainDevJavaProfile2 { 10 | 11 | public static void main(String[] args) { 12 | AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); 13 | context.getEnvironment().setActiveProfiles("dev"); 14 | context.register(NestedProfileConfig.class); 15 | context.refresh(); 16 | 17 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 18 | 19 | for (Member m : memberDao.selectAll()) { 20 | System.out.println(m.getEmail()); 21 | } 22 | 23 | context.close(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainXmlPropertyFile.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | 8 | public class MainXmlPropertyFile { 9 | 10 | public static void main(String[] args) { 11 | GenericXmlApplicationContext context = new GenericXmlApplicationContext(); 12 | context.getEnvironment().setActiveProfiles("dev"); 13 | context.load("classpath:spring-member.xml", 14 | "classpath:spring-ds-prop.xml" 15 | ); 16 | context.refresh(); 17 | 18 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 19 | 20 | for (Member m : memberDao.selectAll()) { 21 | System.out.println(m.getEmail()); 22 | } 23 | 24 | context.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/assembler/Assembler.java: -------------------------------------------------------------------------------- 1 | package assembler; 2 | 3 | import spring.ChangePasswordService; 4 | import spring.MemberDao; 5 | import spring.MemberRegisterService; 6 | 7 | public class Assembler { 8 | 9 | private MemberDao memberDao; 10 | private MemberRegisterService regSvc; 11 | private ChangePasswordService pwdSvc; 12 | 13 | public Assembler() { 14 | memberDao = new MemberDao(); 15 | regSvc = new MemberRegisterService(memberDao); 16 | pwdSvc = new ChangePasswordService(memberDao); 17 | } 18 | 19 | public MemberDao getMemberDao() { 20 | return memberDao; 21 | } 22 | 23 | public MemberRegisterService getMemberRegisterService() { 24 | return regSvc; 25 | } 26 | 27 | public ChangePasswordService getChangePasswordService() { 28 | return pwdSvc; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/resources/message/label.properties: -------------------------------------------------------------------------------- 1 | member.register=회원가입 2 | 3 | term=약관 4 | term.agree=약관동의 5 | next.btn=다음단계 6 | 7 | member.info=회원정보 8 | email=이메일 9 | name=이름 10 | password=비밀번호 11 | password.confirm=비밀번호 확인 12 | register.btn=가입 완료 13 | 14 | register.done={0}님, 회원 가입을 완료했습니다. 15 | 16 | go.main=메인으로 이동 17 | 18 | required=필수항목입니다. 19 | bad.email=이메일이 올바르지 않습니다. 20 | duplicate.email=중복된 이메일입니다. 21 | nomatch.confirmPassword=비밀번호와 확인이 일치하지 않습니다. 22 | 23 | login.title=로그인 24 | login.btn=로그인하기 25 | idPasswordNotMatching=아이디와 비밀번호가 일치하지 않습니다. 26 | login.done=로그인에 성공했습니다. 27 | rememberEmail=이메일 기억하기 28 | 29 | change.pwd.title=비밀번호 변경 30 | currentPassword=현재 비밀번호 31 | newPassword=새 비밀번호 32 | change.btn=변경하기 33 | notMatching.currentPassword=비밀번호를 잘못 입력했습니다. 34 | change.pwd.done=비밀번호를 변경했습니다. 35 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/ConfigPartSub.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import spring.MemberDao; 8 | import spring.MemberInfoPrinter; 9 | import spring.MemberPrinter; 10 | 11 | @Configuration 12 | public class ConfigPartSub { 13 | 14 | @Autowired 15 | private MemberDao memberDao; 16 | 17 | @Bean 18 | public MemberPrinter printer() { 19 | return new MemberPrinter(); 20 | } 21 | 22 | @Bean 23 | public MemberInfoPrinter infoPrinter() { 24 | MemberInfoPrinter infoPrinter = new MemberInfoPrinter(); 25 | infoPrinter.setMemberDao(memberDao); 26 | infoPrinter.setPrinter(printer()); 27 | return infoPrinter; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/JavaMainConf.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.ImportResource; 7 | 8 | import spring.MemberDao; 9 | import spring.MemberPrinter; 10 | import spring.MemberRegisterService; 11 | 12 | @Configuration 13 | @ImportResource("classpath:sub-conf.xml") 14 | public class JavaMainConf { 15 | 16 | @Autowired 17 | private MemberDao memberDao; 18 | 19 | @Bean 20 | public MemberPrinter memberPrinter() { 21 | return new MemberPrinter(); 22 | } 23 | 24 | @Bean 25 | public MemberRegisterService memberRegSvc() { 26 | return new MemberRegisterService(memberDao); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainDevXmlProfile1.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.GenericXmlApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | 8 | public class MainDevXmlProfile1 { 9 | 10 | public static void main(String[] args) { 11 | GenericXmlApplicationContext context = new GenericXmlApplicationContext(); 12 | context.getEnvironment().setActiveProfiles("dev"); 13 | context.load("classpath:spring-member.xml", 14 | "classpath:spring-ds-dev.xml", 15 | "classpath:spring-ds-real.xml" 16 | ); 17 | context.refresh(); 18 | 19 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 20 | 21 | for (Member m : memberDao.selectAll()) { 22 | System.out.println(m.getEmail()); 23 | } 24 | 25 | context.close(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainJavaPropertyFile.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | import config.DsPropConfig; 8 | import config.MemberConfig; 9 | 10 | public class MainJavaPropertyFile { 11 | 12 | public static void main(String[] args) { 13 | AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); 14 | context.getEnvironment().setActiveProfiles("dev"); 15 | context.register(MemberConfig.class, DsPropConfig.class); 16 | context.refresh(); 17 | 18 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 19 | 20 | for (Member m : memberDao.selectAll()) { 21 | System.out.println(m.getEmail()); 22 | } 23 | 24 | context.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/interceptor/AuthCheckInterceptor.java: -------------------------------------------------------------------------------- 1 | package interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 8 | 9 | public class AuthCheckInterceptor extends HandlerInterceptorAdapter { 10 | 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, 13 | HttpServletResponse response, Object handler) throws Exception { 14 | HttpSession session = request.getSession(false); 15 | if (session != null) { 16 | Object authInfo = session.getAttribute("authInfo"); 17 | if (authInfo != null) { 18 | return true; 19 | } 20 | } 21 | response.sendRedirect(request.getContextPath()+"/login"); 22 | return false; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/interceptor/AuthCheckInterceptor.java: -------------------------------------------------------------------------------- 1 | package interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 8 | 9 | public class AuthCheckInterceptor extends HandlerInterceptorAdapter { 10 | 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, 13 | HttpServletResponse response, Object handler) throws Exception { 14 | HttpSession session = request.getSession(false); 15 | if (session != null) { 16 | Object authInfo = session.getAttribute("authInfo"); 17 | if (authInfo != null) { 18 | return true; 19 | } 20 | } 21 | response.sendRedirect(request.getContextPath()+"/login"); 22 | return false; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/interceptor/AuthCheckInterceptor.java: -------------------------------------------------------------------------------- 1 | package interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 8 | 9 | public class AuthCheckInterceptor extends HandlerInterceptorAdapter { 10 | 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, 13 | HttpServletResponse response, Object handler) throws Exception { 14 | HttpSession session = request.getSession(false); 15 | if (session != null) { 16 | Object authInfo = session.getAttribute("authInfo"); 17 | if (authInfo != null) { 18 | return true; 19 | } 20 | } 21 | response.sendRedirect(request.getContextPath()+"/login"); 22 | return false; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/interceptor/AuthCheckInterceptor.java: -------------------------------------------------------------------------------- 1 | package interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 8 | 9 | public class AuthCheckInterceptor extends HandlerInterceptorAdapter { 10 | 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, 13 | HttpServletResponse response, Object handler) throws Exception { 14 | HttpSession session = request.getSession(false); 15 | if (session != null) { 16 | Object authInfo = session.getAttribute("authInfo"); 17 | if (authInfo != null) { 18 | return true; 19 | } 20 | } 21 | response.sendRedirect(request.getContextPath()+"/login"); 22 | return false; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/resources/message/label.properties: -------------------------------------------------------------------------------- 1 | member.register=회원가입 2 | 3 | term=약관 4 | term.agree=약관동의 5 | next.btn=다음단계 6 | 7 | member.info=회원정보 8 | email=이메일 9 | name=이름 10 | password=비밀번호 11 | password.confirm=비밀번호 확인 12 | register.btn=가입 완료 13 | 14 | register.done={0}님, 회원 가입을 완료했습니다. 15 | 16 | go.main=메인으로 이동 17 | 18 | required=필수항목입니다. 19 | bad.email=이메일이 올바르지 않습니다. 20 | duplicate.email=중복된 이메일입니다. 21 | nomatch.confirmPassword=비밀번호와 확인이 일치하지 않습니다. 22 | 23 | login.title=로그인 24 | login.btn=로그인하기 25 | idPasswordNotMatching=아이디와 비밀번호가 일치하지 않습니다. 26 | login.done=로그인에 성공했습니다. 27 | rememberEmail=이메일 기억하기 28 | 29 | change.pwd.title=비밀번호 변경 30 | currentPassword=현재 비밀번호 31 | newPassword=새 비밀번호 32 | change.btn=변경하기 33 | notMatching.currentPassword=비밀번호를 잘못 입력했습니다. 34 | change.pwd.done=비밀번호를 변경했습니다. 35 | 36 | typeMismatch.java.util.Date=잘못된 형식 37 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/resources/message/label.properties: -------------------------------------------------------------------------------- 1 | member.register=회원가입 2 | 3 | term=약관 4 | term.agree=약관동의 5 | next.btn=다음단계 6 | 7 | member.info=회원정보 8 | email=이메일 9 | name=이름 10 | password=비밀번호 11 | password.confirm=비밀번호 확인 12 | register.btn=가입 완료 13 | 14 | register.done={0}님, 회원 가입을 완료했습니다. 15 | 16 | go.main=메인으로 이동 17 | 18 | required=필수항목입니다. 19 | bad.email=이메일이 올바르지 않습니다. 20 | duplicate.email=중복된 이메일입니다. 21 | nomatch.confirmPassword=비밀번호와 확인이 일치하지 않습니다. 22 | 23 | login.title=로그인 24 | login.btn=로그인하기 25 | idPasswordNotMatching=아이디와 비밀번호가 일치하지 않습니다. 26 | login.done=로그인에 성공했습니다. 27 | rememberEmail=이메일 기억하기 28 | 29 | change.pwd.title=비밀번호 변경 30 | currentPassword=현재 비밀번호 31 | newPassword=새 비밀번호 32 | change.btn=변경하기 33 | notMatching.currentPassword=비밀번호를 잘못 입력했습니다. 34 | change.pwd.done=비밀번호를 변경했습니다. 35 | 36 | typeMismatch.java.util.Date=잘못된 형식 37 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/message/label.properties: -------------------------------------------------------------------------------- 1 | member.register=회원가입 2 | 3 | term=약관 4 | term.agree=약관동의 5 | next.btn=다음단계 6 | 7 | member.info=회원정보 8 | email=이메일 9 | name=이름 10 | password=비밀번호 11 | password.confirm=비밀번호 확인 12 | register.btn=가입 완료 13 | 14 | register.done={0}님, 회원 가입을 완료했습니다. 15 | 16 | go.main=메인으로 이동 17 | 18 | required=필수항목입니다. 19 | bad.email=이메일이 올바르지 않습니다. 20 | duplicate.email=중복된 이메일입니다. 21 | nomatch.confirmPassword=비밀번호와 확인이 일치하지 않습니다. 22 | 23 | login.title=로그인 24 | login.btn=로그인하기 25 | idPasswordNotMatching=아이디와 비밀번호가 일치하지 않습니다. 26 | login.done=로그인에 성공했습니다. 27 | rememberEmail=이메일 기억하기 28 | 29 | change.pwd.title=비밀번호 변경 30 | currentPassword=현재 비밀번호 31 | newPassword=새 비밀번호 32 | change.btn=변경하기 33 | notMatching.currentPassword=비밀번호를 잘못 입력했습니다. 34 | change.pwd.done=비밀번호를 변경했습니다. 35 | 36 | typeMismatch.java.util.Date=잘못된 형식 37 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/MemberRegisterService.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | import javax.annotation.Resource; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | public class MemberRegisterService { 10 | private MemberDao memberDao; 11 | 12 | @Autowired 13 | public MemberRegisterService(MemberDao memberDao) { 14 | this.memberDao = memberDao; 15 | } 16 | 17 | public MemberRegisterService() { 18 | } 19 | 20 | public void regist(RegisterRequest req) { 21 | Member member = memberDao.selectByEmail(req.getEmail()); 22 | if (member != null) { 23 | throw new AlreadyExistingMemberException("dup email " + req.getEmail()); 24 | } 25 | Member newMember = new Member( 26 | req.getEmail(), req.getPassword(), req.getName(), 27 | new Date()); 28 | memberDao.insert(newMember); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/JavaConfig2.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import spring.MemberDao; 7 | import spring.MemberInfoPrinter; 8 | import spring.MemberPrinter; 9 | import spring.MemberRegisterService; 10 | 11 | @Configuration 12 | public class JavaConfig2 { 13 | 14 | @Bean 15 | public MemberDao memberDao() { 16 | return new MemberDao(); 17 | } 18 | 19 | @Bean 20 | public MemberRegisterService memberRegSvc() { 21 | return new MemberRegisterService(memberDao()); 22 | } 23 | 24 | @Bean 25 | public MemberPrinter printer() { 26 | return new MemberPrinter(); 27 | } 28 | 29 | @Bean 30 | public MemberInfoPrinter infoPrinter() { 31 | MemberInfoPrinter infoPrinter = new MemberInfoPrinter(); 32 | return infoPrinter; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/resources/main-conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/edit/changePwdForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 | 11 |

12 | 16 |

17 |

18 | 22 |

23 | "> 24 |
25 | 26 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/edit/changePwdForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 | 11 |

12 | 16 |

17 |

18 | 22 |

23 | "> 24 |
25 | 26 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/edit/changePwdForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 | 11 |

12 | 16 |

17 |

18 | 22 |

23 | "> 24 |
25 | 26 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/edit/changePwdForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="change.pwd.title" /> 8 | 9 | 10 | 11 |

12 | 16 |

17 |

18 | 22 |

23 | "> 24 |
25 | 26 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/main/MainDevJavaProfile1.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | 5 | import spring.Member; 6 | import spring.MemberDao; 7 | import config.DsDevConfig; 8 | import config.DsRealConfig; 9 | import config.MemberConfig; 10 | 11 | public class MainDevJavaProfile1 { 12 | 13 | public static void main(String[] args) { 14 | AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); 15 | context.getEnvironment().setActiveProfiles("dev"); 16 | context.register(MemberConfig.class, DsDevConfig.class, DsRealConfig.class); 17 | context.refresh(); 18 | 19 | MemberDao memberDao = context.getBean("memberDao", MemberDao.class); 20 | 21 | for (Member m : memberDao.selectAll()) { 22 | System.out.println(m.getEmail()); 23 | } 24 | 25 | context.close(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/resources/appCtx1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/config/DsDevConfig.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import java.beans.PropertyVetoException; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Profile; 10 | 11 | import com.mchange.v2.c3p0.ComboPooledDataSource; 12 | 13 | @Configuration 14 | @Profile("dev") 15 | public class DsDevConfig { 16 | 17 | @Bean 18 | public DataSource dataSource() { 19 | ComboPooledDataSource ds = new ComboPooledDataSource(); 20 | try { 21 | ds.setDriverClass("com.mysql.jdbc.Driver"); 22 | } catch (PropertyVetoException e) { 23 | throw new RuntimeException(e); 24 | } 25 | ds.setJdbcUrl("jdbc:mysql://localhost/spring4fs?characterEncoding=utf8"); 26 | ds.setUser("spring4"); 27 | ds.setPassword("spring4"); 28 | return ds; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/config/DsRealConfig.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import java.beans.PropertyVetoException; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Profile; 10 | 11 | import com.mchange.v2.c3p0.ComboPooledDataSource; 12 | 13 | @Configuration 14 | @Profile("real") 15 | public class DsRealConfig { 16 | 17 | @Bean 18 | public DataSource dataSource() { 19 | ComboPooledDataSource ds = new ComboPooledDataSource(); 20 | try { 21 | ds.setDriverClass("com.mysql.jdbc.Driver"); 22 | } catch (PropertyVetoException e) { 23 | throw new RuntimeException(e); 24 | } 25 | ds.setJdbcUrl("jdbc:mysql://realhost/realdb?characterEncoding=utf8"); 26 | ds.setUser("realuser"); 27 | ds.setPassword("realpw"); 28 | return ds; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/main/Main4.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | 9 | public class Main4 { 10 | 11 | public static void main(String[] args) { 12 | // MemberRegisterService가 정상 동작하려면 다음의 세 가지 필요 13 | // 1. MemberRegisterService 생성자의 @Autowired의 required 값을 false로 지정 14 | // 2. MemberInfoPrinter의 memDao 필드의 @Autowired의 required 값을 false로 지정 15 | // 3. MemberInfoPrinter 클래스의 setPrinter() 메서드에 추가한 @Qualifier("sysout") 코드 삭제 16 | ApplicationContext ctx = new GenericXmlApplicationContext("classpath:appCtx4.xml"); 17 | MemberRegisterService regSvc = ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = ctx.getBean("infoPrinter", MemberInfoPrinter.class); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/MemberInfoPrinter.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Qualifier; 7 | 8 | public class MemberInfoPrinter { 9 | 10 | @Autowired 11 | private MemberDao memDao; 12 | private MemberPrinter printer; 13 | 14 | public void setMemberDao(MemberDao memberDao) { 15 | this.memDao = memberDao; 16 | } 17 | 18 | @Autowired 19 | //@Qualifier("sysout") 20 | public void setPrinter(MemberPrinter printer) { 21 | System.out.println("setPrinter: " + printer); 22 | this.printer = printer; 23 | } 24 | 25 | public void printMemberInfo(String email) { 26 | Member member = memDao.selectByEmail(email); 27 | if (member == null) { 28 | System.out.println("데이터 없음\n"); 29 | return; 30 | } 31 | printer.print(member); 32 | System.out.println(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/resources/appCtx5.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/ConfigPart2.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import spring.MemberDao; 8 | import spring.MemberInfoPrinter; 9 | import spring.MemberPrinter; 10 | 11 | @Configuration 12 | public class ConfigPart2 { 13 | 14 | @Autowired 15 | private MemberDao memberDao; 16 | 17 | // @Autowired 18 | // private ConfigPart1 configPart1; 19 | 20 | @Bean 21 | public MemberPrinter printer() { 22 | return new MemberPrinter(); 23 | } 24 | 25 | @Bean 26 | public MemberInfoPrinter infoPrinter() { 27 | MemberInfoPrinter infoPrinter = new MemberInfoPrinter(); 28 | infoPrinter.setMemberDao(memberDao); 29 | //infoPrinter.setMemberDao(configPart1.memberDao()); 30 | infoPrinter.setPrinter(printer()); 31 | return infoPrinter; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/JavaConfig.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import spring.MemberDao; 7 | import spring.MemberInfoPrinter; 8 | import spring.MemberPrinter; 9 | import spring.MemberRegisterService; 10 | 11 | @Configuration 12 | public class JavaConfig { 13 | 14 | @Bean 15 | public MemberDao memberDao() { 16 | return new MemberDao(); 17 | } 18 | 19 | @Bean 20 | public MemberRegisterService memberRegSvc() { 21 | return new MemberRegisterService(memberDao()); 22 | } 23 | 24 | @Bean 25 | public MemberPrinter printer() { 26 | return new MemberPrinter(); 27 | } 28 | 29 | @Bean 30 | public MemberInfoPrinter infoPrinter() { 31 | MemberInfoPrinter infoPrinter = new MemberInfoPrinter(); 32 | infoPrinter.setMemberDao(memberDao()); 33 | infoPrinter.setPrinter(printer()); 34 | return infoPrinter; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/resources/appCtx2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/spring-ds-prop.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | 10 | public class Main { 11 | 12 | public static void main(String[] args) { 13 | ApplicationContext ctx = new GenericXmlApplicationContext("classpath:appCtx1.xml"); 14 | MemberRegisterService regSvc = ctx.getBean("memberRegSvc", MemberRegisterService.class); 15 | MemberInfoPrinter infoPrinter = ctx.getBean("infoPrinter", MemberInfoPrinter.class); 16 | 17 | RegisterRequest regReq = new RegisterRequest(); 18 | regReq.setEmail("madvirus@madvirus.net"); 19 | regReq.setName("최범균"); 20 | regReq.setPassword("1234"); 21 | regReq.setConfirmPassword("1234"); 22 | regSvc.regist(regReq); 23 | 24 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sp4-chap02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | sp4 8 | sp4-chap02 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 13 | org.springframework 14 | spring-context 15 | 4.1.0.RELEASE 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.1 24 | 25 | 1.7 26 | 1.7 27 | utf-8 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sp4-chap03/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | sp4 8 | sp4-chap03 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 13 | org.springframework 14 | spring-context 15 | 4.1.0.RELEASE 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.1 24 | 25 | 1.7 26 | 1.7 27 | utf-8 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sp4-chap04/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | sp4 8 | sp4-chap04 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 13 | org.springframework 14 | spring-context 15 | 4.1.0.RELEASE 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.1 24 | 25 | 1.7 26 | 1.7 27 | utf-8 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/resources/appCtx3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/resources/appCtx4.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | -------------------------------------------------------------------------------- /sp4-chap05/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | sp4 8 | sp4-chap05 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 13 | org.springframework 14 | spring-context 15 | 4.1.0.RELEASE 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.1 24 | 25 | 1.7 26 | 1.7 27 | utf-8 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sp4-chap06/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | sp4 8 | sp4-chap06 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 13 | org.springframework 14 | spring-context 15 | 4.1.0.RELEASE 16 | 17 | 18 | 19 | 20 | 21 | 22 | maven-compiler-plugin 23 | 3.1 24 | 25 | 1.7 26 | 1.7 27 | utf-8 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/config/JavaConfig3.java: -------------------------------------------------------------------------------- 1 | package config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import spring.MemberDao; 7 | import spring.MemberInfoPrinter; 8 | import spring.MemberPrinter; 9 | import spring.MemberRegisterService; 10 | 11 | @Configuration 12 | public class JavaConfig3 { 13 | 14 | @Bean 15 | public MemberDao memberDao() { 16 | return new MemberDao(); 17 | } 18 | 19 | @Bean 20 | public MemberRegisterService memberRegSvc(MemberDao memDao) { 21 | return new MemberRegisterService(memDao); 22 | } 23 | 24 | @Bean 25 | public MemberPrinter printer() { 26 | return new MemberPrinter(); 27 | } 28 | 29 | @Bean 30 | public MemberInfoPrinter infoPrinter(MemberDao memDao, MemberPrinter memPrinter) { 31 | MemberInfoPrinter infoPrinter = new MemberInfoPrinter(); 32 | infoPrinter.setMemberDao(memDao); 33 | infoPrinter.setPrinter(memPrinter); 34 | return infoPrinter; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/main/MainForCPS.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.support.AbstractApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.ChangePasswordService; 7 | import spring.IdPasswordNotMatchingException; 8 | import spring.MemberNotFoundException; 9 | 10 | public class MainForCPS { 11 | 12 | public static void main(String[] args) { 13 | AbstractApplicationContext ctx = 14 | new GenericXmlApplicationContext("classpath:appCtx.xml"); 15 | 16 | ChangePasswordService cps = 17 | ctx.getBean("changePwdSvc", ChangePasswordService.class); 18 | try { 19 | cps.changePassword("madvirus@madvirus.net", "1234", "1111"); 20 | System.out.println("암호를 변경했습니다."); 21 | } catch (MemberNotFoundException e) { 22 | System.out.println("회원 데이터가 존재하지 않습니다."); 23 | } catch (IdPasswordNotMatchingException e) { 24 | System.out.println("암호가 올바르지 않습니다."); 25 | } 26 | 27 | ctx.close(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | message.label 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/webapp/WEB-INF/view/login/loginForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 | 11 | 12 |

13 | 17 |

18 |

19 | 23 |

24 |

25 | 28 |

29 | "> 30 |
31 | 32 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | message.label 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/login/loginForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 | 11 | 12 |

13 | 17 |

18 |

19 | 23 |

24 |

25 | 28 |

29 | "> 30 |
31 | 32 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/login/loginForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 | 11 | 12 |

13 | 17 |

18 |

19 | 23 |

24 |

25 | 28 |

29 | "> 30 |
31 | 32 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/resources/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | message.label 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/webapp/WEB-INF/view/login/loginForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 4 | 5 | 6 | 7 | <spring:message code="login.title" /> 8 | 9 | 10 | 11 | 12 |

13 | 17 |

18 |

19 | 23 |

24 |

25 | 28 |

29 | "> 30 |
31 | 32 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | public class RegisterRequest { 4 | 5 | private String email; 6 | private String password; 7 | private String confirmPassword; 8 | private String name; 9 | 10 | public String getEmail() { 11 | return email; 12 | } 13 | 14 | public void setEmail(String email) { 15 | this.email = email; 16 | } 17 | 18 | public String getPassword() { 19 | return password; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public String getConfirmPassword() { 27 | return confirmPassword; 28 | } 29 | 30 | public void setConfirmPassword(String confirmPassword) { 31 | this.confirmPassword = confirmPassword; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isPasswordEqualToConfirmPassword() { 43 | return password.equals(confirmPassword); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.JavaConfig; 10 | 11 | public class Main { 12 | 13 | public static void main(String[] args) { 14 | ApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(JavaConfig.class); 16 | MemberRegisterService regSvc = 17 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = 19 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 20 | 21 | RegisterRequest regReq = new RegisterRequest(); 22 | regReq.setEmail("madvirus@madvirus.net"); 23 | regReq.setName("최범균"); 24 | regReq.setPassword("1234"); 25 | regReq.setConfirmPassword("1234"); 26 | regSvc.regist(regReq); 27 | 28 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/java/aspect/ExeTimeAspect2.java: -------------------------------------------------------------------------------- 1 | package aspect; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.aspectj.lang.ProceedingJoinPoint; 6 | import org.aspectj.lang.Signature; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | 11 | @Aspect 12 | public class ExeTimeAspect2 { 13 | 14 | @Pointcut("execution(public * chap07..*(..))") 15 | private void publicTarget() { 16 | } 17 | 18 | @Around("publicTarget()") 19 | public Object measure(ProceedingJoinPoint joinPoint) throws Throwable { 20 | long start = System.nanoTime(); 21 | try { 22 | Object result = joinPoint.proceed(); 23 | return result; 24 | } finally { 25 | long finish = System.nanoTime(); 26 | Signature sig = joinPoint.getSignature(); 27 | System.out.printf("%s.%s(%s) 실행 시간 : %d ns\n", 28 | joinPoint.getTarget().getClass().getSimpleName(), 29 | sig.getName(), Arrays.toString(joinPoint.getArgs()), 30 | (finish - start)); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/main/MainForJC.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | 6 | import spring.ChangePasswordService; 7 | import spring.IdPasswordNotMatchingException; 8 | import spring.MemberNotFoundException; 9 | import config.AppConfig; 10 | 11 | public class MainForJC { 12 | 13 | public static void main(String[] args) { 14 | AbstractApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(AppConfig.class); 16 | 17 | ChangePasswordService cps = 18 | ctx.getBean("changePwdSvc", ChangePasswordService.class); 19 | try { 20 | cps.changePassword("madvirus@madvirus.net", "1234", "1111"); 21 | System.out.println("암호를 변경했습니다."); 22 | } catch (MemberNotFoundException e) { 23 | System.out.println("회원 데이터가 존재하지 않습니다."); 24 | } catch (IdPasswordNotMatchingException e) { 25 | System.out.println("암호가 올바르지 않습니다."); 26 | } 27 | 28 | ctx.close(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/Main3.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.JavaConfig3; 10 | 11 | public class Main3 { 12 | 13 | public static void main(String[] args) { 14 | ApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(JavaConfig3.class); 16 | MemberRegisterService regSvc = 17 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = 19 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 20 | 21 | RegisterRequest regReq = new RegisterRequest(); 22 | regReq.setEmail("madvirus@madvirus.net"); 23 | regReq.setName("최범균"); 24 | regReq.setPassword("1234"); 25 | regReq.setConfirmPassword("1234"); 26 | regSvc.regist(regReq); 27 | 28 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/MainJavaXml.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.JavaMainConf; 10 | 11 | public class MainJavaXml { 12 | 13 | public static void main(String[] args) { 14 | ApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(JavaMainConf.class); 16 | MemberRegisterService regSvc = 17 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = 19 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 20 | 21 | RegisterRequest regReq = new RegisterRequest(); 22 | regReq.setEmail("madvirus@madvirus.net"); 23 | regReq.setName("최범균"); 24 | regReq.setPassword("1234"); 25 | regReq.setConfirmPassword("1234"); 26 | regSvc.regist(regReq); 27 | 28 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/MainTwoConfs2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.ConfigPartMain; 10 | 11 | public class MainTwoConfs2 { 12 | 13 | public static void main(String[] args) { 14 | ApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(ConfigPartMain.class); 16 | MemberRegisterService regSvc = 17 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = 19 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 20 | 21 | RegisterRequest regReq = new RegisterRequest(); 22 | regReq.setEmail("madvirus@madvirus.net"); 23 | regReq.setName("최범균"); 24 | regReq.setPassword("1234"); 25 | regReq.setConfirmPassword("1234"); 26 | regSvc.regist(regReq); 27 | 28 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/main/Main3.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | 10 | public class Main3 { 11 | 12 | public static void main(String[] args) { 13 | // 이 코드를 정상적으로 실행하면 다음의 코드 변경 필요 14 | // 1. MemberInfoPrinter 클래스의 setPrinter() 메서드에 @Qualifier("sysout") 코드 추가 15 | ApplicationContext ctx = new GenericXmlApplicationContext("classpath:appCtx3.xml"); 16 | MemberRegisterService regSvc = ctx.getBean("memberRegSvc", MemberRegisterService.class); 17 | MemberInfoPrinter infoPrinter = ctx.getBean("infoPrinter", MemberInfoPrinter.class); 18 | 19 | RegisterRequest regReq = new RegisterRequest(); 20 | regReq.setEmail("madvirus@madvirus.net"); 21 | regReq.setName("최범균"); 22 | regReq.setPassword("1234"); 23 | regReq.setConfirmPassword("1234"); 24 | regSvc.regist(regReq); 25 | 26 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/Main2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.JavaConfig2; 10 | 11 | public class Main2 { 12 | // MemberInfoPrinter의 set 메서드에 @Autowired 적용해야 정상 동작 13 | public static void main(String[] args) { 14 | ApplicationContext ctx = 15 | new AnnotationConfigApplicationContext(JavaConfig2.class); 16 | MemberRegisterService regSvc = 17 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 18 | MemberInfoPrinter infoPrinter = 19 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 20 | 21 | RegisterRequest regReq = new RegisterRequest(); 22 | regReq.setEmail("madvirus@madvirus.net"); 23 | regReq.setName("최범균"); 24 | regReq.setPassword("1234"); 25 | regReq.setConfirmPassword("1234"); 26 | regSvc.regist(regReq); 27 | 28 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sp4-chap07/src/main/resources/aopPojo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sp4-chap08/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sp4-chap11/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/main/Main5.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | 10 | public class Main5 { 11 | 12 | public static void main(String[] args) { 13 | ApplicationContext ctx = new GenericXmlApplicationContext("classpath:appCtx5.xml"); 14 | MemberRegisterService regSvc = ctx.getBean("memberRegSvc", MemberRegisterService.class); 15 | MemberInfoPrinter infoPrinter = ctx.getBean("infoPrinter", MemberInfoPrinter.class); 16 | 17 | RegisterRequest regReq = new RegisterRequest(); 18 | regReq.setEmail("madvirus@madvirus.net"); 19 | regReq.setName("최범균"); 20 | regReq.setPassword("1234"); 21 | regReq.setConfirmPassword("1234"); 22 | regSvc.regist(regReq); 23 | 24 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 25 | 26 | System.out.println("printer = " + ctx.getBean("printer")); 27 | System.out.println("printer2 = " + ctx.getBean("printer2")); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/MainTwoConfs.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | import config.ConfigPart1; 10 | import config.ConfigPart2; 11 | 12 | public class MainTwoConfs { 13 | 14 | public static void main(String[] args) { 15 | ApplicationContext ctx = 16 | new AnnotationConfigApplicationContext( 17 | ConfigPart1.class, ConfigPart2.class); 18 | MemberRegisterService regSvc = 19 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 20 | MemberInfoPrinter infoPrinter = 21 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 22 | 23 | RegisterRequest regReq = new RegisterRequest(); 24 | regReq.setEmail("madvirus@madvirus.net"); 25 | regReq.setName("최범균"); 26 | regReq.setPassword("1234"); 27 | regReq.setConfirmPassword("1234"); 28 | regSvc.regist(regReq); 29 | 30 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sp4-chap04/src/main/java/main/Main2.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.GenericXmlApplicationContext; 5 | 6 | import spring.MemberInfoPrinter; 7 | import spring.MemberRegisterService; 8 | import spring.RegisterRequest; 9 | 10 | public class Main2 { 11 | 12 | public static void main(String[] args) { 13 | // 이 코드를 실행하면, MemberInfoPrinter 클래스의 @Autowired가 적용된 setPrinter() 메서드에 14 | // MemberPrinter 타입의 두 빈 객체 중 어떤 객체를 주입해야 할지 모르기 때문에 익셉션이 발생한다. 15 | ApplicationContext ctx = new GenericXmlApplicationContext("classpath:appCtx2.xml"); 16 | MemberRegisterService regSvc = ctx.getBean("memberRegSvc", MemberRegisterService.class); 17 | MemberInfoPrinter infoPrinter = ctx.getBean("infoPrinter", MemberInfoPrinter.class); 18 | 19 | RegisterRequest regReq = new RegisterRequest(); 20 | regReq.setEmail("madvirus@madvirus.net"); 21 | regReq.setName("최범균"); 22 | regReq.setPassword("1234"); 23 | regReq.setConfirmPassword("1234"); 24 | regSvc.regist(regReq); 25 | 26 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sp4-chap03/src/main/resources/conf2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sp4-chap05/src/main/java/main/MainXmlJava.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.support.GenericXmlApplicationContext; 6 | 7 | import spring.MemberInfoPrinter; 8 | import spring.MemberRegisterService; 9 | import spring.RegisterRequest; 10 | import config.JavaMainConf; 11 | 12 | public class MainXmlJava { 13 | 14 | public static void main(String[] args) { 15 | ApplicationContext ctx = 16 | new GenericXmlApplicationContext("classpath:main-conf.xml"); 17 | MemberRegisterService regSvc = 18 | ctx.getBean("memberRegSvc", MemberRegisterService.class); 19 | MemberInfoPrinter infoPrinter = 20 | ctx.getBean("infoPrinter", MemberInfoPrinter.class); 21 | 22 | RegisterRequest regReq = new RegisterRequest(); 23 | regReq.setEmail("madvirus@madvirus.net"); 24 | regReq.setName("최범균"); 25 | regReq.setPassword("1234"); 26 | regReq.setConfirmPassword("1234"); 27 | regSvc.regist(regReq); 28 | 29 | infoPrinter.printMemberInfo("madvirus@madvirus.net"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sp4-chap07/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | sp4 7 | sp4-chap07 8 | 0.0.1-SNAPSHOT 9 | 10 | 11 | 12 | org.springframework 13 | spring-context 14 | 4.1.0.RELEASE 15 | 16 | 17 | org.aspectj 18 | aspectjweaver 19 | 1.8.2 20 | 21 | 22 | 23 | 24 | 25 | 26 | maven-compiler-plugin 27 | 3.1 28 | 29 | 1.7 30 | 1.7 31 | utf-8 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/controller/MemberListController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.Errors; 8 | import org.springframework.web.bind.annotation.ModelAttribute; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | import spring.Member; 12 | import spring.MemberDao; 13 | 14 | @Controller 15 | public class MemberListController { 16 | 17 | private MemberDao memberDao; 18 | 19 | public void setMemberDao(MemberDao memberDao) { 20 | this.memberDao = memberDao; 21 | } 22 | 23 | @RequestMapping("/member/list") 24 | public String list( 25 | @ModelAttribute("cmd") ListCommand listCommand, 26 | Errors errors, Model model) { 27 | if (errors.hasErrors()) { 28 | return "member/memberList"; 29 | } 30 | if (listCommand.getFrom() != null && listCommand.getTo() != null) { 31 | List members = memberDao.selectByRegdate( 32 | listCommand.getFrom(), listCommand.getTo()); 33 | model.addAttribute("members", members); 34 | } 35 | return "member/memberList"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/controller/MemberListController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.Errors; 8 | import org.springframework.web.bind.annotation.ModelAttribute; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | import spring.Member; 12 | import spring.MemberDao; 13 | 14 | @Controller 15 | public class MemberListController { 16 | 17 | private MemberDao memberDao; 18 | 19 | public void setMemberDao(MemberDao memberDao) { 20 | this.memberDao = memberDao; 21 | } 22 | 23 | @RequestMapping("/member/list") 24 | public String list( 25 | @ModelAttribute("cmd") ListCommand listCommand, 26 | Errors errors, Model model) { 27 | if (errors.hasErrors()) { 28 | return "member/memberList"; 29 | } 30 | if (listCommand.getFrom() != null && listCommand.getTo() != null) { 31 | List members = memberDao.selectByRegdate( 32 | listCommand.getFrom(), listCommand.getTo()); 33 | model.addAttribute("members", members); 34 | } 35 | return "member/memberList"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/controller/MemberListController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.Errors; 8 | import org.springframework.web.bind.annotation.ModelAttribute; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | import spring.Member; 12 | import spring.MemberDao; 13 | 14 | @Controller 15 | public class MemberListController { 16 | 17 | private MemberDao memberDao; 18 | 19 | public void setMemberDao(MemberDao memberDao) { 20 | this.memberDao = memberDao; 21 | } 22 | 23 | @RequestMapping("/member/list") 24 | public String list( 25 | @ModelAttribute("cmd") ListCommand listCommand, 26 | Errors errors, Model model) { 27 | if (errors.hasErrors()) { 28 | return "member/memberList"; 29 | } 30 | if (listCommand.getFrom() != null && listCommand.getTo() != null) { 31 | List members = memberDao.selectByRegdate( 32 | listCommand.getFrom(), listCommand.getTo()); 33 | model.addAttribute("members", members); 34 | } 35 | return "member/memberList"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sp4-chap12/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | public boolean matchPassword(String pwd) { 51 | return this.password.equals(pwd); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | public boolean matchPassword(String pwd) { 51 | return this.password.equals(pwd); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | public boolean matchPassword(String pwd) { 51 | return this.password.equals(pwd); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /sp4-chap16/src/main/java/spring/Member.java: -------------------------------------------------------------------------------- 1 | package spring; 2 | 3 | import java.util.Date; 4 | 5 | public class Member { 6 | 7 | private Long id; 8 | private String email; 9 | private String password; 10 | private String name; 11 | private Date registerDate; 12 | 13 | public Member(String email, String password, String name, Date registerDate) { 14 | this.email = email; 15 | this.password = password; 16 | this.name = name; 17 | this.registerDate = registerDate; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public String getEmail() { 29 | return email; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public Date getRegisterDate() { 41 | return registerDate; 42 | } 43 | 44 | public void changePassword(String oldPassword, String newPassword) { 45 | if (!password.equals(oldPassword)) 46 | throw new IdPasswordNotMatchingException(); 47 | this.password = newPassword; 48 | } 49 | 50 | public boolean matchPassword(String pwd) { 51 | return this.password.equals(pwd); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 스프링4 입문 예제 코드 2 | ======= 3 | 4 | # 소스 코드 다운로드 5 | 6 | * **메이븐 프로젝트** 다운로드: 이 화면의 우측에 있는 [Download Zip](https://github.com/madvirus/spring4fs/archive/master.zip) 링크를 누르면 소스 코드를 다운로드 받는다. 7 | * **이클립스 프로젝트** 다운로드: [소스 다운로드](https://drive.google.com/file/d/0B2WFL4DD6ByEdWZELXRhLWNkMW8/view?usp=sharing)로 이동한 뒤, 상단의 다운로드 아이콘을 클릭해서 다운로드 받는다. 8 | 9 | # 사전 준비 10 | ## 이클립스 설정 11 | 제공되는 소스는 메이븐 프로젝트이며 다음을 기준으로 작성되었다. 12 | 13 | - **자바7** 또는 **자바8** 14 | -- Window > Preferences > Java/Installed JREs 에서 추가 15 | - **UTF-8** 16 | -- Window > Preferences > General/Workspace 에서 Text file encoding을 UTF-8로 변경 17 | -- 프로젝트를 임포트 한 뒤, 프로젝트 별로 Project > Properties > Resource 에서 Text file encoding을 UTF-8로 변경해도 됨 18 | - **톰캣 7** 19 | -- Window > Preferences > Servers/Runtime Environments 에서 톰캣 7 설정 추가 20 | 21 | ## 메이븐 설정 22 | 명령 프롬프트에서 메이븐을 이용해서 웹 프로젝트를 실행하려면 메이븐이 설치되어 있어야 한다. 메이븐에 대한 기초 지식이 필요하면 http://javacan.tistory.com/entry/MavenBasic 글을 읽어보기 바란다. 23 | 24 | # 프로젝트 임포트 25 | ## 메이븐 프로젝트 임포트 26 | 이 화면의 우측에 있는 [Download Zip](https://github.com/madvirus/spring4fs/archive/master.zip) 링크를 누르면 소스 코드를 다운로드 받는다. 27 | 이 파일의 압축을 풀면 sp4-chapxx 형식의 메이븐 프로젝트가 존재한다. 28 | 29 | File > Import ... > Maven/Existing Maven Projects 메뉴를 이용해서 메이븐 프로젝트를 임포트 한다. 30 | 31 | -------------------------------------------------------------------------------- /sp4-chap13/src/main/webapp/WEB-INF/view/member/memberList.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 5 | 6 | 7 | 8 | 회원 조회 9 | 10 | 11 | 12 |

13 | 14 | 15 | ~ 16 | 17 | 18 | 19 |

20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 36 | 37 | 38 |
아이디이메일이름가입일
${mem.id}"> 32 | ${mem.email}${mem.name}
39 |
40 | 41 | -------------------------------------------------------------------------------- /sp4-chap14/src/main/webapp/WEB-INF/view/member/memberList.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html; charset=utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 4 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 5 | 6 | 7 | 8 | 회원 조회 9 | 10 | 11 | 12 |

13 | 14 | 15 | ~ 16 | 17 | 18 | 19 |

20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 36 | 37 | 38 |
아이디이메일이름가입일
${mem.id}"> 32 | ${mem.email}${mem.name}
39 |
40 | 41 | --------------------------------------------------------------------------------