├── Code Bundle ├── GitHub Link for this Course.txt └── spring-master-class-master │ ├── .gitignore │ ├── 00-framework-tool-introductions │ ├── 01.Eclipse-Introduction-in-5-steps │ │ ├── .gitignore │ │ ├── code-21July2017.zip │ │ ├── readme.md │ │ └── src │ │ │ ├── HelloWorld.java │ │ │ └── Person.java │ ├── 02.Maven-Introduction-In-5-Steps │ │ ├── .gitignore │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── pom.xml │ │ ├── readme.md │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── in28minutes │ │ │ │ │ └── learning │ │ │ │ │ └── maven │ │ │ │ │ └── maveninfewsteps │ │ │ │ │ └── MavenInFewStepsApplication.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── in28minutes │ │ │ └── learning │ │ │ └── maven │ │ │ └── maveninfewsteps │ │ │ └── MavenInFewStepsApplicationTests.java │ ├── 03.JUnit-Introduction-In-5-Steps │ │ ├── readme.md │ │ ├── src │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── junit │ │ │ │ └── MyMath.java │ │ └── test │ │ │ └── com │ │ │ └── in28minutes │ │ │ └── junit │ │ │ ├── MyAssertTest.java │ │ │ ├── MyBeforeAfterTest.java │ │ │ └── MyMathTest.java │ ├── 04.Mockito-Introduction-In-5-Steps │ │ ├── .gitignore │ │ ├── HELP.md │ │ ├── Step5.md │ │ ├── pom.xml │ │ ├── readme.md │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── in28minutes │ │ │ │ │ └── mockito │ │ │ │ │ └── mockitodemo │ │ │ │ │ ├── MockitoDemoApplication.java │ │ │ │ │ └── business │ │ │ │ │ └── SomeBusinessImpl.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── in28minutes │ │ │ └── mockito │ │ │ └── mockitodemo │ │ │ ├── MockitoDemoApplicationTests.java │ │ │ ├── business │ │ │ ├── SomeBusinessImplMockTest.java │ │ │ └── SomeBusinessImplStubTest.java │ │ │ └── list │ │ │ └── ListTest.java │ └── 05.Spring-Boot-Introduction-In-10-Steps │ │ ├── .gitignore │ │ ├── HELP.md │ │ ├── final.md │ │ ├── notes.txt │ │ ├── pom.xml │ │ ├── readme.md │ │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── springboot │ │ │ │ └── learnspringboot │ │ │ │ ├── Course.java │ │ │ │ ├── CourseController.java │ │ │ │ ├── CurrencyConfigurationController.java │ │ │ │ ├── CurrencyServiceConfiguration.java │ │ │ │ └── LearnSpringBootApplication.java │ │ └── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── in28minutes │ │ └── springboot │ │ └── learnspringboot │ │ └── LearnSpringBootApplicationTests.java │ ├── 01-spring-in-depth │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── Step10.md │ ├── Step10.zip │ ├── Step12.md │ ├── Step12.zip │ ├── Step14.md │ ├── Step14.zip │ ├── Step15.md │ ├── Step15.zip │ ├── Step16.md │ ├── Step16.zip │ ├── Step17.md │ ├── Step17.zip │ ├── Step18.md │ ├── Step18.zip │ ├── Step19.md │ ├── Step19.zip │ ├── Step20.md │ ├── Step20.zip │ ├── Step22_XMLContextConfigurationFirstExampleComplete.md │ ├── Step22_XMLContextConfigurationFirstExampleComplete.zip │ ├── Step23.md │ ├── Step23.zip │ ├── Step25B.md │ ├── Step25B.zip │ ├── Step26.md │ ├── Step26.zip │ ├── Step29.md │ ├── Step29.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── spring │ │ │ │ └── basics │ │ │ │ ├── componentscan │ │ │ │ ├── ComponentDAO.java │ │ │ │ └── ComponentJdbcConnection.java │ │ │ │ └── springin5steps │ │ │ │ ├── SpringIn5StepsBasicApplication.java │ │ │ │ ├── SpringIn5StepsCdiApplication.java │ │ │ │ ├── SpringIn5StepsComponentScanApplication.java │ │ │ │ ├── SpringIn5StepsPropertiesApplication.java │ │ │ │ ├── SpringIn5StepsScopeApplication.java │ │ │ │ ├── SpringIn5StepsXMLContextApplication.java │ │ │ │ ├── basic │ │ │ │ ├── BinarySearchImpl.java │ │ │ │ ├── BubbleSortAlgorithm.java │ │ │ │ ├── QuickSortAlgorithm.java │ │ │ │ └── SortAlgorithm.java │ │ │ │ ├── cdi │ │ │ │ ├── SomeCdiBusiness.java │ │ │ │ └── SomeCdiDao.java │ │ │ │ ├── properties │ │ │ │ └── SomeExternalService.java │ │ │ │ ├── scope │ │ │ │ ├── JdbcConnection.java │ │ │ │ └── PersonDAO.java │ │ │ │ └── xml │ │ │ │ ├── XmlJdbcConnection.java │ │ │ │ └── XmlPersonDAO.java │ │ └── resources │ │ │ ├── app.properties │ │ │ ├── application.properties │ │ │ ├── applicationContext.xml │ │ │ └── log.txt │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── in28minutes │ │ │ └── spring │ │ │ └── basics │ │ │ └── springin5steps │ │ │ ├── SpringIn5StepsBasicApplicationTests.java │ │ │ ├── basic │ │ │ ├── BinarySearchTest.java │ │ │ └── BinarySearchXMLConfigurationTest.java │ │ │ └── cdi │ │ │ └── SomeCdiBusinessTest.java │ │ └── resources │ │ └── testContext.xml │ ├── 02-basic-web-application │ ├── .gitignore │ ├── Step01.md │ ├── Step02.md │ ├── Step03.md │ ├── Step04.md │ ├── Step05.md │ ├── Step06.md │ ├── Step07.md │ ├── Step07.zip │ ├── Step11.md │ ├── Step11.zip │ ├── Step12.md │ ├── Step13.md │ ├── Step13.zip │ ├── Step14.md │ ├── Step15.md │ ├── Step15.zip │ ├── Step16.md │ ├── Step16.zip │ ├── Step17.md │ ├── Step17.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── in28minutes │ │ │ └── login │ │ │ ├── LoginController.java │ │ │ └── LoginService.java │ │ ├── resources │ │ └── log4j.properties │ │ └── webapp │ │ └── WEB-INF │ │ ├── todo-servlet.xml │ │ ├── views │ │ ├── login.jsp │ │ └── welcome.jsp │ │ └── web.xml │ ├── 03-spring-aop │ ├── .gitignore │ ├── Step01.md │ ├── Step01.zip │ ├── Step03.md │ ├── Step03.zip │ ├── Step06.md │ ├── Step06.zip │ ├── Step07.md │ ├── Step07.zip │ ├── Step09.md │ ├── Step09.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── spring │ │ │ │ └── aop │ │ │ │ └── springaop │ │ │ │ ├── SpringAopApplication.java │ │ │ │ ├── aspect │ │ │ │ ├── AfterAopAspect.java │ │ │ │ ├── CommonJoinPointConfig.java │ │ │ │ ├── MethodExecutionCalculationAspect.java │ │ │ │ ├── TrackTime.java │ │ │ │ └── UserAccessAspect.java │ │ │ │ ├── business │ │ │ │ ├── Business1.java │ │ │ │ └── Business2.java │ │ │ │ └── data │ │ │ │ ├── Dao1.java │ │ │ │ └── Dao2.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── in28minutes │ │ └── spring │ │ └── aop │ │ └── springaop │ │ └── SpringAopApplicationTests.java │ ├── 04-spring-jdbc-to-jpa │ ├── .gitignore │ ├── .springBeans │ ├── Step01.md │ ├── Step01.zip │ ├── Step03.md │ ├── Step03.zip │ ├── Step05.md │ ├── Step05.zip │ ├── Step06.md │ ├── Step06.zip │ ├── Step10.md │ ├── Step10.zip │ ├── Step11.md │ ├── Step11.zip │ ├── Step12.md │ ├── Step12.zip │ ├── Step14.md │ ├── Step14.zip │ ├── Step15.md │ ├── Step15.zip │ ├── Step18.md │ ├── Step18.zip │ ├── Step19.md │ ├── Step19.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── database │ │ │ │ └── databasedemo │ │ │ │ ├── JpaDemoApplication.java │ │ │ │ ├── SpringDataDemoApplication.java │ │ │ │ ├── SpringJdbcDemoApplication.java │ │ │ │ ├── entity │ │ │ │ └── Person.java │ │ │ │ ├── jdbc │ │ │ │ └── PersonJbdcDao.java │ │ │ │ ├── jpa │ │ │ │ └── PersonJpaRepository.java │ │ │ │ └── springdata │ │ │ │ └── PersonSpringDataRepository.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── data.sql │ │ └── test │ │ └── java │ │ └── com │ │ └── in28minutes │ │ └── database │ │ └── databasedemo │ │ └── SpringJdbcDemoApplicationTests.java │ ├── 99-old-code │ └── archive.zip │ ├── README.md │ └── notes.md ├── LICENSE.txt ├── README.md ├── S02 - Level 1 to 6 - Course Overview └── SpringMasterClass-CourseGuidev0.1.pdf ├── S03 - Level 1 - Introduction to Java Spring Framework ├── 01-spring-in-depth │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── Step10.md │ ├── Step10.zip │ ├── Step12.md │ ├── Step12.zip │ ├── Step14.md │ ├── Step14.zip │ ├── Step15.md │ ├── Step15.zip │ ├── Step16.md │ ├── Step16.zip │ ├── Step17.md │ ├── Step17.zip │ ├── Step18.md │ ├── Step18.zip │ ├── Step19.md │ ├── Step19.zip │ ├── Step20.md │ ├── Step20.zip │ ├── Step22_XMLContextConfigurationFirstExampleComplete.md │ ├── Step22_XMLContextConfigurationFirstExampleComplete.zip │ ├── Step23.md │ ├── Step23.zip │ ├── Step25B.md │ ├── Step25B.zip │ ├── Step26.md │ ├── Step26.zip │ ├── Step29.md │ ├── Step29.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── spring │ │ │ │ └── basics │ │ │ │ ├── componentscan │ │ │ │ ├── ComponentDAO.java │ │ │ │ └── ComponentJdbcConnection.java │ │ │ │ └── springin5steps │ │ │ │ ├── SpringIn5StepsBasicApplication.java │ │ │ │ ├── SpringIn5StepsCdiApplication.java │ │ │ │ ├── SpringIn5StepsComponentScanApplication.java │ │ │ │ ├── SpringIn5StepsPropertiesApplication.java │ │ │ │ ├── SpringIn5StepsScopeApplication.java │ │ │ │ ├── SpringIn5StepsXMLContextApplication.java │ │ │ │ ├── basic │ │ │ │ ├── BinarySearchImpl.java │ │ │ │ ├── BubbleSortAlgorithm.java │ │ │ │ ├── QuickSortAlgorithm.java │ │ │ │ └── SortAlgorithm.java │ │ │ │ ├── cdi │ │ │ │ ├── SomeCdiBusiness.java │ │ │ │ └── SomeCdiDao.java │ │ │ │ ├── properties │ │ │ │ └── SomeExternalService.java │ │ │ │ ├── scope │ │ │ │ ├── JdbcConnection.java │ │ │ │ └── PersonDAO.java │ │ │ │ └── xml │ │ │ │ ├── XmlJdbcConnection.java │ │ │ │ └── XmlPersonDAO.java │ │ └── resources │ │ │ ├── app.properties │ │ │ ├── application.properties │ │ │ ├── applicationContext.xml │ │ │ └── log.txt │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── in28minutes │ │ │ └── spring │ │ │ └── basics │ │ │ └── springin5steps │ │ │ ├── SpringIn5StepsBasicApplicationTests.java │ │ │ ├── basic │ │ │ ├── BinarySearchTest.java │ │ │ └── BinarySearchXMLConfigurationTest.java │ │ │ └── cdi │ │ │ └── SomeCdiBusinessTest.java │ │ └── resources │ │ └── testContext.xml ├── DO NOT SKIP - New to Maven and Eclipse.docx ├── Fastest Approach to Solve All Your Exceptions.docx └── Spring Framework Level 1, 2 and 3 - Github Folder.docx ├── S04 - Level 2 - Spring Framework in Depth └── Ignore SLF4J Errors in Step 19 - We will fix them in Step 20.docx ├── S09 - Level 5 - Spring AOP ├── 03-spring-aop │ ├── .gitignore │ ├── Step01.md │ ├── Step01.zip │ ├── Step03.md │ ├── Step03.zip │ ├── Step06.md │ ├── Step06.zip │ ├── Step07.md │ ├── Step07.zip │ ├── Step09.md │ ├── Step09.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── spring │ │ │ │ └── aop │ │ │ │ └── springaop │ │ │ │ ├── SpringAopApplication.java │ │ │ │ ├── aspect │ │ │ │ ├── AfterAopAspect.java │ │ │ │ ├── CommonJoinPointConfig.java │ │ │ │ ├── MethodExecutionCalculationAspect.java │ │ │ │ ├── TrackTime.java │ │ │ │ └── UserAccessAspect.java │ │ │ │ ├── business │ │ │ │ ├── Business1.java │ │ │ │ └── Business2.java │ │ │ │ └── data │ │ │ │ ├── Dao1.java │ │ │ │ └── Dao2.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── in28minutes │ │ └── spring │ │ └── aop │ │ └── springaop │ │ └── SpringAopApplicationTests.java └── COURSE UPDATE - AOP Dependency Removed From Spring Initializr.docx ├── S10 - Level 6 - Spring JDBC to JPA ├── 04-spring-jdbc-to-jpa │ ├── .gitignore │ ├── .springBeans │ ├── Step01.md │ ├── Step01.zip │ ├── Step03.md │ ├── Step03.zip │ ├── Step05.md │ ├── Step05.zip │ ├── Step06.md │ ├── Step06.zip │ ├── Step10.md │ ├── Step10.zip │ ├── Step11.md │ ├── Step11.zip │ ├── Step12.md │ ├── Step12.zip │ ├── Step14.md │ ├── Step14.zip │ ├── Step15.md │ ├── Step15.zip │ ├── Step18.md │ ├── Step18.zip │ ├── Step19.md │ ├── Step19.zip │ ├── pom.xml │ ├── readme.md │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── in28minutes │ │ │ │ └── database │ │ │ │ └── databasedemo │ │ │ │ ├── JpaDemoApplication.java │ │ │ │ ├── SpringDataDemoApplication.java │ │ │ │ ├── SpringJdbcDemoApplication.java │ │ │ │ ├── entity │ │ │ │ └── Person.java │ │ │ │ ├── jdbc │ │ │ │ └── PersonJbdcDao.java │ │ │ │ ├── jpa │ │ │ │ └── PersonJpaRepository.java │ │ │ │ └── springdata │ │ │ │ └── PersonSpringDataRepository.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── data.sql │ │ └── test │ │ └── java │ │ └── com │ │ └── in28minutes │ │ └── database │ │ └── databasedemo │ │ └── SpringJdbcDemoApplicationTests.java ├── COURSE UPDATE - H2 Database URL.docx └── Updates to Step 03 and Step 04.docx └── S11 - Web App with Spring MVC └── 02-basic-web-application ├── .gitignore ├── Step01.md ├── Step02.md ├── Step03.md ├── Step04.md ├── Step05.md ├── Step06.md ├── Step07.md ├── Step07.zip ├── Step11.md ├── Step11.zip ├── Step12.md ├── Step13.md ├── Step13.zip ├── Step14.md ├── Step15.md ├── Step15.zip ├── Step16.md ├── Step16.zip ├── Step17.md ├── Step17.zip ├── pom.xml ├── readme.md └── src └── main ├── java └── com │ └── in28minutes │ └── login │ ├── LoginController.java │ └── LoginService.java ├── resources └── log4j.properties └── webapp └── WEB-INF ├── todo-servlet.xml ├── views ├── login.jsp └── welcome.jsp └── web.xml /Code Bundle/GitHub Link for this Course.txt: -------------------------------------------------------------------------------- 1 | GitHub Link for this course: 2 | 3 | https://github.com/in28minutes/spring-master-class/tree/master -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | target 3 | bin 4 | .settings 5 | .classpath 6 | .project 7 | *.class 8 | mvnw 9 | mvnw* 10 | 11 | # Mobile Tools for Java (J2ME) 12 | .mtj.tmp/ 13 | 14 | # Package Files # 15 | *.jar 16 | *.war 17 | *.ear 18 | 19 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 20 | hs_err_pid* 21 | .idea/** 22 | 00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/mockito-demo.iml 23 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/01.Eclipse-Introduction-in-5-steps/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/01.Eclipse-Introduction-in-5-steps/code-21July2017.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/00-framework-tool-introductions/01.Eclipse-Introduction-in-5-steps/code-21July2017.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/01.Eclipse-Introduction-in-5-steps/src/HelloWorld.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | import java.util.Map; 3 | 4 | public class HelloWorld { 5 | public static void main(String[] args) { 6 | Map map = new HashMap(); 7 | map.put("key", "value"); 8 | } 9 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/01.Eclipse-Introduction-in-5-steps/src/Person.java: -------------------------------------------------------------------------------- 1 | public class Person { 2 | private String firstName; 3 | private String lastName; 4 | private String ssn; 5 | 6 | public Person(String firstName, String lastName, String ssn) { 7 | super(); 8 | this.firstName = firstName; 9 | this.lastName = lastName; 10 | this.ssn = ssn; 11 | } 12 | 13 | public String getFirstName() { 14 | return firstName; 15 | } 16 | 17 | public void setFirstName(String firstName) { 18 | this.firstName = firstName; 19 | } 20 | 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | 25 | public void setLastName(String lastName) { 26 | this.lastName = lastName; 27 | } 28 | 29 | public String getSsn() { 30 | return ssn; 31 | } 32 | 33 | public void setSsn(String ssn) { 34 | this.ssn = ssn; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return String.format("Person [firstName=%s, lastName=%s, ssn=%s]", firstName, lastName, ssn); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | final int prime = 31; 45 | int result = 1; 46 | result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); 47 | result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); 48 | result = prime * result + ((ssn == null) ? 0 : ssn.hashCode()); 49 | return result; 50 | } 51 | 52 | @Override 53 | public boolean equals(Object obj) { 54 | if (this == obj) 55 | return true; 56 | if (obj == null) 57 | return false; 58 | if (getClass() != obj.getClass()) 59 | return false; 60 | Person other = (Person) obj; 61 | if (firstName == null) { 62 | if (other.firstName != null) 63 | return false; 64 | } else if (!firstName.equals(other.firstName)) 65 | return false; 66 | if (lastName == null) { 67 | if (other.lastName != null) 68 | return false; 69 | } else if (!lastName.equals(other.lastName)) 70 | return false; 71 | if (ssn == null) { 72 | if (other.ssn != null) 73 | return false; 74 | } else if (!ssn.equals(other.ssn)) 75 | return false; 76 | return true; 77 | } 78 | 79 | } 80 | // Alt + Shift + S 81 | // Cmd + Option + S 82 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/src/main/java/com/in28minutes/learning/maven/maveninfewsteps/MavenInFewStepsApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.learning.maven.maveninfewsteps; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MavenInFewStepsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MavenInFewStepsApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/src/main/resources/application.properties -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/02.Maven-Introduction-In-5-Steps/src/test/java/com/in28minutes/learning/maven/maveninfewsteps/MavenInFewStepsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.learning.maven.maveninfewsteps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | // replaced @RunWith with @ExtendWith 9 | // replaced SpringRunner.class with SpringExtension.class 10 | @ExtendWith(SpringExtension.class) 11 | @SpringBootTest 12 | public class MavenInFewStepsApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/03.JUnit-Introduction-In-5-Steps/src/com/in28minutes/junit/MyMath.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.junit; 2 | 3 | public class MyMath { 4 | 5 | //{1,2,3} => 1+2+3 = 6 6 | public int calculateSum(int[] numbers) { 7 | 8 | int sum = 0; 9 | 10 | for(int number:numbers) { 11 | sum += number; 12 | } 13 | 14 | return sum; 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/03.JUnit-Introduction-In-5-Steps/test/com/in28minutes/junit/MyAssertTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.junit; 2 | 3 | import static org.junit.Assert.assertArrayEquals; 4 | import static org.junit.jupiter.api.Assertions.assertEquals; 5 | import static org.junit.jupiter.api.Assertions.assertFalse; 6 | import static org.junit.jupiter.api.Assertions.assertTrue; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | class MyAssertTest { 14 | 15 | List todos = Arrays.asList("AWS", "Azure", "DevOps"); 16 | 17 | @Test 18 | void testAsserts() { 19 | boolean test = todos.contains("AWS");//Result 20 | boolean test2 = todos.contains("GCP");//Result 21 | 22 | //assertEquals(true, test); 23 | assertTrue(test); 24 | assertFalse(test2); 25 | //assertNull,assertNotNull 26 | assertArrayEquals(new int[] {1,2}, new int[] {2, 1}); 27 | 28 | assertEquals(3, todos.size()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/03.JUnit-Introduction-In-5-Steps/test/com/in28minutes/junit/MyBeforeAfterTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.junit; 2 | 3 | import org.junit.jupiter.api.AfterAll; 4 | import org.junit.jupiter.api.AfterEach; 5 | import org.junit.jupiter.api.BeforeAll; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | class MyBeforeAfterTest { 10 | 11 | 12 | @BeforeAll 13 | static void beforeAll() { 14 | System.out.println("beforeAll"); 15 | } 16 | 17 | @BeforeEach 18 | void beforeEach() { 19 | System.out.println("BeforeEach"); 20 | } 21 | 22 | @Test 23 | void test1() { 24 | System.out.println("test1"); 25 | } 26 | 27 | @Test 28 | void test2() { 29 | System.out.println("test2"); 30 | } 31 | 32 | @Test 33 | void test3() { 34 | System.out.println("test3"); 35 | } 36 | 37 | @AfterEach 38 | void afterEach() { 39 | System.out.println("AfterEach"); 40 | } 41 | 42 | @AfterAll 43 | static void afterAll() { 44 | System.out.println("afterAll"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/03.JUnit-Introduction-In-5-Steps/test/com/in28minutes/junit/MyMathTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.junit; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | class MyMathTest { 8 | 9 | private MyMath math = new MyMath(); 10 | 11 | @Test 12 | void calculateSum_ThreeMemberArray() { 13 | assertEquals(6, math.calculateSum(new int[] {1,2,3})); 14 | } 15 | 16 | @Test 17 | void calculateSum_ZeroLengthArray() { 18 | assertEquals(0, math.calculateSum(new int[] {})); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/HELP.md: -------------------------------------------------------------------------------- 1 | # Read Me First 2 | The following was discovered as part of building this project: 3 | 4 | * The original package name 'com.in28minutes.mockito.mockito-demo' is invalid and this project uses 'com.in28minutes.mockito.mockitodemo' instead. 5 | 6 | # Getting Started 7 | 8 | ### Reference Documentation 9 | For further reference, please consider the following sections: 10 | 11 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 12 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.0.0-M3/maven-plugin/reference/html/) 13 | * [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.0.0-M3/maven-plugin/reference/html/#build-image) 14 | 15 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.2.1 9 | 10 | 11 | com.in28minutes.mockito 12 | mockito-demo 13 | 0.0.1-SNAPSHOT 14 | mockito-demo 15 | Demo project for Spring Boot 16 | 17 | 21 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | spring-milestones 43 | Spring Milestones 44 | https://repo.spring.io/milestone 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | spring-milestones 53 | Spring Milestones 54 | https://repo.spring.io/milestone 55 | 56 | false 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/main/java/com/in28minutes/mockito/mockitodemo/MockitoDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MockitoDemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MockitoDemoApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/main/java/com/in28minutes/mockito/mockitodemo/business/SomeBusinessImpl.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo.business; 2 | 3 | public class SomeBusinessImpl { 4 | 5 | private final DataService dataService; 6 | 7 | public SomeBusinessImpl(DataService dataService) { 8 | super(); 9 | this.dataService = dataService; 10 | } 11 | 12 | public int findTheGreatestFromAllData() { 13 | int[] data = dataService.retrieveAllData(); 14 | int greatestValue = Integer.MIN_VALUE; 15 | for(int value:data) { 16 | if(value > greatestValue) 17 | greatestValue = value; 18 | } 19 | return greatestValue; 20 | } 21 | 22 | } 23 | 24 | interface DataService { 25 | int[] retrieveAllData(); 26 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/test/java/com/in28minutes/mockito/mockitodemo/MockitoDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MockitoDemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/test/java/com/in28minutes/mockito/mockitodemo/business/SomeBusinessImplMockTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo.business; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.mockito.Mockito.when; 5 | 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.mockito.InjectMocks; 9 | import org.mockito.Mock; 10 | import org.mockito.junit.jupiter.MockitoExtension; 11 | 12 | @ExtendWith(MockitoExtension.class) 13 | class SomeBusinessImplMockTest { 14 | 15 | @Mock 16 | private DataService dataServiceMock; 17 | 18 | @InjectMocks 19 | private SomeBusinessImpl businessImpl; 20 | 21 | @Test 22 | void findTheGreatestFromAllData_basicScenario() { 23 | when(dataServiceMock.retrieveAllData()).thenReturn(new int[]{25, 15, 5}); 24 | assertEquals(25, businessImpl.findTheGreatestFromAllData()); 25 | } 26 | 27 | @Test 28 | void findTheGreatestFromAllData_OneValue() { 29 | when(dataServiceMock.retrieveAllData()).thenReturn(new int[]{35}); 30 | assertEquals(35, businessImpl.findTheGreatestFromAllData()); 31 | } 32 | 33 | @Test 34 | void findTheGreatestFromAllData_EmptyArray() { 35 | when(dataServiceMock.retrieveAllData()).thenReturn(new int[]{}); 36 | assertEquals(Integer.MIN_VALUE, businessImpl.findTheGreatestFromAllData()); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/test/java/com/in28minutes/mockito/mockitodemo/business/SomeBusinessImplStubTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo.business; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | class SomeBusinessImplStubTest { 8 | 9 | @Test 10 | void findTheGreatestFromAllData_basicScenario() { 11 | DataService dataServiceStub = new DataServiceStub1(); 12 | SomeBusinessImpl businessImpl = new SomeBusinessImpl(dataServiceStub); 13 | int result = businessImpl.findTheGreatestFromAllData(); 14 | assertEquals(25, result); 15 | } 16 | 17 | @Test 18 | void findTheGreatestFromAllData_withOneValue() { 19 | DataService dataServiceStub = new DataServiceStub2(); 20 | SomeBusinessImpl businessImpl = new SomeBusinessImpl(dataServiceStub); 21 | int result = businessImpl.findTheGreatestFromAllData(); 22 | assertEquals(35, result); 23 | } 24 | 25 | } 26 | 27 | class DataServiceStub1 implements DataService { 28 | 29 | @Override 30 | public int[] retrieveAllData() { 31 | return new int[]{25, 15, 5}; 32 | } 33 | 34 | } 35 | 36 | 37 | class DataServiceStub2 implements DataService { 38 | 39 | @Override 40 | public int[] retrieveAllData() { 41 | return new int[]{35}; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/04.Mockito-Introduction-In-5-Steps/src/test/java/com/in28minutes/mockito/mockitodemo/list/ListTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.mockito.mockitodemo.list; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.mockito.Mockito.mock; 5 | import static org.mockito.Mockito.when; 6 | 7 | import java.util.List; 8 | 9 | import org.junit.jupiter.api.Test; 10 | import org.mockito.Mockito; 11 | 12 | public class ListTest { 13 | 14 | @Test 15 | void simpleTest() { 16 | List listMock = mock(List.class); 17 | //listMock.size() => 3 18 | when(listMock.size()).thenReturn(3); 19 | assertEquals(3, listMock.size()); 20 | assertEquals(3, listMock.size()); 21 | assertEquals(3, listMock.size()); 22 | assertEquals(3, listMock.size()); 23 | } 24 | 25 | @Test 26 | void multipleReturns() { 27 | List listMock = mock(List.class); 28 | //listMock.size() => 3 29 | when(listMock.size()).thenReturn(1).thenReturn(2); 30 | assertEquals(1, listMock.size()); 31 | assertEquals(2, listMock.size()); 32 | assertEquals(2, listMock.size()); 33 | assertEquals(2, listMock.size()); 34 | } 35 | 36 | @Test 37 | void specificParameters() { 38 | List listMock = mock(List.class); 39 | //listMock.size() => 3 40 | when(listMock.get(0)).thenReturn("SomeString"); 41 | assertEquals("SomeString", listMock.get(0)); 42 | assertEquals(null, listMock.get(1)); 43 | } 44 | 45 | @Test 46 | void genericParameters() { 47 | List listMock = mock(List.class); 48 | //listMock.size() => 3 49 | when(listMock.get(Mockito.anyInt())).thenReturn("SomeOtherString"); 50 | assertEquals("SomeOtherString", listMock.get(0)); 51 | assertEquals("SomeOtherString", listMock.get(1)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/HELP.md: -------------------------------------------------------------------------------- 1 | # Read Me First 2 | The following was discovered as part of building this project: 3 | 4 | * The original package name 'com.in28minutes.springboot.learn-spring-boot' is invalid and this project uses 'com.in28minutes.springboot.learnspringboot' instead. 5 | 6 | # Getting Started 7 | 8 | ### Reference Documentation 9 | For further reference, please consider the following sections: 10 | 11 | * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) 12 | * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.0.0-M3/maven-plugin/reference/html/) 13 | * [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.0.0-M3/maven-plugin/reference/html/#build-image) 14 | * [Spring Web](https://docs.spring.io/spring-boot/docs/3.0.0-M3/reference/htmlsingle/#web) 15 | 16 | ### Guides 17 | The following guides illustrate how to use some features concretely: 18 | 19 | * [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) 20 | * [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) 21 | * [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) 22 | 23 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/notes.txt: -------------------------------------------------------------------------------- 1 | 2 | dev 3 | ~~~~ 4 | logging.level.org.springframework=trace 5 | 6 | prod 7 | ~~~~ 8 | logging.level.org.springframework=info 9 | 10 | 11 | trace 12 | debug 13 | info 14 | warning 15 | error 16 | 17 | off 18 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.2.1 9 | 10 | 11 | com.in28minutes.springboot 12 | learn-spring-boot 13 | 0.0.1-SNAPSHOT 14 | learn-spring-boot 15 | Demo project for Spring Boot 16 | 17 | 21 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-actuator 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-devtools 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | 55 | 56 | spring-milestones 57 | Spring Milestones 58 | https://repo.spring.io/milestone 59 | 60 | false 61 | 62 | 63 | 64 | 65 | 66 | spring-milestones 67 | Spring Milestones 68 | https://repo.spring.io/milestone 69 | 70 | false 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/learnspringboot/Course.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | public class Course { 4 | private long id; 5 | private String name; 6 | private String author; 7 | 8 | public Course(long id, String name, String author) { 9 | super(); 10 | this.id = id; 11 | this.name = name; 12 | this.author = author; 13 | } 14 | 15 | public long getId() { 16 | return id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public String getAuthor() { 24 | return author; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "Course [id=" + id + ", name=" + name + ", author=" + author + "]"; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/learnspringboot/CourseController.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class CourseController { 10 | 11 | @RequestMapping("/courses") 12 | public List retrieveAllCourses() { 13 | return List.of( 14 | new Course(1, "Learn AWS", "in28minutes"), 15 | new Course(2, "Learn DevOps", "in28minutes"), 16 | new Course(3, "Learn Azure", "in28minutes"), 17 | new Course(4, "Learn GCP", "in28minutes") 18 | ); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/learnspringboot/CurrencyConfigurationController.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class CurrencyConfigurationController { 9 | 10 | @Autowired 11 | private CurrencyServiceConfiguration configuration; 12 | 13 | @RequestMapping("/currency-configuration") 14 | public CurrencyServiceConfiguration retrieveAllCourses() { 15 | return configuration; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/learnspringboot/CurrencyServiceConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | //currency-service.url= 7 | //currency-service.username= 8 | //currency-service.key= 9 | 10 | @ConfigurationProperties(prefix = "currency-service") 11 | @Component 12 | public class CurrencyServiceConfiguration { 13 | 14 | private String url; 15 | private String username; 16 | private String key; 17 | 18 | public String getUrl() { 19 | return url; 20 | } 21 | 22 | public void setUrl(String url) { 23 | this.url = url; 24 | } 25 | 26 | public String getUsername() { 27 | return username; 28 | } 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | public String getKey() { 35 | return key; 36 | } 37 | 38 | public void setKey(String key) { 39 | this.key = key; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/java/com/in28minutes/springboot/learnspringboot/LearnSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class LearnSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(LearnSpringBootApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework=trace 2 | 3 | currency-service.url=http://dev.in28minutes.com 4 | currency-service.username=devusername 5 | currency-service.key=devkey 6 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework=info 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework=debug 2 | spring.profiles.active=dev 3 | 4 | 5 | currency-service.url=http://default1.in28minutes.com 6 | currency-service.username=defaultusername 7 | currency-service.key=defaultkey 8 | 9 | management.endpoints.web.exposure.include=health,metrics -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/00-framework-tool-introductions/05.Spring-Boot-Introduction-In-10-Steps/src/test/java/com/in28minutes/springboot/learnspringboot/LearnSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.springboot.learnspringboot; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class LearnSpringBootApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step10.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step12.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step14.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step14.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step15.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step16.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step17.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step17.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step18.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step18.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step19.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step19.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step20.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step20.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step22_XMLContextConfigurationFirstExampleComplete.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step22_XMLContextConfigurationFirstExampleComplete.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step23.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step23.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step25B.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step25B.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step26.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step26.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/Step29.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/01-spring-in-depth/Step29.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/componentscan/ComponentDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.componentscan; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class ComponentDAO { 8 | 9 | @Autowired 10 | ComponentJdbcConnection jdbcConnection; 11 | 12 | public ComponentJdbcConnection getJdbcConnection() { 13 | return jdbcConnection; 14 | } 15 | 16 | public void setComponentJdbcConnection(ComponentJdbcConnection jdbcConnection) { 17 | this.jdbcConnection = jdbcConnection; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/componentscan/ComponentJdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.componentscan; 2 | 3 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 4 | import org.springframework.context.annotation.Scope; 5 | import org.springframework.context.annotation.ScopedProxyMode; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE, 10 | proxyMode = ScopedProxyMode.TARGET_CLASS) 11 | public class ComponentJdbcConnection { 12 | public ComponentJdbcConnection() { 13 | System.out.println("JDBC Connection"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsBasicApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.in28minutes.spring.basics.springin5steps.basic.BinarySearchImpl; 8 | 9 | @Configuration 10 | @ComponentScan 11 | public class SpringIn5StepsBasicApplication { 12 | 13 | public static void main(String[] args) { 14 | 15 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsBasicApplication.class)) { 16 | 17 | var binarySearch = applicationContext.getBean(BinarySearchImpl.class); 18 | 19 | var binarySearch1 = applicationContext.getBean(BinarySearchImpl.class); 20 | 21 | System.out.println(binarySearch); 22 | System.out.println(binarySearch1); 23 | 24 | int result = binarySearch.binarySearch(new int[] { 12, 4, 6 }, 3); 25 | System.out.println(result); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsCdiApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.springin5steps.cdi.SomeCdiBusiness; 10 | 11 | @Configuration 12 | @ComponentScan 13 | public class SpringIn5StepsCdiApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsCdiApplication.class); 16 | 17 | public static void main(String[] args) { 18 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsCdiApplication.class)) { 19 | var business = applicationContext.getBean(SomeCdiBusiness.class); 20 | 21 | LOGGER.info("{} dao-{}", business, business.getSomeCDIDAO()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsComponentScanApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.componentscan.ComponentDAO; 10 | 11 | @Configuration 12 | @ComponentScan("com.in28minutes.spring.basics.componentscan") 13 | public class SpringIn5StepsComponentScanApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsComponentScanApplication.class); 16 | 17 | public static void main(String[] args) { 18 | 19 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsComponentScanApplication.class)) { 20 | var componentDAO = applicationContext.getBean(ComponentDAO.class); 21 | 22 | LOGGER.info("{}", componentDAO); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsPropertiesApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.PropertySource; 7 | 8 | import com.in28minutes.spring.basics.springin5steps.properties.SomeExternalService; 9 | 10 | @Configuration 11 | @ComponentScan 12 | // 13 | @PropertySource("classpath:app.properties") 14 | public class SpringIn5StepsPropertiesApplication { 15 | 16 | public static void main(String[] args) { 17 | 18 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsPropertiesApplication.class)) { 19 | 20 | var service = applicationContext.getBean(SomeExternalService.class); 21 | System.out.println(service.returnServiceURL()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsScopeApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.springin5steps.scope.PersonDAO; 10 | 11 | @Configuration 12 | @ComponentScan 13 | public class SpringIn5StepsScopeApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsScopeApplication.class); 16 | 17 | public static void main(String[] args) { 18 | 19 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsScopeApplication.class)) { 20 | 21 | var personDao = applicationContext.getBean(PersonDAO.class); 22 | 23 | var personDao2 = applicationContext.getBean(PersonDAO.class); 24 | 25 | LOGGER.info("{}", personDao); 26 | LOGGER.info("{}", personDao.getJdbcConnection()); 27 | LOGGER.info("{}", personDao.getJdbcConnection()); 28 | 29 | LOGGER.info("{}", personDao2); 30 | LOGGER.info("{}", personDao.getJdbcConnection()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsXMLContextApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | import com.in28minutes.spring.basics.springin5steps.xml.XmlPersonDAO; 8 | 9 | public class SpringIn5StepsXMLContextApplication { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsXMLContextApplication.class); 12 | 13 | public static void main(String[] args) { 14 | 15 | try (var applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml")) { 16 | 17 | LOGGER.info("Beans Loaded -> {}", (Object) applicationContext.getBeanDefinitionNames()); 18 | // [xmlJdbcConnection, xmlPersonDAO] 19 | 20 | var personDao = applicationContext.getBean(XmlPersonDAO.class); 21 | 22 | LOGGER.info("{} {}", personDao, personDao.getXmlJdbcConnection()); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchImpl.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import jakarta.annotation.PostConstruct; 4 | import jakarta.annotation.PreDestroy; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Qualifier; 9 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 10 | import org.springframework.context.annotation.Scope; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service 14 | @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) 15 | public class BinarySearchImpl { 16 | 17 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 18 | 19 | @Autowired 20 | @Qualifier("bubble") 21 | private SortAlgorithm sortAlgorithm; 22 | 23 | public int binarySearch(int[] numbers, int numberToSearchFor) { 24 | 25 | int[] sortedNumbers = sortAlgorithm.sort(numbers); 26 | System.out.println(sortAlgorithm); 27 | // Search the array 28 | return 3; 29 | } 30 | 31 | @PostConstruct 32 | public void postConstruct() { 33 | logger.info("postConstruct"); 34 | } 35 | 36 | @PreDestroy 37 | public void preDestroy() { 38 | logger.info("preDestroy"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/BubbleSortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | @Qualifier("bubble") 8 | public class BubbleSortAlgorithm implements SortAlgorithm { 9 | public int[] sort(int[] numbers) { 10 | // Logic for Bubble Sort 11 | return numbers; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/QuickSortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | @Qualifier("quick") 8 | public class QuickSortAlgorithm implements SortAlgorithm { 9 | public int[] sort(int[] numbers) { 10 | // Logic for Quick Sort 11 | return numbers; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/SortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | public interface SortAlgorithm { 4 | int[] sort(int[] numbers); 5 | } 6 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiBusiness.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | import org.springframework.stereotype.Component; 7 | 8 | @Named 9 | @Component 10 | public class SomeCdiBusiness { 11 | 12 | @Inject 13 | SomeCdiDao someCdiDao; 14 | 15 | public SomeCdiDao getSomeCDIDAO() { 16 | return someCdiDao; 17 | } 18 | 19 | public void setSomeCDIDAO(SomeCdiDao someCdiDao) { 20 | this.someCdiDao = someCdiDao; 21 | } 22 | 23 | public int findGreatest() { 24 | int greatest = Integer.MIN_VALUE; 25 | int[] data = someCdiDao.getData(); 26 | for (int value : data) { 27 | if (value > greatest) { 28 | greatest = value; 29 | } 30 | } 31 | return greatest; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiDao.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import javax.inject.Named; 4 | 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Named 8 | @Repository 9 | public class SomeCdiDao { 10 | 11 | public int[] getData() { 12 | return new int[] {5, 89,100}; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/properties/SomeExternalService.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.properties; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class SomeExternalService { 8 | 9 | @Value("${external.service.url}") 10 | private String url; 11 | 12 | public String returnServiceURL(){ 13 | return url; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/scope/JdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.scope; 2 | 3 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 4 | import org.springframework.context.annotation.Scope; 5 | import org.springframework.context.annotation.ScopedProxyMode; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE, 10 | proxyMode = ScopedProxyMode.TARGET_CLASS) 11 | public class JdbcConnection { 12 | public JdbcConnection() { 13 | System.out.println("JDBC Connection"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/scope/PersonDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.scope; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class PersonDAO { 8 | 9 | @Autowired 10 | JdbcConnection jdbcConnection; 11 | 12 | public JdbcConnection getJdbcConnection() { 13 | return jdbcConnection; 14 | } 15 | 16 | public void setJdbcConnection(JdbcConnection jdbcConnection) { 17 | this.jdbcConnection = jdbcConnection; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/xml/XmlJdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.xml; 2 | 3 | public class XmlJdbcConnection { 4 | public XmlJdbcConnection() { 5 | System.out.println("JDBC Connection"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/xml/XmlPersonDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.xml; 2 | 3 | public class XmlPersonDAO { 4 | 5 | XmlJdbcConnection xmlJdbcConnection; 6 | 7 | public XmlJdbcConnection getXmlJdbcConnection() { 8 | return xmlJdbcConnection; 9 | } 10 | 11 | public void setXmlJdbcConnection(XmlJdbcConnection jdbcConnection) { 12 | this.xmlJdbcConnection = jdbcConnection; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | external.service.url=http://someserver.dev.com/service -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #logging.level.org.springframework = debug -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/main/resources/log.txt: -------------------------------------------------------------------------------- 1 | Searching directory [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps] for files matching pattern [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/**/*.class] 2 | Identified candidate component class: file [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/BinarySearchImpl.class] 3 | Identified candidate component class: file [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/BubbleSortAlgorithm.class] 4 | 5 | Creating instance of bean 'binarySearchImpl' 6 | Creating instance of bean 'bubbleSortAlgorithm' 7 | Finished creating instance of bean 'bubbleSortAlgorithm' 8 | 9 | Constuctor - Autowiring by type from bean name 'binarySearchImpl' via constructor 10 | to bean named 'bubbleSortAlgorithm' 11 | Setter - Autowiring by type from bean name 'binarySearchImpl' to bean named 'bubbleSortAlgorithm' 12 | No Setter or Constructor - Autowiring by type from bean name 'binarySearchImpl' to bean named 'bubbleSortAlgorithm' 13 | 14 | 15 | Finished creating instance of bean 'binarySearchImpl' 16 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsBasicApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | @ExtendWith(SpringExtension.class) 9 | @ContextConfiguration(locations="/testContext.xml") 10 | class SpringIn5StepsBasicApplicationTests { 11 | 12 | @Test 13 | void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import com.in28minutes.spring.basics.springin5steps.SpringIn5StepsBasicApplication; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | 12 | // Load the context 13 | @ExtendWith(SpringExtension.class) 14 | @ContextConfiguration(classes = SpringIn5StepsBasicApplication.class) 15 | class BinarySearchTest { 16 | 17 | // Get this bean from the context 18 | @Autowired 19 | BinarySearchImpl binarySearch; 20 | 21 | @Test 22 | void testBasicScenario() { 23 | 24 | // call method on binarySearch 25 | int actualResult = binarySearch.binarySearch(new int[] {}, 5); 26 | 27 | // check if the value is correct 28 | assertEquals(3, actualResult); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchXMLConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit.jupiter.SpringExtension; 10 | 11 | //Load the context 12 | @ExtendWith(SpringExtension.class) 13 | @ContextConfiguration(locations="/testContext.xml") 14 | class BinarySearchXMLConfigurationTest { 15 | 16 | // Get this bean from the context 17 | @Autowired 18 | BinarySearchImpl binarySearch; 19 | 20 | @Test 21 | void testBasicScenario() { 22 | 23 | // call method on binarySearch 24 | int actualResult = binarySearch.binarySearch(new int[] {}, 5); 25 | 26 | // check if the value is correct 27 | assertEquals(3, actualResult); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiBusinessTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.mockito.InjectMocks; 8 | import org.mockito.Mock; 9 | import org.mockito.Mockito; 10 | import org.mockito.junit.jupiter.MockitoExtension; 11 | import org.springframework.context.annotation.ImportResource; 12 | 13 | @ExtendWith(MockitoExtension.class) 14 | class SomeCdiBusinessTest { 15 | 16 | // Inject Mock 17 | @InjectMocks 18 | SomeCdiBusiness business; 19 | 20 | // Create Mock 21 | @Mock 22 | SomeCdiDao daoMock; 23 | 24 | @Test 25 | void testBasicScenario() { 26 | Mockito.when(daoMock.getData()).thenReturn(new int[] { 2, 4 }); 27 | assertEquals(4, business.findGreatest()); 28 | } 29 | 30 | @Test 31 | void testBasicScenario_NoElements() { 32 | Mockito.when(daoMock.getData()).thenReturn(new int[] { }); 33 | assertEquals(Integer.MIN_VALUE, business.findGreatest()); 34 | } 35 | 36 | @Test 37 | void testBasicScenario_EqualElements() { 38 | Mockito.when(daoMock.getData()).thenReturn(new int[] { 2,2}); 39 | assertEquals(2, business.findGreatest()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/01-spring-in-depth/src/test/resources/testContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step02.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 67 | } 68 | 69 | } 70 | ``` 71 | ### \src\main\webapp\WEB-INF\views\login.jsp 72 | ``` 73 | 74 | 75 | Yahoo!! 76 | 77 | 78 | My First JSP!!! 79 | 80 | 81 | ``` 82 | ### \src\main\webapp\WEB-INF\web.xml 83 | ``` 84 | 85 | 88 | 89 | To do List 90 | 91 | 92 | login.do 93 | 94 | 95 | 96 | ``` 97 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step03.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.setAttribute("name", request.getParameter("name")); 67 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 68 | } 69 | 70 | } 71 | ``` 72 | ### \src\main\webapp\WEB-INF\views\login.jsp 73 | ``` 74 | 75 | 76 | Yahoo!! 77 | 78 | 79 | My First JSP!!! My name is ${name} 80 | 81 | 82 | ``` 83 | ### \src\main\webapp\WEB-INF\web.xml 84 | ``` 85 | 86 | 89 | 90 | To do List 91 | 92 | 93 | login.do 94 | 95 | 96 | 97 | ``` 98 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step04.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.setAttribute("name", request.getParameter("name")); 67 | request.setAttribute("password", request.getParameter("password")); 68 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 69 | } 70 | 71 | } 72 | ``` 73 | ### \src\main\webapp\WEB-INF\views\login.jsp 74 | ``` 75 | 76 | 77 | Yahoo!! 78 | 79 | 80 | My First JSP!!! My name is ${name} and password is ${password} 81 | 82 | 83 | ``` 84 | ### \src\main\webapp\WEB-INF\web.xml 85 | ``` 86 | 87 | 90 | 91 | To do List 92 | 93 | 94 | login.do 95 | 96 | 97 | 98 | ``` 99 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step07.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step07.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step11.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step12.md: -------------------------------------------------------------------------------- 1 | #First Spring MVC Controller 2 | - @RequestMapping(value = "/login", method = RequestMethod.GET) 3 | - http://localhost:8080/spring-mvc/login 4 | - web.xml - /spring-mvc/* 5 | - Why @ResponseBody? 6 | - Important of RequestMapping method 7 | - Can I have multiple urls rendered from Same Controller? 8 | 9 | #Snippets 10 | ``` 11 | package com.in28minutes.springmvc; 12 | 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | @Controller 18 | public class LoginController { 19 | 20 | @RequestMapping(value = "/login") 21 | @ResponseBody 22 | public String sayHello() { 23 | return "Hello World dummy"; 24 | } 25 | } 26 | 27 | ``` 28 | 29 | ## Files List 30 | NOT AVAILABLE 31 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step13.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step13.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step15.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step16.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/Step17.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/02-basic-web-application/Step17.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.in28minutes 5 | in28Minutes-springmvc 6 | 0.0.1-SNAPSHOT 7 | war 8 | 9 | 10 | 11 | javax 12 | javaee-web-api 13 | 8.0.1 14 | provided 15 | 16 | 17 | 18 | org.springframework 19 | spring-webmvc 20 | 6.0.10 21 | 22 | 23 | 24 | log4j 25 | log4j 26 | 1.2.17 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-compiler-plugin 36 | 3.2 37 | 38 | true 39 | 17 40 | 17 41 | true 42 | 43 | 44 | 45 | org.apache.tomcat.maven 46 | tomcat7-maven-plugin 47 | 2.2 48 | 49 | / 50 | true 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/java/com/in28minutes/login/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.login; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.ModelMap; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | @Controller 11 | public class LoginController { 12 | 13 | @Autowired 14 | private LoginService loginService; 15 | 16 | @RequestMapping(value = "/login", method = RequestMethod.GET) 17 | public String showLoginPage() { 18 | return "login"; 19 | } 20 | 21 | @RequestMapping(value = "/login", method = RequestMethod.POST) 22 | public String handleUserLogin(ModelMap model, @RequestParam String name, 23 | @RequestParam String password) { 24 | 25 | if (!loginService.validateUser(name, password)) { 26 | model.put("errorMessage", "Invalid Credentials"); 27 | return "login"; 28 | } 29 | 30 | model.put("name", name); 31 | return "welcome"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/java/com/in28minutes/login/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.login; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class LoginService { 7 | public boolean validateUser(String user, String password) { 8 | return user.equalsIgnoreCase("in28Minutes") && password.equals("dummy"); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=TRACE, Appender1, Appender2 2 | 3 | log4j.appender.Appender1=org.apache.log4j.ConsoleAppender 4 | log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n 6 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/webapp/WEB-INF/todo-servlet.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | /WEB-INF/views/ 17 | 18 | 19 | .jsp 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/webapp/WEB-INF/views/login.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yahoo!! 4 | 5 | 6 |

