├── README.md ├── examples ├── .gitignore ├── core │ ├── .gitignore │ ├── 01_hello-world_module │ │ ├── 01-hello-world_annotation │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ ├── bean │ │ │ │ ├── GreetingService.java │ │ │ │ └── impl │ │ │ │ │ └── GreetingServiceImpl.java │ │ │ │ └── service │ │ │ │ └── GreetingManager.java │ │ ├── 01-hello-world_javaconfig │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ ├── bean │ │ │ │ ├── GreetingService.java │ │ │ │ └── impl │ │ │ │ │ └── GreetingServiceImpl.java │ │ │ │ ├── config │ │ │ │ └── AppConfig.java │ │ │ │ └── service │ │ │ │ └── GreetingManager.java │ │ ├── 01-hello-world_xml │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ ├── GreetingService.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── GreetingServiceImpl.java │ │ │ │ │ └── service │ │ │ │ │ └── GreetingManager.java │ │ │ │ └── resources │ │ │ │ └── application-context.xml │ │ └── pom.xml │ ├── 02_bean-scope_module │ │ ├── 02_bean-scope-prototype_annotation │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ └── bean │ │ │ │ └── MyBean.java │ │ ├── 02_bean-scope-prototype_javaconfig │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ ├── bean │ │ │ │ └── MyBean.java │ │ │ │ └── config │ │ │ │ └── AppConfig.java │ │ ├── 02_bean-scope-prototype_xml │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ └── MyBean.java │ │ │ │ └── resources │ │ │ │ └── application-context.xml │ │ ├── 02_bean-scope-singleton_annotation │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ └── bean │ │ │ │ └── MyBean.java │ │ ├── 02_bean-scope-singleton_javaconfig │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── altafjava │ │ │ │ ├── App.java │ │ │ │ ├── bean │ │ │ │ └── MyBean.java │ │ │ │ └── config │ │ │ │ └── AppConfig.java │ │ ├── 02_bean-scope-singleton_xml │ │ │ ├── .gitignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ └── MyBean.java │ │ │ │ └── resources │ │ │ │ └── application-context.xml │ │ └── pom.xml │ ├── 03_dependency-injection_module │ │ ├── 03_constructor-injection_module │ │ │ ├── 03_ci-collection-injection-list_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Team.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-collection-injection-list_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Team.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-collection-injection-map_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── University.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-collection-injection-map_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Country.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-collection-injection-props_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Scientist.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-collection-injection-props_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Continent.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-collection-injection-set_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Team.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-collection-injection-set_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Team.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-object-injection_annotation │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ ├── Car.java │ │ │ │ │ └── Engine.java │ │ │ ├── 03_ci-object-injection_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ ├── Car.java │ │ │ │ │ └── Engine.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-object-injection_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ ├── Car.java │ │ │ │ │ │ └── Engine.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-primitive-string-injection_annotation │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ └── Employee.java │ │ │ ├── 03_ci-primitive-string-injection_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Employee.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_ci-primitive-string-injection_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Employee.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-type-ambiguity-solution-index │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Customer.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-type-ambiguity-solution-name │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Customer.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-type-ambiguity-solution-type │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Customer.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_ci-type-ambiguity │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Customer.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ └── pom.xml │ │ ├── 03_field-injection_module │ │ │ ├── 03_fi-object-injection_annotation │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ ├── ATM.java │ │ │ │ │ └── Printer.java │ │ │ └── pom.xml │ │ ├── 03_setter-constructor-overriding │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ └── Company.java │ │ │ │ └── resources │ │ │ │ └── application-context.xml │ │ ├── 03_setter-injection_module │ │ │ ├── 03_si-collection-injection-list_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Team.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-collection-injection-list_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Team.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_si-collection-injection-map_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── University.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-collection-injection-map_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Country.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_si-collection-injection-props_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Scientist.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-collection-injection-props_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Continent.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_si-collection-injection-set_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Team.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-collection-injection-set_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Team.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_si-object-injection_annotation │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ ├── Car.java │ │ │ │ │ └── Engine.java │ │ │ ├── 03_si-object-injection_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ ├── Car.java │ │ │ │ │ └── Engine.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-object-injection_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ ├── Car.java │ │ │ │ │ │ └── Engine.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ ├── 03_si-primitive-string-injection_annotation │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ └── bean │ │ │ │ │ └── Employee.java │ │ │ ├── 03_si-primitive-string-injection_javaconfig │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── altafjava │ │ │ │ │ ├── App.java │ │ │ │ │ ├── bean │ │ │ │ │ └── Employee.java │ │ │ │ │ └── config │ │ │ │ │ └── AppConfig.java │ │ │ ├── 03_si-primitive-string-injection_xml │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── altafjava │ │ │ │ │ │ ├── App.java │ │ │ │ │ │ └── bean │ │ │ │ │ │ └── Employee.java │ │ │ │ │ └── resources │ │ │ │ │ └── application-context.xml │ │ │ └── pom.xml │ │ └── pom.xml │ └── pom.xml └── pom.xml └── images ├── core ├── container-configuration-metadata.png ├── cross-cutting-concerns.png └── spring-framework-runtime.png └── spring-logo.png /examples/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 01_hello-world_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 01-hello-world_annotation 12 | 0.0.1-SNAPSHOT 13 | 01-hello-world_annotation 14 | http://maven.apache.org 15 | 16 | UTF-8 17 | 18 | 19 | 20 | junit 21 | junit 22 | 3.8.1 23 | test 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.service.GreetingManager; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | GreetingManager greetingManager = applicationContext.getBean(GreetingManager.class); 13 | greetingManager.sayGreet(); 14 | } 15 | } -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/src/main/java/com/altafjava/bean/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public interface GreetingService { 4 | String greet(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/src/main/java/com/altafjava/bean/impl/GreetingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean.impl; 2 | 3 | import org.springframework.stereotype.Component; 4 | import com.altafjava.bean.GreetingService; 5 | 6 | @Component 7 | public class GreetingServiceImpl implements GreetingService { 8 | 9 | @Override 10 | public String greet() { 11 | return "Hello World Annotation: Welcome to Spring Framework"; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_annotation/src/main/java/com/altafjava/service/GreetingManager.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import com.altafjava.bean.GreetingService; 6 | 7 | @Component 8 | public class GreetingManager { 9 | 10 | private GreetingService greetingService; 11 | 12 | @Autowired 13 | public void setGreetingService(GreetingService greetingService) { 14 | this.greetingService = greetingService; 15 | } 16 | 17 | public void sayGreet() { 18 | System.out.println(greetingService.greet()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 01_hello-world_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 01-hello-world_javaconfig 12 | 0.0.1-SNAPSHOT 13 | 01-hello-world_javaconfig 14 | http://maven.apache.org 15 | 16 | UTF-8 17 | 18 | 19 | 20 | junit 21 | junit 22 | 3.8.1 23 | test 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.config.AppConfig; 6 | import com.altafjava.service.GreetingManager; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | GreetingManager greetingManager = applicationContext.getBean(GreetingManager.class); 12 | greetingManager.sayGreet(); 13 | } 14 | } -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/src/main/java/com/altafjava/bean/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public interface GreetingService { 4 | String greet(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/src/main/java/com/altafjava/bean/impl/GreetingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean.impl; 2 | 3 | import com.altafjava.bean.GreetingService; 4 | 5 | public class GreetingServiceImpl implements GreetingService { 6 | 7 | @Override 8 | public String greet() { 9 | return "Hello World JavaConfig: Welcome to Spring Framework"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import com.altafjava.bean.GreetingService; 6 | import com.altafjava.bean.impl.GreetingServiceImpl; 7 | import com.altafjava.service.GreetingManager; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean(name = "greetingService") 13 | public GreetingService buildGreetingServiceBean() { 14 | return new GreetingServiceImpl(); 15 | } 16 | 17 | @Bean 18 | public GreetingManager buildGreetingManagerBean(GreetingService greetingService) { 19 | GreetingManager greetingManager = new GreetingManager(); 20 | greetingManager.setGreetingService(greetingService); 21 | return greetingManager; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_javaconfig/src/main/java/com/altafjava/service/GreetingManager.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.service; 2 | 3 | import com.altafjava.bean.GreetingService; 4 | 5 | public class GreetingManager { 6 | 7 | private GreetingService greetingService; 8 | 9 | public void setGreetingService(GreetingService greetingService) { 10 | this.greetingService = greetingService; 11 | } 12 | 13 | public void sayGreet() { 14 | System.out.println(greetingService.greet()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 01-hello-world_xml 6 | 01-hello-world_xml 7 | http://maven.apache.org 8 | 9 | 10 | com.altafjava 11 | 01_hello-world_module 12 | 0.0.1-SNAPSHOT 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.beans.factory.BeanFactory; 4 | import org.springframework.beans.factory.xml.XmlBeanFactory; 5 | import org.springframework.core.io.ClassPathResource; 6 | import com.altafjava.service.GreetingManager; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("application-context.xml")); 11 | GreetingManager greetingManager = beanFactory.getBean(GreetingManager.class); 12 | greetingManager.sayGreet(); 13 | } 14 | } -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/src/main/java/com/altafjava/bean/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public interface GreetingService { 4 | String greet(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/src/main/java/com/altafjava/bean/impl/GreetingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean.impl; 2 | 3 | import com.altafjava.bean.GreetingService; 4 | 5 | public class GreetingServiceImpl implements GreetingService { 6 | 7 | @Override 8 | public String greet() { 9 | return "Hello World XML: Welcome to Spring Framework"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/src/main/java/com/altafjava/service/GreetingManager.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.service; 2 | 3 | import com.altafjava.bean.GreetingService; 4 | 5 | public class GreetingManager { 6 | 7 | private GreetingService greetingService; 8 | 9 | public void setGreetingService(GreetingService greetingService) { 10 | this.greetingService = greetingService; 11 | } 12 | 13 | public void sayGreet() { 14 | System.out.println(greetingService.greet()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/01-hello-world_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/core/01_hello-world_module/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 01_hello-world_module 5 | pom 6 | 7 | com.altafjava 8 | core 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 01-hello-world_xml 13 | 01-hello-world_annotation 14 | 01-hello-world_javaconfig 15 | 16 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_annotation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 02_bean-scope_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 02_bean-scope-prototype_annotation 11 | 02_bean-scope-prototype_annotation 12 | http://maven.apache.org 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.MyBean; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | MyBean myBean1 = applicationContext.getBean(MyBean.class); 13 | MyBean myBean2 = (MyBean) applicationContext.getBean("myBean"); 14 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 15 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 16 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_annotation/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.context.annotation.Scope; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Scope(scopeName = "prototype") 8 | public class MyBean { 9 | 10 | public MyBean() { 11 | System.out.println("MyBean Constructor executed"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_javaconfig/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 02_bean-scope_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 02_bean-scope-prototype_javaconfig 11 | 02_bean-scope-prototype_javaconfig 12 | http://maven.apache.org 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.MyBean; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | MyBean myBean1 = applicationContext.getBean(MyBean.class); 12 | MyBean myBean2 = (MyBean) applicationContext.getBean("myBean"); 13 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 14 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 15 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_javaconfig/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class MyBean { 4 | 5 | public MyBean() { 6 | System.out.println("MyBean Constructor executed"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Scope; 6 | import com.altafjava.bean.MyBean; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | @Scope(scopeName = "prototype") 13 | public MyBean myBean() { 14 | return new MyBean(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_xml/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 02_bean-scope_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 02_bean-scope-prototype_xml 11 | 02_bean-scope-prototype_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.beans.factory.BeanFactory; 4 | import org.springframework.beans.factory.xml.XmlBeanFactory; 5 | import org.springframework.core.io.ClassPathResource; 6 | import com.altafjava.bean.MyBean; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("application-context.xml")); 11 | MyBean myBean1 = beanFactory.getBean(MyBean.class); 12 | MyBean myBean2 = (MyBean) beanFactory.getBean("myBean"); 13 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 14 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 15 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_xml/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class MyBean { 4 | 5 | public MyBean() { 6 | System.out.println("MyBean Constructor executed"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-prototype_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_annotation/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 02_bean-scope-singleton_annotation 6 | 02_bean-scope-singleton_annotation 7 | http://maven.apache.org 8 | 9 | 10 | com.altafjava 11 | 02_bean-scope_module 12 | 0.0.1-SNAPSHOT 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.MyBean; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | MyBean myBean1 = applicationContext.getBean(MyBean.class); 13 | MyBean myBean2 = (MyBean) applicationContext.getBean("myBean"); 14 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 15 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 16 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_annotation/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.context.annotation.Scope; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Scope(value = "singleton") /* Here @Scope annotation is not required because by default bean scope is singleton */ 8 | public class MyBean { 9 | 10 | public MyBean() { 11 | System.out.println("Constructor executed only once but getBean() method invoked 2 times"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_javaconfig/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 02_bean-scope-singleton_javaconfig 6 | 02_bean-scope-singleton_javaconfig 7 | http://maven.apache.org 8 | 9 | 10 | com.altafjava 11 | 02_bean-scope_module 12 | 0.0.1-SNAPSHOT 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.MyBean; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | MyBean myBean1 = applicationContext.getBean(MyBean.class); 12 | MyBean myBean2 = (MyBean) applicationContext.getBean("createMyBean"); 13 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 14 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 15 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_javaconfig/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class MyBean { 4 | 5 | public MyBean() { 6 | System.out.println("Constructor executed only once but getBean() method invoked 2 times"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Scope; 6 | import com.altafjava.bean.MyBean; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | @Scope("singleton") /* Here @Scope annotation is not required because by default bean scope is singleton */ 13 | public MyBean createMyBean() { 14 | return new MyBean(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_xml/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | 4 | !.mvn/wrapper/maven-wrapper.jar 5 | !**/src/main/**/target/ 6 | !**/src/test/**/target/ 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | 23 | ### NetBeans ### 24 | /nbproject/private/ 25 | /nbbuild/ 26 | /dist/ 27 | /nbdist/ 28 | /.nb-gradle/ 29 | build/ 30 | !**/src/main/**/build/ 31 | !**/src/test/**/build/ 32 | 33 | ### VS Code ### 34 | .vscode/ 35 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 02_bean-scope-singleton_xml 6 | 02_bean-scope-singleton_xml 7 | http://maven.apache.org 8 | 9 | 10 | com.altafjava 11 | 02_bean-scope_module 12 | 0.0.1-SNAPSHOT 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.beans.factory.BeanFactory; 4 | import org.springframework.beans.factory.xml.XmlBeanFactory; 5 | import org.springframework.core.io.ClassPathResource; 6 | import com.altafjava.bean.MyBean; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("application-context.xml")); 11 | MyBean myBean1 = beanFactory.getBean(MyBean.class); 12 | MyBean myBean2 = (MyBean) beanFactory.getBean("myBean"); 13 | System.out.println("Bean1 Hashcode: " + myBean1.hashCode()); 14 | System.out.println("Bean2 Hashcode: " + myBean2.hashCode()); 15 | System.out.println("are both beans same: " + (myBean1 == myBean2)); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_xml/src/main/java/com/altafjava/bean/MyBean.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class MyBean { 4 | 5 | public MyBean() { 6 | System.out.println("Constructor executed only once but getBean() method invoked 2 times"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/02_bean-scope-singleton_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/core/02_bean-scope_module/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.altafjava 6 | core 7 | 0.0.1-SNAPSHOT 8 | 9 | 02_bean-scope_module 10 | pom 11 | 12 | 13 | 02_bean-scope-singleton_xml 14 | 02_bean-scope-singleton_annotation 15 | 02_bean-scope-singleton_javaconfig 16 | 02_bean-scope-prototype_xml 17 | 02_bean-scope-prototype_annotation 18 | 02_bean-scope-prototype_javaconfig 19 | 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-list_javaconfig 11 | 03_ci-collection-injection-list_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Team; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Team team = applicationContext.getBean(Team.class); 13 | System.out.println(team); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_javaconfig/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.List; 4 | 5 | public class Team { 6 | private String teamName; 7 | private List players; 8 | 9 | public Team(String teamName, List players) { 10 | this.teamName = teamName; 11 | this.players = players; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.Team; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public Team team() { 14 | List players = new ArrayList<>(); 15 | players.add("Ronaldo"); 16 | players.add("Messi"); 17 | players.add("Salah"); 18 | String teamName = "Football Players"; 19 | return new Team(teamName, players); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-list_xml 11 | 03_ci-collection-injection-list_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Team; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Team team = applicationContext.getBean(Team.class); 12 | System.out.println(team); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_xml/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.List; 4 | 5 | public class Team { 6 | private String teamName; 7 | private List players; 8 | 9 | public Team(String teamName, List players) { 10 | this.teamName = teamName; 11 | this.players = players; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-list_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Iron Mans 10 | Captain America 11 | Thor 12 | Hulk 13 | Black Widow 14 | Hawkeye 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-map_javaconfig 11 | 03_ci-collection-injection-map_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.University; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | University university = applicationContext.getBean(University.class); 12 | System.out.println(university); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_javaconfig/src/main/java/com/altafjava/bean/University.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Map; 4 | 5 | public class University { 6 | private String name; 7 | private Map colleges; 8 | 9 | public University(String name, Map colleges) { 10 | this.name = name; 11 | this.colleges = colleges; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "University [name=" + name + ", colleges=" + colleges + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.University; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public University university() { 14 | Map colleges = new LinkedHashMap<>(); 15 | colleges.put("8P", "AAR Mahaveer Engineering College"); 16 | colleges.put("EK", "Abdul Kalam Institute of Technological Sciences"); 17 | colleges.put("AG", "ACE Engineering College"); 18 | University university = new University("JNTUH", colleges); 19 | return university; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-map_xml 11 | 03_ci-collection-injection-map_xml 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Country; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Country country = applicationContext.getBean(Country.class); 11 | System.out.println(country); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_xml/src/main/java/com/altafjava/bean/Country.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Map; 4 | 5 | public class Country { 6 | private String name; 7 | private Map cityWithZip; 8 | 9 | public Country(String name, Map cityWithZip) { 10 | this.name = name; 11 | this.cityWithZip = cityWithZip; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Country [name=" + name + ", cityWithZip=" + cityWithZip + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-map_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 03_ci-collection-injection-props_javaconfig 12 | 03_ci-collection-injection-props_javaconfig 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Scientist; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Scientist scientist = applicationContext.getBean(Scientist.class); 13 | System.out.println(scientist); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_javaconfig/src/main/java/com/altafjava/bean/Scientist.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Properties; 4 | 5 | public class Scientist { 6 | private Properties scientists; 7 | 8 | public Scientist(Properties scientists) { 9 | this.scientists = scientists; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Scientist [scientists=" + scientists + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.Properties; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import com.altafjava.bean.Scientist; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public Scientist teacher() { 13 | Properties scientists = new Properties(); 14 | scientists.setProperty("mathematician", "Al-Battani"); 15 | scientists.setProperty("medicine", "Ibn Sina"); 16 | scientists.setProperty("algoritm", "Muhammad ibn Musa Al-Khwarizmi"); 17 | scientists.setProperty("astronomer", "Omar Khayyam"); 18 | scientists.setProperty("chemistry", "Jabir Ibn Haiyan"); 19 | Scientist scientist = new Scientist(scientists); 20 | return scientist; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 03_ci-collection-injection-props_xml 12 | 03_ci-collection-injection-props_xml 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Continent; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Continent continent = applicationContext.getBean(Continent.class); 12 | System.out.println(continent); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_xml/src/main/java/com/altafjava/bean/Continent.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Properties; 4 | 5 | public class Continent { 6 | private Properties continents; 7 | 8 | public Continent(Properties continents) { 9 | this.continents = continents; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Continent [continents=" + continents + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-props_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | Antarctica 9 | Africa 10 | Asia 11 | Australia 12 | Europe 13 | North America 14 | South America 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-set_javaconfig 11 | 03_ci-collection-injection-set_javaconfig 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Team; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Team team = applicationContext.getBean(Team.class); 13 | System.out.println(team); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_javaconfig/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Set; 4 | 5 | public class Team { 6 | private String teamName; 7 | private Set players; 8 | 9 | public Team(String teamName, Set players) { 10 | this.teamName = teamName; 11 | this.players = players; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.Team; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public Team team() { 14 | Set players = new HashSet<>(); 15 | players.add("Ronaldo"); 16 | players.add("Messi"); 17 | players.add("Salah"); 18 | players.add("Messi"); 19 | return new Team("Footbal Players", players); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-collection-injection-set_xml 11 | 03_ci-collection-injection-set_xml 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Team; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Team team = applicationContext.getBean(Team.class); 12 | System.out.println(team); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_xml/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Set; 4 | 5 | public class Team { 6 | private String teamName; 7 | private Set players; 8 | 9 | public Team(String teamName, Set players) { 10 | this.teamName = teamName; 11 | this.players = players; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-collection-injection-set_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Iron Man 10 | Captain America 11 | Thor 12 | Hulk 13 | Thor 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-object-injection_annotation 11 | 03_ci-object-injection_annotation 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.Car; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | Car car = applicationContext.getBean(Car.class); 13 | System.out.println(car); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_annotation/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class Car { 9 | private String brand; 10 | private String model; 11 | private Engine engine; 12 | 13 | public Car(@Value("Maruti Suzuki") String brand, @Value(value = "Dzire") String model, @Autowired Engine engine) { 14 | this.brand = brand; 15 | this.model = model; 16 | this.engine = engine; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_annotation/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class Engine { 7 | private int engineId; 8 | private String engineName; 9 | 10 | public Engine(int engineId, String engineName) { 11 | this.engineId = engineId; 12 | this.engineName = engineName; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-object-injection_javaconfig 11 | 03_ci-object-injection_javaconfig 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Car; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | Car car = applicationContext.getBean(Car.class); 12 | System.out.println(car); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_javaconfig/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class Car { 7 | private String brand; 8 | private String model; 9 | private Engine engine; 10 | 11 | public Car(String brand, String model, Engine engine) { 12 | this.brand = brand; 13 | this.model = model; 14 | this.engine = engine; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_javaconfig/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Engine { 8 | private int engineId; 9 | private String engineName; 10 | 11 | public Engine(@Value(value = "234") int engineId, @Value("Toyota") String engineName) { 12 | this.engineId = engineId; 13 | this.engineName = engineName; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import com.altafjava.bean.Car; 6 | import com.altafjava.bean.Engine; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public Engine engine() { 13 | return new Engine(456, "Cummins"); 14 | } 15 | 16 | @Bean 17 | public Car car(Engine engine) { 18 | return new Car("Honda", "City", engine); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-object-injection_xml 11 | 03_ci-object-injection_xml 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Car; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Car car = applicationContext.getBean(Car.class); 11 | System.out.println(car); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_xml/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Car { 4 | private String brand; 5 | private String model; 6 | private Engine engine; 7 | 8 | public Car(String brand, String model, Engine engine) { 9 | this.brand = brand; 10 | this.model = model; 11 | this.engine = engine; 12 | System.out.println("=== Car constructor called ==="); 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_xml/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Engine { 4 | private int engineId; 5 | private String engineName; 6 | 7 | public Engine(int engineId, String engineName) { 8 | this.engineId = engineId; 9 | this.engineName = engineName; 10 | System.out.println("---Engine constructor called---"); 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-object-injection_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-primitive-string-injection_annotation 11 | 03_ci-primitive-string-injection_annotation 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.Employee; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | Employee employee = applicationContext.getBean(Employee.class); 13 | System.out.println(employee); 14 | } 15 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_annotation/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Employee { 8 | private int id; 9 | private String name; 10 | private String address; 11 | private float salary; 12 | 13 | public Employee(@Value("123") int id, @Value("Sam Altaf") String name, @Value(value = "Tokyo") String address, @Value(value = "9876.54") float salary) { 14 | this.id = id; 15 | this.name = name; 16 | this.address = address; 17 | this.salary = salary; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-primitive-string-injection_javaconfig 11 | 03_ci-primitive-string-injection_javaconfig 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Employee; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | Employee employee = applicationContext.getBean(Employee.class); 12 | System.out.println(employee); 13 | } 14 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_javaconfig/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Employee { 4 | private int id; 5 | private String name; 6 | private String address; 7 | private float salary; 8 | 9 | public Employee(int id, String name, String address, float salary) { 10 | this.id = id; 11 | this.name = name; 12 | this.address = address; 13 | this.salary = salary; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import com.altafjava.bean.Employee; 6 | 7 | @Configuration 8 | public class AppConfig { 9 | 10 | @Bean(name = "employee") 11 | public Employee createEmployee() { 12 | return new Employee(123, "Kais Saied", "Tunisia", 444849.33f); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-primitive-string-injection_xml 11 | 03_ci-primitive-string-injection_xml 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Employee; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Employee employee = (Employee) applicationContext.getBean("employee"); 11 | System.out.println(employee); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_xml/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Employee { 4 | private int id; 5 | private String name; 6 | private String address; 7 | private float salary; 8 | 9 | public Employee(int id, String name, String address, float salary) { 10 | this.id = id; 11 | this.name = name; 12 | this.address = address; 13 | this.salary = salary; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-primitive-string-injection_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-index/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_constructor-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-type-ambiguity-solution-index 11 | 03_ci-type-ambiguity-solution-index 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-index/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Customer; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Customer customer = (Customer) applicationContext.getBean("customer"); 11 | System.out.println(customer); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-index/src/main/java/com/altafjava/bean/Customer.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Customer { 4 | private String name; 5 | private int age; 6 | 7 | public Customer(String name, int age) { 8 | this.name = name; 9 | this.age = age; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Customer [name=" + name + ", age=" + age + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-index/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-name/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_constructor-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-type-ambiguity-solution-name 11 | 03_ci-type-ambiguity-solution-name 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-name/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Customer; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Customer customer = (Customer) applicationContext.getBean("customer"); 11 | System.out.println(customer); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-name/src/main/java/com/altafjava/bean/Customer.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Customer { 4 | private String name; 5 | private int age; 6 | 7 | public Customer(int age, String name) { 8 | this.name = name; 9 | this.age = age; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Customer [name=" + name + ", age=" + age + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-name/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-type/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_constructor-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-type-ambiguity-solution-type 11 | 03_ci-type-ambiguity-solution-type 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-type/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Customer; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Customer customer = (Customer) applicationContext.getBean("customer"); 11 | System.out.println(customer); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-type/src/main/java/com/altafjava/bean/Customer.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Customer { 4 | private String name; 5 | private String address; 6 | private int age; 7 | 8 | public Customer(String name, String address) { 9 | this.name = name; 10 | this.address = address; 11 | } 12 | 13 | public Customer(String name, int age) { 14 | this.name = name; 15 | this.age = age; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "Customer [name=" + name + ", address=" + address + ", age=" + age + "]"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity-solution-type/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_constructor-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_ci-type-ambiguity 11 | 03_ci-type-ambiguity 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Customer; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Customer customer = (Customer) applicationContext.getBean("customer"); 11 | System.out.println(customer); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity/src/main/java/com/altafjava/bean/Customer.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Customer { 4 | private String name; 5 | private String address; 6 | private int age; 7 | 8 | public Customer(String name, String address) { 9 | this.name = name; 10 | this.address = address; 11 | } 12 | 13 | public Customer(String name, int age) { 14 | this.name = name; 15 | this.age = age; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "Customer [name=" + name + ", address=" + address + ", age=" + age + "]"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/03_ci-type-ambiguity/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_constructor-injection_module/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_dependency-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_constructor-injection_module 11 | pom 12 | 13 | 03_ci-primitive-string-injection_annotation 14 | 03_ci-primitive-string-injection_javaconfig 15 | 03_ci-primitive-string-injection_xml 16 | 03_ci-object-injection_annotation 17 | 03_ci-object-injection_javaconfig 18 | 03_ci-object-injection_xml 19 | 03_ci-collection-injection-list_xml 20 | 03_ci-collection-injection-list_javaconfig 21 | 03_ci-collection-injection-set_xml 22 | 03_ci-collection-injection-set_javaconfig 23 | 03_ci-collection-injection-map_xml 24 | 03_ci-collection-injection-map_javaconfig 25 | 03_ci-collection-injection-props_xml 26 | 03_ci-collection-injection-props_javaconfig 27 | 03_ci-type-ambiguity 28 | 03_ci-type-ambiguity-solution-type 29 | 03_ci-type-ambiguity-solution-index 30 | 03_ci-type-ambiguity-solution-name 31 | 32 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_field-injection_module/03_fi-object-injection_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_field-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_fi-object-injection_annotation 11 | 03_fi-object-injection_annotation 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_field-injection_module/03_fi-object-injection_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.ATM; 7 | import com.altafjava.bean.Printer; 8 | 9 | @ComponentScan 10 | public class App { 11 | public static void main(String[] args) { 12 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 13 | ATM atm = applicationContext.getBean(ATM.class); 14 | Printer printer = atm.getPrinter(); 15 | printer.printBalance(atm.getBankName(), 67839.93); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_field-injection_module/03_fi-object-injection_annotation/src/main/java/com/altafjava/bean/ATM.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class ATM { 9 | @Value("ICICI") 10 | private String bankName; 11 | @Autowired 12 | private Printer printer; 13 | 14 | public String getBankName() { 15 | return bankName; 16 | } 17 | 18 | public Printer getPrinter() { 19 | return printer; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_field-injection_module/03_fi-object-injection_annotation/src/main/java/com/altafjava/bean/Printer.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class Printer { 7 | 8 | public void printBalance(String bankName, double balance) { 9 | System.out.println("Total balance in " + bankName + " bank is: " + balance); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_field-injection_module/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.altafjava 6 | 03_dependency-injection_module 7 | 0.0.1-SNAPSHOT 8 | 9 | 03_field-injection_module 10 | pom 11 | 12 | 03_fi-object-injection_annotation 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-constructor-overriding/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_dependency-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_setter-constructor-overriding 11 | 03_setter-constructor-overriding 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-constructor-overriding/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Company; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Company company = applicationContext.getBean(Company.class); 12 | System.out.println(company); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-constructor-overriding/src/main/java/com/altafjava/bean/Company.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Company { 4 | private String name; 5 | 6 | public void setName(String name) { 7 | this.name = name; 8 | System.out.println("setter"); 9 | } 10 | 11 | public Company() { 12 | System.out.println("no arg constructor"); 13 | } 14 | 15 | public Company(String name) { 16 | this.name = name; 17 | System.out.println("1 arg constructor"); 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "Company [name=" + name + "]"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-constructor-overriding/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-collection-injection-list_javaconfig 11 | 03_si-collection-injection-list_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Team; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Team team = applicationContext.getBean(Team.class); 13 | System.out.println(team); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_javaconfig/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.List; 4 | 5 | public class Team { 6 | private String teamName; 7 | private List players; 8 | 9 | public void setTeamName(String teamName) { 10 | this.teamName = teamName; 11 | } 12 | 13 | public void setPlayers(List players) { 14 | this.players = players; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.Team; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public Team team() { 14 | Team team = new Team(); 15 | team.setTeamName("Football Players"); 16 | List players = new ArrayList<>(); 17 | players.add("Ronaldo"); 18 | players.add("Messi"); 19 | players.add("Salah"); 20 | team.setPlayers(players); 21 | return team; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-collection-injection-list_xml 11 | 03_si-collection-injection-list_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Team; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Team team = applicationContext.getBean(Team.class); 12 | System.out.println(team); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_xml/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.List; 4 | 5 | public class Team { 6 | private String teamName; 7 | private List players; 8 | 9 | public void setTeamName(String teamName) { 10 | this.teamName = teamName; 11 | } 12 | 13 | public void setPlayers(List players) { 14 | this.players = players; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-list_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Iron Man 10 | Captain America 11 | Thor 12 | Hulk 13 | Black Widow 14 | Hawkeye 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 03_si-collection-injection-map_javaconfig 12 | 0.0.1-SNAPSHOT 13 | 03_si-collection-injection-map_javaconfig 14 | http://maven.apache.org 15 | 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.University; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | University university = applicationContext.getBean(University.class); 12 | System.out.println(university); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_javaconfig/src/main/java/com/altafjava/bean/University.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Map; 4 | 5 | public class University { 6 | private String name; 7 | private Map colleges; 8 | 9 | public void setName(String name) { 10 | this.name = name; 11 | } 12 | 13 | public void setColleges(Map colleges) { 14 | this.colleges = colleges; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "University [name=" + name + ", colleges=" + colleges + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.University; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public University university() { 14 | University university = new University(); 15 | university.setName("JNTUH"); 16 | Map colleges = new LinkedHashMap<>(); 17 | colleges.put("8P", "AAR Mahaveer Engineering College"); 18 | colleges.put("EK", "Abdul Kalam Institute of Technological Sciences"); 19 | colleges.put("AG", "ACE Engineering College"); 20 | university.setColleges(colleges); 21 | return university; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-collection-injection-map_xml 11 | 03_si-collection-injection-map_xml 12 | 13 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Country; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Country country = applicationContext.getBean(Country.class); 11 | System.out.println(country); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_xml/src/main/java/com/altafjava/bean/Country.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Map; 4 | 5 | public class Country { 6 | private String name; 7 | private Map cityWithZip; 8 | 9 | public void setName(String name) { 10 | this.name = name; 11 | } 12 | 13 | public void setCityWithZip(Map cityWithZip) { 14 | this.cityWithZip = cityWithZip; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Country [name=" + name + ", cityWithZip=" + cityWithZip + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-map_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 03_si-collection-injection-props_javaconfig 12 | 03_si-collection-injection-props_javaconfig 13 | http://maven.apache.org 14 | 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Scientist; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Scientist scientist = applicationContext.getBean(Scientist.class); 13 | System.out.println(scientist); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_javaconfig/src/main/java/com/altafjava/bean/Scientist.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Properties; 4 | 5 | public class Scientist { 6 | private Properties scientists; 7 | 8 | public void setScientists(Properties scientists) { 9 | this.scientists = scientists; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Scientist [scientists=" + scientists + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.Properties; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import com.altafjava.bean.Scientist; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public Scientist teacher() { 13 | Scientist scientist = new Scientist(); 14 | Properties scientists = new Properties(); 15 | scientists.setProperty("mathematician", "Al-Battani"); 16 | scientists.setProperty("medicine", "Ibn Sina"); 17 | scientists.setProperty("algoritm", "Muhammad ibn Musa Al-Khwarizmi"); 18 | scientists.setProperty("astronomer", "Omar Khayyam"); 19 | scientists.setProperty("chemistry", "Jabir Ibn Haiyan"); 20 | scientist.setScientists(scientists); 21 | return scientist; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | com.altafjava 11 | 03_si-collection-injection-props_xml 12 | 03_si-collection-injection-props_xml 13 | http://maven.apache.org 14 | 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Continent; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Continent continent = applicationContext.getBean(Continent.class); 12 | System.out.println(continent); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_xml/src/main/java/com/altafjava/bean/Continent.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Properties; 4 | 5 | public class Continent { 6 | private Properties continents; 7 | 8 | public void setContinents(Properties continents) { 9 | this.continents = continents; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Continent [continents=" + continents + "]"; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-props_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | Antarctica 9 | Africa 10 | Asia 11 | Australia 12 | Europe 13 | North America 14 | South America 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-collection-injection-set_javaconfig 11 | 03_si-collection-injection-set_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Team; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 12 | Team team = applicationContext.getBean(Team.class); 13 | System.out.println(team); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_javaconfig/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Set; 4 | 5 | public class Team { 6 | private String teamName; 7 | private Set players; 8 | 9 | public void setTeamName(String teamName) { 10 | this.teamName = teamName; 11 | } 12 | 13 | public void setPlayers(Set players) { 14 | this.players = players; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import com.altafjava.bean.Team; 8 | 9 | @Configuration 10 | public class AppConfig { 11 | 12 | @Bean 13 | public Team team() { 14 | Team team = new Team(); 15 | team.setTeamName("Football Players"); 16 | Set players = new HashSet<>(); 17 | players.add("Ronaldo"); 18 | players.add("Messi"); 19 | players.add("Salah"); 20 | players.add("Messi"); 21 | team.setPlayers(players); 22 | return team; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-collection-injection-set_xml 11 | 03_si-collection-injection-set_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Team; 6 | 7 | public class App { 8 | 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 11 | Team team = applicationContext.getBean(Team.class); 12 | System.out.println(team); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_xml/src/main/java/com/altafjava/bean/Team.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import java.util.Set; 4 | 5 | public class Team { 6 | private String teamName; 7 | private Set players; 8 | 9 | public void setTeamName(String teamName) { 10 | this.teamName = teamName; 11 | } 12 | 13 | public void setPlayers(Set players) { 14 | this.players = players; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Team [teamName=" + teamName + ", players=" + players + "]"; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-collection-injection-set_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Iron Man 10 | Captain America 11 | Thor 12 | Hulk 13 | Thor 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-object-injection_annotation 11 | 03_si-object-injection_annotation 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.Car; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | Car car = applicationContext.getBean(Car.class); 13 | System.out.println(car); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_annotation/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class Car { 9 | private String brand; 10 | private String model; 11 | private Engine engine; 12 | 13 | @Value("Maruti Suzuki") 14 | public void setBrand(String brand) { 15 | this.brand = brand; 16 | } 17 | 18 | @Value(value = "Dzire") 19 | public void setModel(String model) { 20 | this.model = model; 21 | } 22 | 23 | @Autowired 24 | public void setEngine(Engine engine) { 25 | this.engine = engine; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_annotation/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Engine { 8 | @Value(value = "234") 9 | private int engineId; 10 | @Value("Toyota") 11 | private String engineName; 12 | 13 | public void setEngineId(int engineId) { 14 | this.engineId = engineId; 15 | } 16 | 17 | public void setEngineName(String engineName) { 18 | this.engineName = engineName; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-object-injection_javaconfig 11 | 03_si-object-injection_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Car; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | Car car = applicationContext.getBean(Car.class); 12 | System.out.println(car); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_javaconfig/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class Car { 9 | private String brand; 10 | private String model; 11 | private Engine engine; 12 | 13 | @Value("Maruti Suzuki") 14 | public void setBrand(String brand) { 15 | this.brand = brand; 16 | } 17 | 18 | @Value(value = "Dzire") 19 | public void setModel(String model) { 20 | this.model = model; 21 | } 22 | 23 | @Autowired 24 | public void setEngine(Engine engine) { 25 | this.engine = engine; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_javaconfig/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Engine { 8 | @Value(value = "234") 9 | private int engineId; 10 | @Value("Toyota") 11 | private String engineName; 12 | 13 | public void setEngineId(int engineId) { 14 | this.engineId = engineId; 15 | } 16 | 17 | public void setEngineName(String engineName) { 18 | this.engineName = engineName; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import com.altafjava.bean.Car; 6 | import com.altafjava.bean.Engine; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public Engine engine() { 13 | Engine engine = new Engine(); 14 | engine.setEngineId(456); 15 | engine.setEngineName("Cummins"); 16 | return engine; 17 | } 18 | 19 | @Bean 20 | public Car car(Engine engine) { 21 | Car car = new Car(); 22 | car.setBrand("Honda"); 23 | car.setModel("city"); 24 | car.setEngine(engine); 25 | return car; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-object-injection_xml 11 | 03_si-object-injection_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Car; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Car car = applicationContext.getBean(Car.class); 11 | System.out.println(car); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_xml/src/main/java/com/altafjava/bean/Car.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Car { 4 | private String brand; 5 | private String model; 6 | private Engine engine; 7 | 8 | public void setBrand(String brand) { 9 | this.brand = brand; 10 | } 11 | 12 | public void setModel(String model) { 13 | this.model = model; 14 | } 15 | 16 | public void setEngine(Engine engine) { 17 | this.engine = engine; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "Vehicle [brand=" + brand + ", model=" + model + ", engine=" + engine + "]"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_xml/src/main/java/com/altafjava/bean/Engine.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Engine { 4 | private int engineId; 5 | private String engineName; 6 | 7 | public void setEngineId(int engineId) { 8 | this.engineId = engineId; 9 | } 10 | 11 | public void setEngineName(String engineName) { 12 | this.engineName = engineName; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "Engine [engineId=" + engineId + ", engineName=" + engineName + "]"; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-object-injection_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-primitive-string-injection_annotation 11 | 03_si-primitive-string-injection_annotation 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_annotation/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import com.altafjava.bean.Employee; 7 | 8 | @ComponentScan 9 | public class App { 10 | public static void main(String[] args) { 11 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(App.class); 12 | Employee employee = applicationContext.getBean(Employee.class); 13 | System.out.println(employee); 14 | } 15 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_annotation/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Employee { 8 | private int id; 9 | private String name; 10 | private String address; 11 | private float salary; 12 | 13 | @Value("123") 14 | public void setId(int id) { 15 | this.id = id; 16 | } 17 | 18 | @Value("Sam Altaf") 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | @Value(value = "Tokyo") 24 | public void setAddress(String address) { 25 | this.address = address; 26 | } 27 | 28 | @Value(value = "9876.54") 29 | public void setSalary(float salary) { 30 | this.salary = salary; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-primitive-string-injection_javaconfig 11 | 03_si-primitive-string-injection_javaconfig 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_javaconfig/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import com.altafjava.bean.Employee; 6 | import com.altafjava.config.AppConfig; 7 | 8 | public class App { 9 | public static void main(String[] args) { 10 | ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 11 | Employee employee = applicationContext.getBean(Employee.class); 12 | System.out.println(employee); 13 | } 14 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_javaconfig/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Employee { 4 | private int id; 5 | private String name; 6 | private String address; 7 | private float salary; 8 | 9 | public void setId(int id) { 10 | this.id = id; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public void setSalary(float salary) { 22 | this.salary = salary; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_javaconfig/src/main/java/com/altafjava/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import com.altafjava.bean.Employee; 6 | 7 | @Configuration 8 | public class AppConfig { 9 | 10 | @Bean(name = "employee") 11 | public Employee createEmployee() { 12 | Employee employee = new Employee(); 13 | employee.setId(123); 14 | employee.setName("Sam Altaf"); 15 | employee.setAddress("Tunisia"); 16 | employee.setSalary(635474.74f); 17 | return employee; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.altafjava 7 | 03_setter-injection_module 8 | 0.0.1-SNAPSHOT 9 | 10 | 03_si-primitive-string-injection_xml 11 | 03_si-primitive-string-injection_xml 12 | http://maven.apache.org 13 | 14 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_xml/src/main/java/com/altafjava/App.java: -------------------------------------------------------------------------------- 1 | package com.altafjava; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import com.altafjava.bean.Employee; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml"); 10 | Employee employee = (Employee) applicationContext.getBean("employee"); 11 | System.out.println(employee); 12 | } 13 | } -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_xml/src/main/java/com/altafjava/bean/Employee.java: -------------------------------------------------------------------------------- 1 | package com.altafjava.bean; 2 | 3 | public class Employee { 4 | private int id; 5 | private String name; 6 | private String address; 7 | private float salary; 8 | 9 | public void setId(int id) { 10 | this.id = id; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public void setAddress(String address) { 18 | this.address = address; 19 | } 20 | 21 | public void setSalary(float salary) { 22 | this.salary = salary; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Employee [id=" + id + ", name=" + name + ", address=" + address + ", salary=" + salary + "]"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/03_si-primitive-string-injection_xml/src/main/resources/application-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/03_setter-injection_module/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.altafjava 6 | 03_dependency-injection_module 7 | 0.0.1-SNAPSHOT 8 | 9 | 03_setter-injection_module 10 | pom 11 | 12 | 03_si-primitive-string-injection_annotation 13 | 03_si-primitive-string-injection_javaconfig 14 | 03_si-primitive-string-injection_xml 15 | 03_si-object-injection_annotation 16 | 03_si-object-injection_javaconfig 17 | 03_si-object-injection_xml 18 | 03_si-collection-injection-list_xml 19 | 03_si-collection-injection-list_javaconfig 20 | 03_si-collection-injection-set_xml 21 | 03_si-collection-injection-set_javaconfig 22 | 03_si-collection-injection-map_xml 23 | 03_si-collection-injection-map_javaconfig 24 | 03_si-collection-injection-props_xml 25 | 03_si-collection-injection-props_javaconfig 26 | 27 | -------------------------------------------------------------------------------- /examples/core/03_dependency-injection_module/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 03_dependency-injection_module 5 | pom 6 | 7 | com.altafjava 8 | core 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | 03_setter-injection_module 13 | 03_constructor-injection_module 14 | 03_field-injection_module 15 | 03_setter-constructor-overriding 16 | 17 | -------------------------------------------------------------------------------- /examples/core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | core 6 | pom 7 | core 8 | Spring Core Examples 9 | 10 | 11 | com.altafjava 12 | examples 13 | 0.0.1-SNAPSHOT 14 | 15 | 16 | 17 | 01_hello-world_module 18 | 02_bean-scope_module 19 | 03_dependency-injection_module 20 | 21 | 22 | 23 | 5.3.9 24 | 1.8 25 | 3.8.1 26 | 27 | 28 | 29 | 30 | org.springframework 31 | spring-context 32 | ${spring.version} 33 | 34 | 35 | org.springframework 36 | spring-beans 37 | ${spring.version} 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-compiler-plugin 46 | ${maven.compiler.plugin.version} 47 | 48 | ${java.version} 49 | ${java.version} 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.altafjava 6 | examples 7 | 0.0.1-SNAPSHOT 8 | pom 9 | examples 10 | Spring Examples 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | core 18 | 19 | 20 | -------------------------------------------------------------------------------- /images/core/container-configuration-metadata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altafjava/spring-interview-questions-answers/3dba772c651b1167454e622bd60cadabe88fcec3/images/core/container-configuration-metadata.png -------------------------------------------------------------------------------- /images/core/cross-cutting-concerns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altafjava/spring-interview-questions-answers/3dba772c651b1167454e622bd60cadabe88fcec3/images/core/cross-cutting-concerns.png -------------------------------------------------------------------------------- /images/core/spring-framework-runtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altafjava/spring-interview-questions-answers/3dba772c651b1167454e622bd60cadabe88fcec3/images/core/spring-framework-runtime.png -------------------------------------------------------------------------------- /images/spring-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altafjava/spring-interview-questions-answers/3dba772c651b1167454e622bd60cadabe88fcec3/images/spring-logo.png --------------------------------------------------------------------------------