${errorMessage}

7 |
8 | Name : Password : 9 |
10 | 11 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/webapp/WEB-INF/views/welcome.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yahoo!! 4 | 5 | 6 | Welcome ${name}. You are now authenticated. 7 | 8 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/02-basic-web-application/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | To do List 6 | 7 | 8 | dispatcher 9 | 10 | org.springframework.web.servlet.DispatcherServlet 11 | 12 | 13 | contextConfigLocation 14 | /WEB-INF/todo-servlet.xml 15 | 16 | 1 17 | 18 | 19 | 20 | dispatcher 21 | / 22 | 23 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/.gitignore: -------------------------------------------------------------------------------- 1 | -.DS_Store 2 | .idea/ 3 | target/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 03-spring-aop/.classpath 8 | 03-spring-aop/.project 9 | 03-spring-aop/.settings/org.eclipse.core.resources.prefs 10 | 03-spring-aop/.settings/org.eclipse.jdt.core.prefs 11 | 03-spring-aop/.settings/org.eclipse.m2e.core.prefs 12 | 03-spring-aop/.settings/org.eclipse.wst.common.component 13 | 03-spring-aop/.settings/org.eclipse.wst.common.project.facet.core.xml -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/Step01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/Step01.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/Step03.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/Step03.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/Step06.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/Step06.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/Step07.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/Step07.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/Step09.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/Step09.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.in28minutes.spring.aop 7 | spring-aop 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | spring-aop 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 3.2.1 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 21 25 | 3.1.1 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-aop 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | 52 | spring-snapshots 53 | Spring Snapshots 54 | https://repo.spring.io/snapshot 55 | 56 | true 57 | 58 | 59 | 60 | spring-milestones 61 | Spring Milestones 62 | https://repo.spring.io/milestone 63 | 64 | false 65 | 66 | 67 | 68 | 69 | 70 | 71 | spring-snapshots 72 | Spring Snapshots 73 | https://repo.spring.io/snapshot 74 | 75 | true 76 | 77 | 78 | 79 | spring-milestones 80 | Spring Milestones 81 | https://repo.spring.io/milestone 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/SpringAopApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | import com.in28minutes.spring.aop.springaop.business.Business1; 11 | import com.in28minutes.spring.aop.springaop.business.Business2; 12 | 13 | @SpringBootApplication 14 | public class SpringAopApplication implements CommandLineRunner{ 15 | 16 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 17 | 18 | @Autowired 19 | private Business1 business1; 20 | 21 | @Autowired 22 | private Business2 business2; 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(SpringAopApplication.class, args); 26 | } 27 | 28 | @Override 29 | public void run(String... args) throws Exception { 30 | logger.info(business1.calculateSomething()); 31 | logger.info(business2.calculateSomething()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/AfterAopAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.After; 5 | import org.aspectj.lang.annotation.AfterReturning; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | //AOP 12 | //Configuration 13 | @Aspect 14 | @Configuration 15 | public class AfterAopAspect { 16 | 17 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 18 | 19 | @AfterReturning(value = "com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.businessLayerExecution()", 20 | returning = "result") 21 | public void afterReturning(JoinPoint joinPoint, Object result) { 22 | logger.info("{} returned with value {}", joinPoint, result); 23 | } 24 | 25 | @After(value = "com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.businessLayerExecution()") 26 | public void after(JoinPoint joinPoint) { 27 | logger.info("after execution of {}", joinPoint); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/CommonJoinPointConfig.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.annotation.Pointcut; 4 | 5 | public class CommonJoinPointConfig { 6 | 7 | @Pointcut("execution(* com.in28minutes.spring.aop.springaop.data.*.*(..))") 8 | public void dataLayerExecution(){} 9 | 10 | @Pointcut("execution(* com.in28minutes.spring.aop.springaop.business.*.*(..))") 11 | public void businessLayerExecution(){} 12 | 13 | @Pointcut("dataLayerExecution() && businessLayerExecution()") 14 | public void allLayerExecution(){} 15 | 16 | @Pointcut("bean(*dao*)") 17 | public void beanContainingDao(){} 18 | 19 | @Pointcut("within(com.in28minutes.spring.aop.springaop.data..*)") 20 | public void dataLayerExecutionWithWithin(){} 21 | 22 | @Pointcut("@annotation(com.in28minutes.spring.aop.springaop.aspect.TrackTime)") 23 | public void trackTimeAnnotation(){} 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/MethodExecutionCalculationAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Aspect 11 | @Configuration 12 | public class MethodExecutionCalculationAspect { 13 | 14 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 15 | 16 | @Around("com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.trackTimeAnnotation()") 17 | public Object around(ProceedingJoinPoint joinPoint) throws Throwable { 18 | long startTime = System.currentTimeMillis(); 19 | 20 | Object returnProceed = joinPoint.proceed(); 21 | 22 | long timeTaken = System.currentTimeMillis() - startTime; 23 | logger.info("Time Taken by {} is {}", joinPoint, timeTaken); 24 | 25 | return returnProceed; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/TrackTime.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface TrackTime { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/UserAccessAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | //AOP 11 | //Configuration 12 | @Aspect 13 | @Configuration 14 | public class UserAccessAspect { 15 | 16 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 17 | 18 | //What kind of method calls I would intercept 19 | //execution(* PACKAGE.*.*(..)) 20 | //Weaving & Weaver 21 | @Before("com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.dataLayerExecution()") 22 | public void before(JoinPoint joinPoint){ 23 | //Advice 24 | logger.info(" Check for user access "); 25 | logger.info(" Allowed execution for {}", joinPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/business/Business1.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.business; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.in28minutes.spring.aop.springaop.aspect.TrackTime; 9 | import com.in28minutes.spring.aop.springaop.data.Dao1; 10 | 11 | @Service 12 | public class Business1 { 13 | 14 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 15 | 16 | @Autowired 17 | private Dao1 dao1; 18 | 19 | @TrackTime 20 | public String calculateSomething(){ 21 | //Business Logic 22 | String value = dao1.retrieveSomething(); 23 | logger.info("In Business - {}", value); 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/business/Business2.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.business; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.in28minutes.spring.aop.springaop.data.Dao2; 7 | 8 | @Service 9 | public class Business2 { 10 | 11 | @Autowired 12 | private Dao2 dao2; 13 | 14 | public String calculateSomething(){ 15 | //Business Logic 16 | return dao2.retrieveSomething(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/data/Dao1.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.data; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.in28minutes.spring.aop.springaop.aspect.TrackTime; 6 | 7 | @Repository 8 | public class Dao1 { 9 | 10 | @TrackTime 11 | public String retrieveSomething(){ 12 | return "Dao1"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/data/Dao2.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.data; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class Dao2 { 7 | 8 | public String retrieveSomething(){ 9 | return "Dao2"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/03-spring-aop/src/main/resources/application.properties -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/03-spring-aop/src/test/java/com/in28minutes/spring/aop/springaop/SpringAopApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | // replaced @RunWith with @ExtendWith 9 | // replaced SpringRunner.class with SpringExtension.class 10 | @ExtendWith(SpringExtension.class) 11 | @SpringBootTest 12 | public class SpringAopApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | target/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 04-spring-jdbc-to-jpa/.classpath 8 | 04-spring-jdbc-to-jpa/.project 9 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.core.resources.prefs 10 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.jdt.core.prefs 11 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.m2e.core.prefs 12 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.wst.common.component 13 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml 14 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | java:com.in28minutes.database.databasedemo.SpringJdbcDemoApplication 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step01.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step03.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step03.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step05.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step05.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step06.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step06.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step10.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step11.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step12.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step14.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step14.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step15.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step18.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step18.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step19.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/Step19.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/JpaDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.jpa.PersonJpaRepository; 14 | 15 | //@SpringBootApplication 16 | public class JpaDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonJpaRepository repository; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(JpaDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("User id 10001 -> {}", repository.findById(10001)); 31 | 32 | logger.info("Inserting -> {}", 33 | repository.insert(new Person("Tara", "Berlin", new Date()))); 34 | 35 | logger.info("Update 10003 -> {}", 36 | repository.update(new Person(10003, "Pieter", "Utrecht", new Date()))); 37 | 38 | repository.deleteById(10002); 39 | 40 | logger.info("All users -> {}", repository.findAll()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/SpringDataDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.springdata.PersonSpringDataRepository; 14 | 15 | @SpringBootApplication 16 | public class SpringDataDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonSpringDataRepository repository; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(SpringDataDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("User id 10001 -> {}", repository.findById(10001)); 31 | 32 | logger.info("Inserting -> {}", 33 | repository.save(new Person("Tara", "Berlin", new Date()))); 34 | 35 | logger.info("Update 10003 -> {}", 36 | repository.save(new Person(10003, "Pieter", "Utrecht", new Date()))); 37 | 38 | repository.deleteById(10002); 39 | 40 | logger.info("All users -> {}", repository.findAll()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/SpringJdbcDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.jdbc.PersonJbdcDao; 14 | 15 | //@SpringBootApplication 16 | public class SpringJdbcDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonJbdcDao dao; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(SpringJdbcDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("All users -> {}", dao.findAll()); 31 | 32 | logger.info("User id 10001 -> {}", dao.findById(10001)); 33 | 34 | logger.info("Deleting 10002 -> No of Rows Deleted - {}", 35 | dao.deleteById(10002)); 36 | 37 | logger.info("Inserting 10004 -> {}", 38 | dao.insert(new Person(10004, "Tara", "Berlin", new Date()))); 39 | 40 | logger.info("Update 10003 -> {}", 41 | dao.update(new Person(10003, "Pieter", "Utrecht", new Date()))); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/entity/Person.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.entity; 2 | 3 | import java.util.Date; 4 | 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.GeneratedValue; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.NamedQuery; 9 | 10 | @Entity 11 | @NamedQuery(name="find_all_persons", query="select p from Person p") 12 | public class Person { 13 | 14 | @Id 15 | @GeneratedValue 16 | private int id; 17 | 18 | private String name; 19 | private String location; 20 | private Date birthDate; 21 | 22 | public Person() { 23 | 24 | } 25 | 26 | public Person(int id, String name, String location, Date birthDate) { 27 | super(); 28 | this.id = id; 29 | this.name = name; 30 | this.location = location; 31 | this.birthDate = birthDate; 32 | } 33 | 34 | public Person(String name, String location, Date birthDate) { 35 | super(); 36 | this.name = name; 37 | this.location = location; 38 | this.birthDate = birthDate; 39 | } 40 | 41 | public int getId() { 42 | return id; 43 | } 44 | 45 | public void setId(int id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getLocation() { 58 | return location; 59 | } 60 | 61 | public void setLocation(String location) { 62 | this.location = location; 63 | } 64 | 65 | public Date getBirthDate() { 66 | return birthDate; 67 | } 68 | 69 | public void setBirthDate(Date birthDate) { 70 | this.birthDate = birthDate; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return String.format("\nPerson [id=%s, name=%s, location=%s, birthDate=%s]", id, name, location, birthDate); 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/jdbc/PersonJbdcDao.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.jdbc; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.sql.Timestamp; 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.jdbc.core.BeanPropertyRowMapper; 10 | import org.springframework.jdbc.core.JdbcTemplate; 11 | import org.springframework.jdbc.core.RowMapper; 12 | import org.springframework.stereotype.Repository; 13 | 14 | import com.in28minutes.database.databasedemo.entity.Person; 15 | 16 | @Repository 17 | public class PersonJbdcDao { 18 | 19 | @Autowired 20 | JdbcTemplate jdbcTemplate; 21 | 22 | class PersonRowMapper implements RowMapper{ 23 | @Override 24 | public Person mapRow(ResultSet rs, int rowNum) throws SQLException { 25 | Person person = new Person(); 26 | person.setId(rs.getInt("id")); 27 | person.setName(rs.getString("name")); 28 | person.setLocation(rs.getString("location")); 29 | person.setBirthDate(rs.getTimestamp("birth_date")); 30 | return person; 31 | } 32 | 33 | } 34 | 35 | public List findAll() { 36 | return jdbcTemplate.query("select * from person", new PersonRowMapper()); 37 | } 38 | 39 | public Person findById(int id) { 40 | return jdbcTemplate.queryForObject("select * from person where id=?", new Object[] { id }, 41 | new BeanPropertyRowMapper(Person.class)); 42 | } 43 | 44 | public int deleteById(int id) { 45 | return jdbcTemplate.update("delete from person where id=?", new Object[] { id }); 46 | } 47 | 48 | public int insert(Person person) { 49 | return jdbcTemplate.update("insert into person (id, name, location, birth_date) " + "values(?, ?, ?, ?)", 50 | new Object[] { person.getId(), person.getName(), person.getLocation(), 51 | new Timestamp(person.getBirthDate().getTime()) }); 52 | } 53 | 54 | public int update(Person person) { 55 | return jdbcTemplate.update("update person " + " set name = ?, location = ?, birth_date = ? " + " where id = ?", 56 | new Object[] { person.getName(), person.getLocation(), new Timestamp(person.getBirthDate().getTime()), 57 | person.getId() }); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/jpa/PersonJpaRepository.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.jpa; 2 | 3 | import java.util.List; 4 | 5 | import jakarta.persistence.EntityManager; 6 | import jakarta.persistence.PersistenceContext; 7 | import jakarta.persistence.TypedQuery; 8 | import jakarta.transaction.Transactional; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import com.in28minutes.database.databasedemo.entity.Person; 12 | 13 | @Repository 14 | @Transactional 15 | public class PersonJpaRepository { 16 | 17 | // connect to the database 18 | @PersistenceContext 19 | EntityManager entityManager; 20 | 21 | public List findAll() { 22 | TypedQuery namedQuery = entityManager.createNamedQuery("find_all_persons", Person.class); 23 | return namedQuery.getResultList(); 24 | } 25 | 26 | public Person findById(int id) { 27 | return entityManager.find(Person.class, id);// JPA 28 | } 29 | 30 | public Person update(Person person) { 31 | return entityManager.merge(person); 32 | } 33 | 34 | public Person insert(Person person) { 35 | return entityManager.merge(person); 36 | } 37 | 38 | public void deleteById(int id) { 39 | Person person = findById(id); 40 | entityManager.remove(person); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/springdata/PersonSpringDataRepository.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.springdata; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.in28minutes.database.databasedemo.entity.Person; 7 | 8 | @Repository 9 | public interface PersonSpringDataRepository 10 | extends JpaRepository{ 11 | } 12 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.h2.console.enabled=true 2 | spring.jpa.show-sql=true 3 | logging.level.root=debug 4 | 5 | spring.datasource.url=jdbc:h2:mem:testdb 6 | spring.data.jpa.repositories.bootstrap-mode=default 7 | spring.jpa.defer-datasource-initialization=true -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | /* 2 | create table person 3 | ( 4 | id integer not null, 5 | name varchar(255) not null, 6 | location varchar(255), 7 | birth_date timestamp, 8 | primary key(id) 9 | ); 10 | */ 11 | 12 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 13 | VALUES(10001, 'Ranga', 'Hyderabad',CURRENT_DATE); 14 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 15 | VALUES(10002, 'James', 'New York',CURRENT_DATE); 16 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 17 | VALUES(10003, 'Pieter', 'Amsterdam',CURRENT_DATE); 18 | 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/04-spring-jdbc-to-jpa/src/test/java/com/in28minutes/database/databasedemo/SpringJdbcDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | // replaced @RunWith with @ExtendWith 9 | // replaced SpringRunner.class with SpringExtension.class 10 | @ExtendWith(SpringExtension.class) 11 | @SpringBootTest 12 | public class SpringJdbcDemoApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/99-old-code/archive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/Code Bundle/spring-master-class-master/99-old-code/archive.zip -------------------------------------------------------------------------------- /Code Bundle/spring-master-class-master/README.md: -------------------------------------------------------------------------------- 1 | # Spring Master Class - Journey from Beginner to Expert 2 | 3 | Learn the magic of Spring Framework. From IOC (Inversion of Control), DI (Dependency Injection), Application Context to the world of Spring Boot, AOP, JDBC and JPA. Get set for an incredible journey. 4 | 5 | ### Introduction 6 | 7 | Spring Framework remains as popular today as it was when I first used it 12 years back. How is this possible in the incredibly dynamic world where architectures have completely changed? 8 | 9 | ### What You will learn 10 | 11 | - You will learn the basics of Spring Framework - Dependency Injection, IOC Container, Application Context and Bean Factory. 12 | - You will understand how to use Spring Annotations - @Autowired, @Component, @Service, @Repository, @Configuration, @Primary.... 13 | - You will understand Spring MVC in depth - DispatcherServlet , Model, Controllers and ViewResolver 14 | - You will use a variety of Spring Boot Starters - Spring Boot Starter Web, Starter Data Jpa, Starter Test 15 | - You will learn the basics of Spring Boot, Spring AOP, Spring JDBC and JPA 16 | - You will learn the basics of Eclipse, Maven, JUnit and Mockito 17 | - You will develop a basic Web application step by step using JSP Servlets and Spring MVC 18 | - You will learn to write unit tests with XML, Java Application Contexts and Mockito 19 | 20 | ### Requirements 21 | - You should have working knowledge of Java and Annotations. 22 | - We will help you install Eclipse and get up and running with Maven and Tomcat. 23 | 24 | 25 | ### Step Wise Details 26 | Refer each section 27 | 28 | ## Installing Tools 29 | - Installation Video : https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3 30 | - GIT Repository For Installation : https://github.com/in28minutes/getting-started-in-5-steps 31 | - PDF : https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf 32 | 33 | ## Running Examples 34 | - Download the zip or clone the Git repository. 35 | - Unzip the zip file (if you downloaded one) 36 | - Open Command Prompt and Change directory (cd) to folder containing pom.xml 37 | - Open Eclipse 38 | - File -> Import -> Existing Maven Project -> Navigate to the folder where you unzipped the zip 39 | - Select the right project 40 | - Choose the Spring Boot Application file (search for @SpringBootApplication) 41 | - Right Click on the file and Run as Java Application 42 | - You are all Set 43 | - For help : use our installation guide - https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3 44 | 45 | ### Troubleshooting 46 | - Refer our TroubleShooting Guide - https://github.com/in28minutes/in28minutes-initiatives/tree/master/The-in28Minutes-TroubleshootingGuide-And-FAQ 47 | 48 | 49 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring Framework Master Class - Java Spring the Modern Way 2 | 3 | This is the code repository for Spring Framework Master Class - Java Spring the Modern Way, published by [Packt](https://www.packtpub.com/?utm_source=github). It contains all the supporting project files necessary to work through the video course from start to finish. 4 | 5 | Learn the magic of Spring Framework. From IOC (Inversion of Control), DI (Dependency Injection), Application Context to the world of Spring Boot, AOP, JDBC and JPA. Get set for an incredible journey. 6 | 7 | ### Introduction 8 | 9 | Spring Framework remains as popular today as it was when I first used it 12 years back. How is this possible in the incredibly dynamic world where architectures have completely changed? 10 | 11 | ### What You will learn 12 | 13 | - You will learn the basics of Spring Framework - Dependency Injection, IOC Container, Application Context and Bean Factory. 14 | - You will understand how to use Spring Annotations - @Autowired, @Component, @Service, @Repository, @Configuration, @Primary.... 15 | - You will understand Spring MVC in depth - DispatcherServlet , Model, Controllers and ViewResolver 16 | - You will use a variety of Spring Boot Starters - Spring Boot Starter Web, Starter Data Jpa, Starter Test 17 | - You will learn the basics of Spring Boot, Spring AOP, Spring JDBC and JPA 18 | - You will learn the basics of Eclipse, Maven, JUnit and Mockito 19 | - You will develop a basic Web application step by step using JSP Servlets and Spring MVC 20 | - You will learn to write unit tests with XML, Java Application Contexts and Mockito 21 | 22 | ### Requirements 23 | - You should have working knowledge of Java and Annotations. 24 | - We will help you install Eclipse and get up and running with Maven and Tomcat. 25 | -------------------------------------------------------------------------------- /S02 - Level 1 to 6 - Course Overview/SpringMasterClass-CourseGuidev0.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S02 - Level 1 to 6 - Course Overview/SpringMasterClass-CourseGuidev0.1.pdf -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step10.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step12.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step14.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step14.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step15.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step16.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step17.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step17.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step18.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step18.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step19.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step19.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step20.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step20.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step22_XMLContextConfigurationFirstExampleComplete.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step22_XMLContextConfigurationFirstExampleComplete.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step23.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step23.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step25B.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step25B.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step26.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step26.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step29.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/Step29.zip -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/componentscan/ComponentDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.componentscan; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class ComponentDAO { 8 | 9 | @Autowired 10 | ComponentJdbcConnection jdbcConnection; 11 | 12 | public ComponentJdbcConnection getJdbcConnection() { 13 | return jdbcConnection; 14 | } 15 | 16 | public void setComponentJdbcConnection(ComponentJdbcConnection jdbcConnection) { 17 | this.jdbcConnection = jdbcConnection; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/componentscan/ComponentJdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.componentscan; 2 | 3 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 4 | import org.springframework.context.annotation.Scope; 5 | import org.springframework.context.annotation.ScopedProxyMode; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE, 10 | proxyMode = ScopedProxyMode.TARGET_CLASS) 11 | public class ComponentJdbcConnection { 12 | public ComponentJdbcConnection() { 13 | System.out.println("JDBC Connection"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsBasicApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.in28minutes.spring.basics.springin5steps.basic.BinarySearchImpl; 8 | 9 | @Configuration 10 | @ComponentScan 11 | public class SpringIn5StepsBasicApplication { 12 | 13 | public static void main(String[] args) { 14 | 15 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsBasicApplication.class)) { 16 | 17 | var binarySearch = applicationContext.getBean(BinarySearchImpl.class); 18 | 19 | var binarySearch1 = applicationContext.getBean(BinarySearchImpl.class); 20 | 21 | System.out.println(binarySearch); 22 | System.out.println(binarySearch1); 23 | 24 | int result = binarySearch.binarySearch(new int[] { 12, 4, 6 }, 3); 25 | System.out.println(result); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsCdiApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.springin5steps.cdi.SomeCdiBusiness; 10 | 11 | @Configuration 12 | @ComponentScan 13 | public class SpringIn5StepsCdiApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsCdiApplication.class); 16 | 17 | public static void main(String[] args) { 18 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsCdiApplication.class)) { 19 | var business = applicationContext.getBean(SomeCdiBusiness.class); 20 | 21 | LOGGER.info("{} dao-{}", business, business.getSomeCDIDAO()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsComponentScanApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.componentscan.ComponentDAO; 10 | 11 | @Configuration 12 | @ComponentScan("com.in28minutes.spring.basics.componentscan") 13 | public class SpringIn5StepsComponentScanApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsComponentScanApplication.class); 16 | 17 | public static void main(String[] args) { 18 | 19 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsComponentScanApplication.class)) { 20 | var componentDAO = applicationContext.getBean(ComponentDAO.class); 21 | 22 | LOGGER.info("{}", componentDAO); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsPropertiesApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.PropertySource; 7 | 8 | import com.in28minutes.spring.basics.springin5steps.properties.SomeExternalService; 9 | 10 | @Configuration 11 | @ComponentScan 12 | // 13 | @PropertySource("classpath:app.properties") 14 | public class SpringIn5StepsPropertiesApplication { 15 | 16 | public static void main(String[] args) { 17 | 18 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsPropertiesApplication.class)) { 19 | 20 | var service = applicationContext.getBean(SomeExternalService.class); 21 | System.out.println(service.returnServiceURL()); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsScopeApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import com.in28minutes.spring.basics.springin5steps.scope.PersonDAO; 10 | 11 | @Configuration 12 | @ComponentScan 13 | public class SpringIn5StepsScopeApplication { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsScopeApplication.class); 16 | 17 | public static void main(String[] args) { 18 | 19 | try (var applicationContext = new AnnotationConfigApplicationContext(SpringIn5StepsScopeApplication.class)) { 20 | 21 | var personDao = applicationContext.getBean(PersonDAO.class); 22 | 23 | var personDao2 = applicationContext.getBean(PersonDAO.class); 24 | 25 | LOGGER.info("{}", personDao); 26 | LOGGER.info("{}", personDao.getJdbcConnection()); 27 | LOGGER.info("{}", personDao.getJdbcConnection()); 28 | 29 | LOGGER.info("{}", personDao2); 30 | LOGGER.info("{}", personDao.getJdbcConnection()); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsXMLContextApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | import com.in28minutes.spring.basics.springin5steps.xml.XmlPersonDAO; 8 | 9 | public class SpringIn5StepsXMLContextApplication { 10 | 11 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringIn5StepsXMLContextApplication.class); 12 | 13 | public static void main(String[] args) { 14 | 15 | try (var applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml")) { 16 | 17 | LOGGER.info("Beans Loaded -> {}", (Object) applicationContext.getBeanDefinitionNames()); 18 | // [xmlJdbcConnection, xmlPersonDAO] 19 | 20 | var personDao = applicationContext.getBean(XmlPersonDAO.class); 21 | 22 | LOGGER.info("{} {}", personDao, personDao.getXmlJdbcConnection()); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchImpl.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import jakarta.annotation.PostConstruct; 4 | import jakarta.annotation.PreDestroy; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.beans.factory.annotation.Qualifier; 9 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 10 | import org.springframework.context.annotation.Scope; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service 14 | @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) 15 | public class BinarySearchImpl { 16 | 17 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 18 | 19 | @Autowired 20 | @Qualifier("bubble") 21 | private SortAlgorithm sortAlgorithm; 22 | 23 | public int binarySearch(int[] numbers, int numberToSearchFor) { 24 | 25 | int[] sortedNumbers = sortAlgorithm.sort(numbers); 26 | System.out.println(sortAlgorithm); 27 | // Search the array 28 | return 3; 29 | } 30 | 31 | @PostConstruct 32 | public void postConstruct() { 33 | logger.info("postConstruct"); 34 | } 35 | 36 | @PreDestroy 37 | public void preDestroy() { 38 | logger.info("preDestroy"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/BubbleSortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | @Qualifier("bubble") 8 | public class BubbleSortAlgorithm implements SortAlgorithm { 9 | public int[] sort(int[] numbers) { 10 | // Logic for Bubble Sort 11 | return numbers; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/QuickSortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | @Qualifier("quick") 8 | public class QuickSortAlgorithm implements SortAlgorithm { 9 | public int[] sort(int[] numbers) { 10 | // Logic for Quick Sort 11 | return numbers; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/basic/SortAlgorithm.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | public interface SortAlgorithm { 4 | int[] sort(int[] numbers); 5 | } 6 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiBusiness.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | import org.springframework.stereotype.Component; 7 | 8 | @Named 9 | @Component 10 | public class SomeCdiBusiness { 11 | 12 | @Inject 13 | SomeCdiDao someCdiDao; 14 | 15 | public SomeCdiDao getSomeCDIDAO() { 16 | return someCdiDao; 17 | } 18 | 19 | public void setSomeCDIDAO(SomeCdiDao someCdiDao) { 20 | this.someCdiDao = someCdiDao; 21 | } 22 | 23 | public int findGreatest() { 24 | int greatest = Integer.MIN_VALUE; 25 | int[] data = someCdiDao.getData(); 26 | for (int value : data) { 27 | if (value > greatest) { 28 | greatest = value; 29 | } 30 | } 31 | return greatest; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiDao.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import javax.inject.Named; 4 | 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Named 8 | @Repository 9 | public class SomeCdiDao { 10 | 11 | public int[] getData() { 12 | return new int[] {5, 89,100}; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/properties/SomeExternalService.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.properties; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class SomeExternalService { 8 | 9 | @Value("${external.service.url}") 10 | private String url; 11 | 12 | public String returnServiceURL(){ 13 | return url; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/scope/JdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.scope; 2 | 3 | import org.springframework.beans.factory.config.ConfigurableBeanFactory; 4 | import org.springframework.context.annotation.Scope; 5 | import org.springframework.context.annotation.ScopedProxyMode; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE, 10 | proxyMode = ScopedProxyMode.TARGET_CLASS) 11 | public class JdbcConnection { 12 | public JdbcConnection() { 13 | System.out.println("JDBC Connection"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/scope/PersonDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.scope; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class PersonDAO { 8 | 9 | @Autowired 10 | JdbcConnection jdbcConnection; 11 | 12 | public JdbcConnection getJdbcConnection() { 13 | return jdbcConnection; 14 | } 15 | 16 | public void setJdbcConnection(JdbcConnection jdbcConnection) { 17 | this.jdbcConnection = jdbcConnection; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/xml/XmlJdbcConnection.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.xml; 2 | 3 | public class XmlJdbcConnection { 4 | public XmlJdbcConnection() { 5 | System.out.println("JDBC Connection"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/java/com/in28minutes/spring/basics/springin5steps/xml/XmlPersonDAO.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.xml; 2 | 3 | public class XmlPersonDAO { 4 | 5 | XmlJdbcConnection xmlJdbcConnection; 6 | 7 | public XmlJdbcConnection getXmlJdbcConnection() { 8 | return xmlJdbcConnection; 9 | } 10 | 11 | public void setXmlJdbcConnection(XmlJdbcConnection jdbcConnection) { 12 | this.xmlJdbcConnection = jdbcConnection; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | external.service.url=http://someserver.dev.com/service -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #logging.level.org.springframework = debug -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/main/resources/log.txt: -------------------------------------------------------------------------------- 1 | Searching directory [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps] for files matching pattern [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/**/*.class] 2 | Identified candidate component class: file [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/BinarySearchImpl.class] 3 | Identified candidate component class: file [/in28Minutes/git/getting-started-in-5-steps/spring-in-5-steps/target/classes/com/in28minutes/spring/basics/springin5steps/BubbleSortAlgorithm.class] 4 | 5 | Creating instance of bean 'binarySearchImpl' 6 | Creating instance of bean 'bubbleSortAlgorithm' 7 | Finished creating instance of bean 'bubbleSortAlgorithm' 8 | 9 | Constuctor - Autowiring by type from bean name 'binarySearchImpl' via constructor 10 | to bean named 'bubbleSortAlgorithm' 11 | Setter - Autowiring by type from bean name 'binarySearchImpl' to bean named 'bubbleSortAlgorithm' 12 | No Setter or Constructor - Autowiring by type from bean name 'binarySearchImpl' to bean named 'bubbleSortAlgorithm' 13 | 14 | 15 | Finished creating instance of bean 'binarySearchImpl' 16 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/SpringIn5StepsBasicApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | @ExtendWith(SpringExtension.class) 9 | @ContextConfiguration(locations="/testContext.xml") 10 | class SpringIn5StepsBasicApplicationTests { 11 | 12 | @Test 13 | void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import com.in28minutes.spring.basics.springin5steps.SpringIn5StepsBasicApplication; 6 | import org.junit.jupiter.api.Test; 7 | import org.junit.jupiter.api.extension.ExtendWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit.jupiter.SpringExtension; 11 | 12 | // Load the context 13 | @ExtendWith(SpringExtension.class) 14 | @ContextConfiguration(classes = SpringIn5StepsBasicApplication.class) 15 | class BinarySearchTest { 16 | 17 | // Get this bean from the context 18 | @Autowired 19 | BinarySearchImpl binarySearch; 20 | 21 | @Test 22 | void testBasicScenario() { 23 | 24 | // call method on binarySearch 25 | int actualResult = binarySearch.binarySearch(new int[] {}, 5); 26 | 27 | // check if the value is correct 28 | assertEquals(3, actualResult); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/basic/BinarySearchXMLConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.basic; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit.jupiter.SpringExtension; 10 | 11 | //Load the context 12 | @ExtendWith(SpringExtension.class) 13 | @ContextConfiguration(locations="/testContext.xml") 14 | class BinarySearchXMLConfigurationTest { 15 | 16 | // Get this bean from the context 17 | @Autowired 18 | BinarySearchImpl binarySearch; 19 | 20 | @Test 21 | void testBasicScenario() { 22 | 23 | // call method on binarySearch 24 | int actualResult = binarySearch.binarySearch(new int[] {}, 5); 25 | 26 | // check if the value is correct 27 | assertEquals(3, actualResult); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/test/java/com/in28minutes/spring/basics/springin5steps/cdi/SomeCdiBusinessTest.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.basics.springin5steps.cdi; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.mockito.InjectMocks; 8 | import org.mockito.Mock; 9 | import org.mockito.Mockito; 10 | import org.mockito.junit.jupiter.MockitoExtension; 11 | import org.springframework.context.annotation.ImportResource; 12 | 13 | @ExtendWith(MockitoExtension.class) 14 | class SomeCdiBusinessTest { 15 | 16 | // Inject Mock 17 | @InjectMocks 18 | SomeCdiBusiness business; 19 | 20 | // Create Mock 21 | @Mock 22 | SomeCdiDao daoMock; 23 | 24 | @Test 25 | void testBasicScenario() { 26 | Mockito.when(daoMock.getData()).thenReturn(new int[] { 2, 4 }); 27 | assertEquals(4, business.findGreatest()); 28 | } 29 | 30 | @Test 31 | void testBasicScenario_NoElements() { 32 | Mockito.when(daoMock.getData()).thenReturn(new int[] { }); 33 | assertEquals(Integer.MIN_VALUE, business.findGreatest()); 34 | } 35 | 36 | @Test 37 | void testBasicScenario_EqualElements() { 38 | Mockito.when(daoMock.getData()).thenReturn(new int[] { 2,2}); 39 | assertEquals(2, business.findGreatest()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/01-spring-in-depth/src/test/resources/testContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/DO NOT SKIP - New to Maven and Eclipse.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/DO NOT SKIP - New to Maven and Eclipse.docx -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/Fastest Approach to Solve All Your Exceptions.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/Fastest Approach to Solve All Your Exceptions.docx -------------------------------------------------------------------------------- /S03 - Level 1 - Introduction to Java Spring Framework/Spring Framework Level 1, 2 and 3 - Github Folder.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S03 - Level 1 - Introduction to Java Spring Framework/Spring Framework Level 1, 2 and 3 - Github Folder.docx -------------------------------------------------------------------------------- /S04 - Level 2 - Spring Framework in Depth/Ignore SLF4J Errors in Step 19 - We will fix them in Step 20.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S04 - Level 2 - Spring Framework in Depth/Ignore SLF4J Errors in Step 19 - We will fix them in Step 20.docx -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/.gitignore: -------------------------------------------------------------------------------- 1 | -.DS_Store 2 | .idea/ 3 | target/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 03-spring-aop/.classpath 8 | 03-spring-aop/.project 9 | 03-spring-aop/.settings/org.eclipse.core.resources.prefs 10 | 03-spring-aop/.settings/org.eclipse.jdt.core.prefs 11 | 03-spring-aop/.settings/org.eclipse.m2e.core.prefs 12 | 03-spring-aop/.settings/org.eclipse.wst.common.component 13 | 03-spring-aop/.settings/org.eclipse.wst.common.project.facet.core.xml -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/Step01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/Step01.zip -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/Step03.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/Step03.zip -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/Step06.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/Step06.zip -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/Step07.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/Step07.zip -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/Step09.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/Step09.zip -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.in28minutes.spring.aop 7 | spring-aop 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | spring-aop 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 3.2.1 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 21 25 | 3.1.1 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-aop 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | 48 | 49 | 50 | 51 | 52 | spring-snapshots 53 | Spring Snapshots 54 | https://repo.spring.io/snapshot 55 | 56 | true 57 | 58 | 59 | 60 | spring-milestones 61 | Spring Milestones 62 | https://repo.spring.io/milestone 63 | 64 | false 65 | 66 | 67 | 68 | 69 | 70 | 71 | spring-snapshots 72 | Spring Snapshots 73 | https://repo.spring.io/snapshot 74 | 75 | true 76 | 77 | 78 | 79 | spring-milestones 80 | Spring Milestones 81 | https://repo.spring.io/milestone 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/SpringAopApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | import com.in28minutes.spring.aop.springaop.business.Business1; 11 | import com.in28minutes.spring.aop.springaop.business.Business2; 12 | 13 | @SpringBootApplication 14 | public class SpringAopApplication implements CommandLineRunner{ 15 | 16 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 17 | 18 | @Autowired 19 | private Business1 business1; 20 | 21 | @Autowired 22 | private Business2 business2; 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(SpringAopApplication.class, args); 26 | } 27 | 28 | @Override 29 | public void run(String... args) throws Exception { 30 | logger.info(business1.calculateSomething()); 31 | logger.info(business2.calculateSomething()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/AfterAopAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.After; 5 | import org.aspectj.lang.annotation.AfterReturning; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | //AOP 12 | //Configuration 13 | @Aspect 14 | @Configuration 15 | public class AfterAopAspect { 16 | 17 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 18 | 19 | @AfterReturning(value = "com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.businessLayerExecution()", 20 | returning = "result") 21 | public void afterReturning(JoinPoint joinPoint, Object result) { 22 | logger.info("{} returned with value {}", joinPoint, result); 23 | } 24 | 25 | @After(value = "com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.businessLayerExecution()") 26 | public void after(JoinPoint joinPoint) { 27 | logger.info("after execution of {}", joinPoint); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/CommonJoinPointConfig.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.annotation.Pointcut; 4 | 5 | public class CommonJoinPointConfig { 6 | 7 | @Pointcut("execution(* com.in28minutes.spring.aop.springaop.data.*.*(..))") 8 | public void dataLayerExecution(){} 9 | 10 | @Pointcut("execution(* com.in28minutes.spring.aop.springaop.business.*.*(..))") 11 | public void businessLayerExecution(){} 12 | 13 | @Pointcut("dataLayerExecution() && businessLayerExecution()") 14 | public void allLayerExecution(){} 15 | 16 | @Pointcut("bean(*dao*)") 17 | public void beanContainingDao(){} 18 | 19 | @Pointcut("within(com.in28minutes.spring.aop.springaop.data..*)") 20 | public void dataLayerExecutionWithWithin(){} 21 | 22 | @Pointcut("@annotation(com.in28minutes.spring.aop.springaop.aspect.TrackTime)") 23 | public void trackTimeAnnotation(){} 24 | 25 | } 26 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/MethodExecutionCalculationAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Aspect 11 | @Configuration 12 | public class MethodExecutionCalculationAspect { 13 | 14 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 15 | 16 | @Around("com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.trackTimeAnnotation()") 17 | public Object around(ProceedingJoinPoint joinPoint) throws Throwable { 18 | long startTime = System.currentTimeMillis(); 19 | 20 | Object returnProceed = joinPoint.proceed(); 21 | 22 | long timeTaken = System.currentTimeMillis() - startTime; 23 | logger.info("Time Taken by {} is {}", joinPoint, timeTaken); 24 | 25 | return returnProceed; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/TrackTime.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface TrackTime { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/aspect/UserAccessAspect.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.aspect; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | //AOP 11 | //Configuration 12 | @Aspect 13 | @Configuration 14 | public class UserAccessAspect { 15 | 16 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 17 | 18 | //What kind of method calls I would intercept 19 | //execution(* PACKAGE.*.*(..)) 20 | //Weaving & Weaver 21 | @Before("com.in28minutes.spring.aop.springaop.aspect.CommonJoinPointConfig.dataLayerExecution()") 22 | public void before(JoinPoint joinPoint){ 23 | //Advice 24 | logger.info(" Check for user access "); 25 | logger.info(" Allowed execution for {}", joinPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/business/Business1.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.business; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.in28minutes.spring.aop.springaop.aspect.TrackTime; 9 | import com.in28minutes.spring.aop.springaop.data.Dao1; 10 | 11 | @Service 12 | public class Business1 { 13 | 14 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 15 | 16 | @Autowired 17 | private Dao1 dao1; 18 | 19 | @TrackTime 20 | public String calculateSomething(){ 21 | //Business Logic 22 | String value = dao1.retrieveSomething(); 23 | logger.info("In Business - {}", value); 24 | return value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/business/Business2.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.business; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.in28minutes.spring.aop.springaop.data.Dao2; 7 | 8 | @Service 9 | public class Business2 { 10 | 11 | @Autowired 12 | private Dao2 dao2; 13 | 14 | public String calculateSomething(){ 15 | //Business Logic 16 | return dao2.retrieveSomething(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/data/Dao1.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.data; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.in28minutes.spring.aop.springaop.aspect.TrackTime; 6 | 7 | @Repository 8 | public class Dao1 { 9 | 10 | @TrackTime 11 | public String retrieveSomething(){ 12 | return "Dao1"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/java/com/in28minutes/spring/aop/springaop/data/Dao2.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop.data; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class Dao2 { 7 | 8 | public String retrieveSomething(){ 9 | return "Dao2"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/03-spring-aop/src/main/resources/application.properties -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/03-spring-aop/src/test/java/com/in28minutes/spring/aop/springaop/SpringAopApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.spring.aop.springaop; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | // replaced @RunWith with @ExtendWith 9 | // replaced SpringRunner.class with SpringExtension.class 10 | @ExtendWith(SpringExtension.class) 11 | @SpringBootTest 12 | public class SpringAopApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /S09 - Level 5 - Spring AOP/COURSE UPDATE - AOP Dependency Removed From Spring Initializr.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S09 - Level 5 - Spring AOP/COURSE UPDATE - AOP Dependency Removed From Spring Initializr.docx -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | target/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 04-spring-jdbc-to-jpa/.classpath 8 | 04-spring-jdbc-to-jpa/.project 9 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.core.resources.prefs 10 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.jdt.core.prefs 11 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.m2e.core.prefs 12 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.wst.common.component 13 | 04-spring-jdbc-to-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml 14 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | java:com.in28minutes.database.databasedemo.SpringJdbcDemoApplication 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step01.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step03.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step03.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step05.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step05.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step06.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step06.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step10.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step11.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step12.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step14.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step14.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step15.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step18.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step18.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step19.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/Step19.zip -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/JpaDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.jpa.PersonJpaRepository; 14 | 15 | //@SpringBootApplication 16 | public class JpaDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonJpaRepository repository; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(JpaDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("User id 10001 -> {}", repository.findById(10001)); 31 | 32 | logger.info("Inserting -> {}", 33 | repository.insert(new Person("Tara", "Berlin", new Date()))); 34 | 35 | logger.info("Update 10003 -> {}", 36 | repository.update(new Person(10003, "Pieter", "Utrecht", new Date()))); 37 | 38 | repository.deleteById(10002); 39 | 40 | logger.info("All users -> {}", repository.findAll()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/SpringDataDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.springdata.PersonSpringDataRepository; 14 | 15 | @SpringBootApplication 16 | public class SpringDataDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonSpringDataRepository repository; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(SpringDataDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("User id 10001 -> {}", repository.findById(10001)); 31 | 32 | logger.info("Inserting -> {}", 33 | repository.save(new Person("Tara", "Berlin", new Date()))); 34 | 35 | logger.info("Update 10003 -> {}", 36 | repository.save(new Person(10003, "Pieter", "Utrecht", new Date()))); 37 | 38 | repository.deleteById(10002); 39 | 40 | logger.info("All users -> {}", repository.findAll()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/SpringJdbcDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import java.util.Date; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | 12 | import com.in28minutes.database.databasedemo.entity.Person; 13 | import com.in28minutes.database.databasedemo.jdbc.PersonJbdcDao; 14 | 15 | //@SpringBootApplication 16 | public class SpringJdbcDemoApplication implements CommandLineRunner { 17 | 18 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 19 | 20 | @Autowired 21 | PersonJbdcDao dao; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(SpringJdbcDemoApplication.class, args); 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | logger.info("All users -> {}", dao.findAll()); 31 | 32 | logger.info("User id 10001 -> {}", dao.findById(10001)); 33 | 34 | logger.info("Deleting 10002 -> No of Rows Deleted - {}", 35 | dao.deleteById(10002)); 36 | 37 | logger.info("Inserting 10004 -> {}", 38 | dao.insert(new Person(10004, "Tara", "Berlin", new Date()))); 39 | 40 | logger.info("Update 10003 -> {}", 41 | dao.update(new Person(10003, "Pieter", "Utrecht", new Date()))); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/entity/Person.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.entity; 2 | 3 | import java.util.Date; 4 | 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.GeneratedValue; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.NamedQuery; 9 | 10 | @Entity 11 | @NamedQuery(name="find_all_persons", query="select p from Person p") 12 | public class Person { 13 | 14 | @Id 15 | @GeneratedValue 16 | private int id; 17 | 18 | private String name; 19 | private String location; 20 | private Date birthDate; 21 | 22 | public Person() { 23 | 24 | } 25 | 26 | public Person(int id, String name, String location, Date birthDate) { 27 | super(); 28 | this.id = id; 29 | this.name = name; 30 | this.location = location; 31 | this.birthDate = birthDate; 32 | } 33 | 34 | public Person(String name, String location, Date birthDate) { 35 | super(); 36 | this.name = name; 37 | this.location = location; 38 | this.birthDate = birthDate; 39 | } 40 | 41 | public int getId() { 42 | return id; 43 | } 44 | 45 | public void setId(int id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getLocation() { 58 | return location; 59 | } 60 | 61 | public void setLocation(String location) { 62 | this.location = location; 63 | } 64 | 65 | public Date getBirthDate() { 66 | return birthDate; 67 | } 68 | 69 | public void setBirthDate(Date birthDate) { 70 | this.birthDate = birthDate; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return String.format("\nPerson [id=%s, name=%s, location=%s, birthDate=%s]", id, name, location, birthDate); 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/jdbc/PersonJbdcDao.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.jdbc; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.sql.Timestamp; 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.jdbc.core.BeanPropertyRowMapper; 10 | import org.springframework.jdbc.core.JdbcTemplate; 11 | import org.springframework.jdbc.core.RowMapper; 12 | import org.springframework.stereotype.Repository; 13 | 14 | import com.in28minutes.database.databasedemo.entity.Person; 15 | 16 | @Repository 17 | public class PersonJbdcDao { 18 | 19 | @Autowired 20 | JdbcTemplate jdbcTemplate; 21 | 22 | class PersonRowMapper implements RowMapper{ 23 | @Override 24 | public Person mapRow(ResultSet rs, int rowNum) throws SQLException { 25 | Person person = new Person(); 26 | person.setId(rs.getInt("id")); 27 | person.setName(rs.getString("name")); 28 | person.setLocation(rs.getString("location")); 29 | person.setBirthDate(rs.getTimestamp("birth_date")); 30 | return person; 31 | } 32 | 33 | } 34 | 35 | public List findAll() { 36 | return jdbcTemplate.query("select * from person", new PersonRowMapper()); 37 | } 38 | 39 | public Person findById(int id) { 40 | return jdbcTemplate.queryForObject("select * from person where id=?", new Object[] { id }, 41 | new BeanPropertyRowMapper(Person.class)); 42 | } 43 | 44 | public int deleteById(int id) { 45 | return jdbcTemplate.update("delete from person where id=?", new Object[] { id }); 46 | } 47 | 48 | public int insert(Person person) { 49 | return jdbcTemplate.update("insert into person (id, name, location, birth_date) " + "values(?, ?, ?, ?)", 50 | new Object[] { person.getId(), person.getName(), person.getLocation(), 51 | new Timestamp(person.getBirthDate().getTime()) }); 52 | } 53 | 54 | public int update(Person person) { 55 | return jdbcTemplate.update("update person " + " set name = ?, location = ?, birth_date = ? " + " where id = ?", 56 | new Object[] { person.getName(), person.getLocation(), new Timestamp(person.getBirthDate().getTime()), 57 | person.getId() }); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/jpa/PersonJpaRepository.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.jpa; 2 | 3 | import java.util.List; 4 | 5 | import jakarta.persistence.EntityManager; 6 | import jakarta.persistence.PersistenceContext; 7 | import jakarta.persistence.TypedQuery; 8 | import jakarta.transaction.Transactional; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import com.in28minutes.database.databasedemo.entity.Person; 12 | 13 | @Repository 14 | @Transactional 15 | public class PersonJpaRepository { 16 | 17 | // connect to the database 18 | @PersistenceContext 19 | EntityManager entityManager; 20 | 21 | public List findAll() { 22 | TypedQuery namedQuery = entityManager.createNamedQuery("find_all_persons", Person.class); 23 | return namedQuery.getResultList(); 24 | } 25 | 26 | public Person findById(int id) { 27 | return entityManager.find(Person.class, id);// JPA 28 | } 29 | 30 | public Person update(Person person) { 31 | return entityManager.merge(person); 32 | } 33 | 34 | public Person insert(Person person) { 35 | return entityManager.merge(person); 36 | } 37 | 38 | public void deleteById(int id) { 39 | Person person = findById(id); 40 | entityManager.remove(person); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/java/com/in28minutes/database/databasedemo/springdata/PersonSpringDataRepository.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo.springdata; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.in28minutes.database.databasedemo.entity.Person; 7 | 8 | @Repository 9 | public interface PersonSpringDataRepository 10 | extends JpaRepository{ 11 | } 12 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.h2.console.enabled=true 2 | spring.jpa.show-sql=true 3 | logging.level.root=debug 4 | 5 | spring.datasource.url=jdbc:h2:mem:testdb 6 | spring.data.jpa.repositories.bootstrap-mode=default 7 | spring.jpa.defer-datasource-initialization=true -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | /* 2 | create table person 3 | ( 4 | id integer not null, 5 | name varchar(255) not null, 6 | location varchar(255), 7 | birth_date timestamp, 8 | primary key(id) 9 | ); 10 | */ 11 | 12 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 13 | VALUES(10001, 'Ranga', 'Hyderabad',CURRENT_DATE); 14 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 15 | VALUES(10002, 'James', 'New York',CURRENT_DATE); 16 | INSERT INTO PERSON (ID, NAME, LOCATION, BIRTH_DATE ) 17 | VALUES(10003, 'Pieter', 'Amsterdam',CURRENT_DATE); 18 | 19 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/04-spring-jdbc-to-jpa/src/test/java/com/in28minutes/database/databasedemo/SpringJdbcDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.database.databasedemo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | // replaced @RunWith with @ExtendWith 9 | // replaced SpringRunner.class with SpringExtension.class 10 | @ExtendWith(SpringExtension.class) 11 | @SpringBootTest 12 | public class SpringJdbcDemoApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/COURSE UPDATE - H2 Database URL.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/COURSE UPDATE - H2 Database URL.docx -------------------------------------------------------------------------------- /S10 - Level 6 - Spring JDBC to JPA/Updates to Step 03 and Step 04.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S10 - Level 6 - Spring JDBC to JPA/Updates to Step 03 and Step 04.docx -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step02.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 67 | } 68 | 69 | } 70 | ``` 71 | ### \src\main\webapp\WEB-INF\views\login.jsp 72 | ``` 73 | 74 | 75 | Yahoo!! 76 | 77 | 78 | My First JSP!!! 79 | 80 | 81 | ``` 82 | ### \src\main\webapp\WEB-INF\web.xml 83 | ``` 84 | 85 | 88 | 89 | To do List 90 | 91 | 92 | login.do 93 | 94 | 95 | 96 | ``` 97 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step03.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.setAttribute("name", request.getParameter("name")); 67 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 68 | } 69 | 70 | } 71 | ``` 72 | ### \src\main\webapp\WEB-INF\views\login.jsp 73 | ``` 74 | 75 | 76 | Yahoo!! 77 | 78 | 79 | My First JSP!!! My name is ${name} 80 | 81 | 82 | ``` 83 | ### \src\main\webapp\WEB-INF\web.xml 84 | ``` 85 | 86 | 89 | 90 | To do List 91 | 92 | 93 | login.do 94 | 95 | 96 | 97 | ``` 98 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step04.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | @WebServlet(urlPatterns = "/login.do") 61 | public class LoginServlet extends HttpServlet { 62 | 63 | @Override 64 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 65 | throws IOException, ServletException { 66 | request.setAttribute("name", request.getParameter("name")); 67 | request.setAttribute("password", request.getParameter("password")); 68 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 69 | } 70 | 71 | } 72 | ``` 73 | ### \src\main\webapp\WEB-INF\views\login.jsp 74 | ``` 75 | 76 | 77 | Yahoo!! 78 | 79 | 80 | My First JSP!!! My name is ${name} and password is ${password} 81 | 82 | 83 | ``` 84 | ### \src\main\webapp\WEB-INF\web.xml 85 | ``` 86 | 87 | 90 | 91 | To do List 92 | 93 | 94 | login.do 95 | 96 | 97 | 98 | ``` 99 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step05.md: -------------------------------------------------------------------------------- 1 | ### \pom.xml 2 | ``` 3 | 5 | 4.0.0 6 | com.in28minutes 7 | in28Minutes-first-webapp 8 | 0.0.1-SNAPSHOT 9 | war 10 | 11 | 12 | 13 | javax 14 | javaee-web-api 15 | 6.0 16 | provided 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 3.2 27 | 28 | true 29 | 1.8 30 | 1.8 31 | true 32 | 33 | 34 | 35 | org.apache.tomcat.maven 36 | tomcat7-maven-plugin 37 | 2.2 38 | 39 | / 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | ``` 48 | ### \src\main\java\webapp\LoginServlet.java 49 | ``` 50 | package webapp; 51 | 52 | import java.io.IOException; 53 | 54 | import javax.servlet.ServletException; 55 | import javax.servlet.annotation.WebServlet; 56 | import javax.servlet.http.HttpServlet; 57 | import javax.servlet.http.HttpServletRequest; 58 | import javax.servlet.http.HttpServletResponse; 59 | 60 | 61 | @WebServlet(urlPatterns = "/login.do") 62 | public class LoginServlet extends HttpServlet { 63 | 64 | 65 | @Override 66 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 67 | throws IOException, ServletException { 68 | request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request, response); 69 | } 70 | 71 | } 72 | ``` 73 | ### \\src\main\webapp\WEB-INF\views\login.jsp 74 | ``` 75 | 76 | 77 | Yahoo!! 78 | 79 | 80 |
81 | Name : 82 |
83 | 84 | 85 | ``` 86 | ### \src\main\webapp\WEB-INF\views\welcome.jsp 87 | ``` 88 | 89 | 90 | Yahoo!! 91 | 92 | 93 | Welcome ${name} 94 | 95 | 96 | ``` 97 | ### \src\main\webapp\WEB-INF\web.xml 98 | ``` 99 | 100 | 103 | 104 | To do List 105 | 106 | 107 | login.do 108 | 109 | 110 | 111 | ``` 112 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step07.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step07.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step11.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step11.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step12.md: -------------------------------------------------------------------------------- 1 | #First Spring MVC Controller 2 | - @RequestMapping(value = "/login", method = RequestMethod.GET) 3 | - http://localhost:8080/spring-mvc/login 4 | - web.xml - /spring-mvc/* 5 | - Why @ResponseBody? 6 | - Important of RequestMapping method 7 | - Can I have multiple urls rendered from Same Controller? 8 | 9 | #Snippets 10 | ``` 11 | package com.in28minutes.springmvc; 12 | 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | @Controller 18 | public class LoginController { 19 | 20 | @RequestMapping(value = "/login") 21 | @ResponseBody 22 | public String sayHello() { 23 | return "Hello World dummy"; 24 | } 25 | } 26 | 27 | ``` 28 | 29 | ## Files List 30 | NOT AVAILABLE 31 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step13.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step13.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step15.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step15.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step16.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step16.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/Step17.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Spring-Framework-Master-Class-Java-Spring-the-Modern-Way/988fd8f802749001404483d418e6487e4b52c5a7/S11 - Web App with Spring MVC/02-basic-web-application/Step17.zip -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.in28minutes 5 | in28Minutes-springmvc 6 | 0.0.1-SNAPSHOT 7 | war 8 | 9 | 10 | 11 | javax 12 | javaee-web-api 13 | 8.0.1 14 | provided 15 | 16 | 17 | 18 | org.springframework 19 | spring-webmvc 20 | 6.0.10 21 | 22 | 23 | 24 | log4j 25 | log4j 26 | 1.2.17 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-compiler-plugin 36 | 3.2 37 | 38 | true 39 | 17 40 | 17 41 | true 42 | 43 | 44 | 45 | org.apache.tomcat.maven 46 | tomcat7-maven-plugin 47 | 2.2 48 | 49 | / 50 | true 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/java/com/in28minutes/login/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.login; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.ModelMap; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | @Controller 11 | public class LoginController { 12 | 13 | @Autowired 14 | private LoginService loginService; 15 | 16 | @RequestMapping(value = "/login", method = RequestMethod.GET) 17 | public String showLoginPage() { 18 | return "login"; 19 | } 20 | 21 | @RequestMapping(value = "/login", method = RequestMethod.POST) 22 | public String handleUserLogin(ModelMap model, @RequestParam String name, 23 | @RequestParam String password) { 24 | 25 | if (!loginService.validateUser(name, password)) { 26 | model.put("errorMessage", "Invalid Credentials"); 27 | return "login"; 28 | } 29 | 30 | model.put("name", name); 31 | return "welcome"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/java/com/in28minutes/login/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.in28minutes.login; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class LoginService { 7 | public boolean validateUser(String user, String password) { 8 | return user.equalsIgnoreCase("in28Minutes") && password.equals("dummy"); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=TRACE, Appender1, Appender2 2 | 3 | log4j.appender.Appender1=org.apache.log4j.ConsoleAppender 4 | log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n 6 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/webapp/WEB-INF/todo-servlet.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | /WEB-INF/views/ 17 | 18 | 19 | .jsp 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/webapp/WEB-INF/views/login.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yahoo!! 4 | 5 | 6 |

${errorMessage}

7 |
8 | Name : Password : 9 |
10 | 11 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/webapp/WEB-INF/views/welcome.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yahoo!! 4 | 5 | 6 | Welcome ${name}. You are now authenticated. 7 | 8 | -------------------------------------------------------------------------------- /S11 - Web App with Spring MVC/02-basic-web-application/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | To do List 6 | 7 | 8 | dispatcher 9 | 10 | org.springframework.web.servlet.DispatcherServlet 11 | 12 | 13 | contextConfigLocation 14 | /WEB-INF/todo-servlet.xml 15 | 16 | 1 17 | 18 | 19 | 20 | dispatcher 21 | / 22 | 23 | --------------------------------------------------------------------------------