├── spring-boot-camel ├── printing.key ├── src │ ├── test │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── apacheCamel │ │ │ └── CamelSpringBootApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── apacheCamel │ │ │ ├── models │ │ │ ├── Message.java │ │ │ ├── KeyBody.java │ │ │ └── interfaces │ │ │ │ └── MessageResponse.java │ │ │ ├── CamelSpringBootApplication.java │ │ │ ├── services │ │ │ └── MessageService.java │ │ │ └── config │ │ │ └── CamelConfig.java │ │ └── resources │ │ └── application.properties ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── spring-webflux ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammez │ │ │ └── examples │ │ │ └── webflux │ │ │ ├── repositories │ │ │ ├── TacoRepository.java │ │ │ ├── OrderRepository.java │ │ │ └── IngredientRepository.java │ │ │ ├── WebfluxApplication.java │ │ │ ├── GreetingWebClient.java │ │ │ ├── GreetingHandler.java │ │ │ ├── GreetingRouter.java │ │ │ ├── models │ │ │ ├── Taco.java │ │ │ ├── Ingredient.java │ │ │ └── Order.java │ │ │ ├── config │ │ │ ├── CouchbaseConfig.java │ │ │ └── ReactiveCouchbaseConfig.java │ │ │ └── controllers │ │ │ └── TacoController.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammez │ │ └── examples │ │ └── webflux │ │ └── GreetingRouterTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md └── .gitignore ├── spring-angular ├── sprular-web │ └── src │ │ └── main │ │ └── web │ │ └── np-app │ │ ├── src │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── app │ │ │ ├── app.component.css │ │ │ ├── Hero.ts │ │ │ ├── app-routing.module.ts │ │ │ ├── heros.service.ts │ │ │ ├── app.module.ts │ │ │ ├── app.component.ts │ │ │ └── app.component.spec.ts │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── styles.css │ │ ├── favicon.ico │ │ ├── tsconfig.app.json │ │ ├── tsconfig.spec.json │ │ ├── index.html │ │ ├── tslint.json │ │ ├── main.ts │ │ ├── browserslist │ │ ├── test.ts │ │ └── karma.conf.js │ │ ├── e2e │ │ ├── tsconfig.e2e.json │ │ ├── src │ │ │ ├── app.po.ts │ │ │ └── app.e2e-spec.ts │ │ └── protractor.conf.js │ │ ├── .editorconfig │ │ ├── tsconfig.json │ │ ├── .gitignore │ │ ├── README.md │ │ └── package.json ├── sprular-server │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── eprogrammerz │ │ │ │ └── examples │ │ │ │ └── springangular │ │ │ │ ├── controllers │ │ │ │ ├── HomeController.java │ │ │ │ └── HeroController.java │ │ │ │ ├── SpringAngularApplication.java │ │ │ │ ├── models │ │ │ │ └── Hero.java │ │ │ │ └── config │ │ │ │ └── CorsConfig.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── springangular │ │ │ └── SpringAngularApplicationTests.java │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ └── .gitignore └── pom.xml ├── spring-trasaction ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── schema.sql │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── spring │ │ │ └── springtrasaction │ │ │ ├── SpringTrasactionApplication.java │ │ │ ├── ThreadConfig.java │ │ │ └── BookingService.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── spring │ │ └── springtrasaction │ │ └── SpringTrasactionApplicationTests.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore └── build.gradle ├── spring-kotlin-demo ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── kotlin │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ ├── repositories │ │ │ └── CustomerRepository.kt │ │ │ ├── models │ │ │ └── Customer.kt │ │ │ ├── controllers │ │ │ └── CustomerController.kt │ │ │ ├── config │ │ │ └── SwaggerConfig.kt │ │ │ └── KotlinDemoApplication.kt │ └── test │ │ └── kotlin │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── KotlinDemoApplicationTests.kt ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── spring-metric-api ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── messages.properties │ │ └── java │ │ │ └── com │ │ │ └── company │ │ │ └── dpt │ │ │ └── metric │ │ │ └── api │ │ │ └── metricapi │ │ │ ├── exceptions │ │ │ ├── BaseException.java │ │ │ ├── DataException.java │ │ │ ├── NotFoundException.java │ │ │ └── AlreadyExistsException.java │ │ │ ├── repositories │ │ │ ├── MetricRepository.java │ │ │ └── MetricEntryRepository.java │ │ │ ├── MetricApiApplication.java │ │ │ ├── models │ │ │ ├── interfaces │ │ │ │ ├── MetricRequest.java │ │ │ │ ├── MetricEntryRequest.java │ │ │ │ ├── ErrorResponse.java │ │ │ │ └── Statistics.java │ │ │ ├── common │ │ │ │ ├── Error.java │ │ │ │ └── ErrorCodes.java │ │ │ └── core │ │ │ │ └── MetricEntry.java │ │ │ ├── services │ │ │ ├── MetricEntryService.java │ │ │ └── MetricService.java │ │ │ └── config │ │ │ ├── MessageSourceConfig.java │ │ │ └── SwaggerConfiguration.java │ └── test │ │ └── java │ │ └── com │ │ └── company │ │ └── dpt │ │ └── metric │ │ └── api │ │ └── metricapi │ │ └── MetricApiApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── README.md ├── spring-boot-activiti ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── activiti │ │ │ └── hiring │ │ │ ├── services │ │ │ └── ResumeService.java │ │ │ ├── repositories │ │ │ └── ApplicantRepository.java │ │ │ ├── HiringApplication.java │ │ │ ├── models │ │ │ └── Applicant.java │ │ │ ├── config │ │ │ └── SwaggerConfiguration.java │ │ │ └── controllers │ │ │ └── ApplicantController.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── activiti │ │ └── hiring │ │ └── SpringBootActivitiApplicationTests.java └── .gitignore ├── spring-custom-bean-validation ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── messages.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── validation │ │ │ ├── models │ │ │ ├── types │ │ │ │ └── CaseMode.java │ │ │ ├── common │ │ │ │ └── Error.java │ │ │ └── Car.java │ │ │ ├── CustomBeanValidationApplication.java │ │ │ ├── config │ │ │ └── MessageSourceConfig.java │ │ │ └── validators │ │ │ └── enumValidator │ │ │ ├── CheckCaseValidator.java │ │ │ └── CheckCase.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── validation │ │ └── CustomBeanValidationApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── Dockerfile └── .gitignore ├── spring-filter-custom-fields ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── spring │ │ │ └── filterCustomFields │ │ │ ├── SpringFilterCustomFieldsApplication.java │ │ │ ├── User.java │ │ │ └── UserController.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── spring │ │ └── filterCustomFields │ │ └── SpringFilterCustomFieldsApplicationTests.java └── .gitignore ├── spring-security-jwt-demo ├── .travis.yml ├── README.md ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── eprogrammerz │ │ │ │ └── examples │ │ │ │ └── security │ │ │ │ ├── models │ │ │ │ ├── RoleType.java │ │ │ │ └── Role.java │ │ │ │ ├── repository │ │ │ │ ├── RoleRepository.java │ │ │ │ └── UserRepository.java │ │ │ │ ├── JwtDemoApplication.java │ │ │ │ ├── security │ │ │ │ ├── exception │ │ │ │ │ ├── JwtTokenExpiredException.java │ │ │ │ │ ├── JwtTokenMissingException.java │ │ │ │ │ ├── JwtUserNotFoundException.java │ │ │ │ │ └── JwtTokenMalformedException.java │ │ │ │ ├── model │ │ │ │ │ ├── JwtUserDto.java │ │ │ │ │ └── JwtAuthenticationToken.java │ │ │ │ ├── JwtAuthenticationSuccessHandler.java │ │ │ │ ├── JwtAuthenticationEntryPoint.java │ │ │ │ └── utils │ │ │ │ │ ├── JwtTokenGenerator.java │ │ │ │ │ └── JwtTokenValidator.java │ │ │ │ ├── controller │ │ │ │ ├── MethodProtectedRestController.java │ │ │ │ └── UserController.java │ │ │ │ ├── service │ │ │ │ └── JwtUserDetailsServiceImpl.java │ │ │ │ └── data │ │ │ │ └── MockUserData.java │ │ └── resources │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── security │ │ └── JwtDemoApplicationTests.java ├── LICENSE └── .gitignore ├── spring-boot-cloud-foundry ├── src │ ├── main │ │ ├── resources │ │ │ ├── data.sql │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── bookmarkSvc │ │ │ ├── repositories │ │ │ └── BookmarkRepository.java │ │ │ ├── config │ │ │ └── SwaggerConfiguration.java │ │ │ ├── models │ │ │ ├── Bookmark.java │ │ │ └── types │ │ │ │ └── BookmarkType.java │ │ │ └── BookmarkServiceApplication.java │ └── test │ │ ├── java │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── bookmarkSvc │ │ │ └── BookmarkServiceApplicationTests.java │ │ └── groovy │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── bookmarkSvc │ │ └── controllers │ │ └── BookmarkControllerTest.groovy ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── manifest.yml ├── spring-boot-jpa-example ├── README.md ├── .gitignore └── src │ └── main │ ├── resources │ └── application.yml │ └── java │ └── com │ └── eprogrammerz │ └── examples │ └── jpa │ ├── ApplicantListener.java │ ├── ApplicantRepository.java │ └── ApplicantIdGenerator.java ├── spring-boot-rest-template ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── spring │ │ │ └── getToken │ │ │ ├── config │ │ │ └── BeanConfig.java │ │ │ ├── GetTokenApplication.java │ │ │ └── clients │ │ │ └── RemoteServiceClient.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── spring │ │ └── getToken │ │ └── GetTokenApplicationTests.java └── .gitignore ├── spring-boot-jsp ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ ├── webapp-1 │ │ │ └── WEB-INF │ │ │ │ └── jsp │ │ │ │ └── hello.jsp │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── spring │ │ │ └── springbootjsp │ │ │ ├── controllers │ │ │ └── HelloController.java │ │ │ └── SpringBootJspApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── spring │ │ └── springbootjsp │ │ └── SpringBootJspApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── spring-exception-handling ├── src │ ├── main │ │ ├── resources │ │ │ ├── application-dev.yml │ │ │ ├── application-local.yml │ │ │ ├── application.yml │ │ │ ├── messages.properties │ │ │ ├── log4j2.yml │ │ │ ├── log4j2-dev.yml │ │ │ └── log4j2-local.yml │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── rest │ │ │ ├── exceptions │ │ │ └── DataException.java │ │ │ ├── RestBeanValidationApplication.java │ │ │ ├── domains │ │ │ ├── Error.java │ │ │ ├── ErrorResponse.java │ │ │ ├── Address.java │ │ │ └── User.java │ │ │ ├── config │ │ │ └── MessageSourceConfig.java │ │ │ └── controllers │ │ │ └── UserController.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── rest │ │ └── RestBeanValidationApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── spring-boot-mongo ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── springbootmongo │ │ │ ├── models │ │ │ ├── Base.java │ │ │ └── Derived.java │ │ │ ├── repositories │ │ │ └── DerivedRepository.java │ │ │ └── SpringBootMongoApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── springbootmongo │ │ └── SpringBootMongoApplicationTests.java └── .gitignore ├── spring-okta-integration ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── saml │ │ │ │ └── keystore.jks │ │ │ ├── templates │ │ │ │ └── index.html │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ └── okta │ │ │ └── springOktaIntegration │ │ │ ├── controllers │ │ │ └── IndexController.java │ │ │ └── SpringOktaIntegrationApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── okta │ │ └── springOktaIntegration │ │ └── SpringOktaIntegrationApplicationTests.java └── .gitignore ├── spring-security-oauth-demo ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── src │ ├── test │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── SpringSecurityApplicationTests.java │ └── main │ ├── java │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ ├── controllers │ │ └── LoginController.java │ │ └── SpringSecurityApplication.java │ └── resources │ └── application.yml ├── spring-dynamic-properties-load ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ ├── exception │ │ │ └── ResourceException.java │ │ │ ├── DynamicPropertiesLoadApplication.java │ │ │ ├── config │ │ │ ├── PropertiesConfigurer.java │ │ │ ├── PropertyParts.java │ │ │ └── DynamicEnvironmentProperties.java │ │ │ └── controllers │ │ │ └── HomeController.java │ └── test │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── DynamicPropertiesLoadApplicationTests.java └── .gitignore ├── spring-in-action-example └── src │ ├── main │ ├── resources │ │ └── app.properties │ ├── java │ │ └── com │ │ │ └── eprogrammerz │ │ │ └── examples │ │ │ ├── models │ │ │ ├── CompactDisc.java │ │ │ ├── MediaPlayer.java │ │ │ └── impl │ │ │ │ ├── SgtPeppers.java │ │ │ │ └── CDPlayer.java │ │ │ ├── configuration │ │ │ ├── CDPlayerConfig.java │ │ │ ├── ApplicationInitializer.java │ │ │ └── ApplicationConfiguration.java │ │ │ └── controllers │ │ │ └── HomeController.java │ └── webapp │ │ └── WEB-INF │ │ └── views │ │ └── index.jsp │ └── test │ └── java │ └── com │ └── eprogrammerz │ └── examples │ ├── models │ └── impl │ │ └── CDPlayerTest.java │ └── controllers │ └── HomeControllerTest.java ├── spring-mvc-annotation ├── src │ └── main │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── views │ │ │ └── index.jsp │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ ├── controllers │ │ └── HomeController.java │ │ └── configuration │ │ ├── ApplicationInitializer.java │ │ └── ApplicationConfiguration.java └── .gitignore ├── spring-mvc-xml-demo ├── src │ └── main │ │ ├── webapp │ │ └── WEB-INF │ │ │ ├── pages │ │ │ └── index.jsp │ │ │ ├── web.xml │ │ │ └── spring-context │ │ │ └── DispatcherServlet-context.xml │ │ └── java │ │ └── com │ │ └── eprogrammerz │ │ └── examples │ │ └── controllers │ │ └── HomeController.java ├── .gitignore └── pom.xml ├── spring-dependency-injection ├── ProductApplication │ ├── src │ │ └── com │ │ │ └── eShop │ │ │ ├── service │ │ │ ├── IProductService.java │ │ │ └── ProductService.java │ │ │ ├── repository │ │ │ ├── IProductRepository.java │ │ │ └── ProductRepository.java │ │ │ ├── Application.java │ │ │ └── domain │ │ │ └── Product.java │ ├── web │ │ ├── WEB-INF │ │ │ └── web.xml │ │ └── index.jsp │ └── .gitignore ├── ProductApplicationDI │ ├── src │ │ ├── com │ │ │ └── eShop │ │ │ │ ├── service │ │ │ │ ├── IProductService.java │ │ │ │ └── ProductService.java │ │ │ │ ├── repository │ │ │ │ ├── IProductRepository.java │ │ │ │ ├── MockProjectRepo.java │ │ │ │ └── ProductRepository.java │ │ │ │ ├── Application.java │ │ │ │ └── domain │ │ │ │ └── Product.java │ │ └── springconfig.xml │ ├── web │ │ ├── WEB-INF │ │ │ └── web.xml │ │ └── index.jsp │ └── .gitignore └── libraries │ └── org.springframework.spring-library-3.0.2.RELEASE.libd └── .gitignore /spring-boot-camel/printing.key: -------------------------------------------------------------------------------- 1 | this is test text -------------------------------------------------------------------------------- /spring-webflux/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-trasaction/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/app.component.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 -------------------------------------------------------------------------------- /spring-metric-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8083 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-examples 2 | Consists of examples that I've done in spring. 3 | -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 -------------------------------------------------------------------------------- /spring-filter-custom-fields/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8089 -------------------------------------------------------------------------------- /spring-security-jwt-demo/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - oraclejdk8 -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS bookmark; -------------------------------------------------------------------------------- /spring-boot-jpa-example/README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot Application 2 | Showing custom id generation with JPA annotations -------------------------------------------------------------------------------- /spring-boot-rest-template/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | remote.service.host.uri=https://remote.server.uri -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: spring-boot-cloud-foundry -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mvc.view.prefix: /WEB-INF/jsp/ 2 | spring.mvc.view.suffix: .jsp 3 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/Hero.ts: -------------------------------------------------------------------------------- 1 | export class Hero { 2 | name : string; 3 | rating : string; 4 | } 5 | -------------------------------------------------------------------------------- /spring-boot-camel/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | message.route.uri=direct:action.message.route 2 | message.result.uri=mock:result -------------------------------------------------------------------------------- /spring-boot-jpa-example/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ 3 | spring-boot-example.iml 4 | /.settings/ 5 | /bin/ 6 | /.classpath 7 | /.project 8 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/README.md: -------------------------------------------------------------------------------- 1 | # JWT Spring Security Demo 2 | 3 | Demo illustrating use of JWT (JSON Web Tokens) with Spring Security. -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | api: 2 | version: 0.1 3 | 4 | logging: 5 | config: classpath:log4j2-dev.yml -------------------------------------------------------------------------------- /spring-trasaction/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | drop table BOOKINGS if exists; 2 | create table BOOKINGS(IID serial, FIRST_NAME varchar(7) NOT NULL); -------------------------------------------------------------------------------- /spring-boot-jsp/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-boot-jsp/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-webflux/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-webflux/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-camel/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-boot-camel/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-mongo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-boot-mongo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-metric-api/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-metric-api/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-mongo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | data: 3 | mongodb: 4 | database: test 5 | host: localhost 6 | port: 27017 -------------------------------------------------------------------------------- /spring-kotlin-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-kotlin-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-trasaction/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-trasaction/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-trasaction/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | } 5 | } 6 | rootProject.name = 'spring-trasaction' 7 | -------------------------------------------------------------------------------- /spring-boot-camel/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-boot-cloud-foundry/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-jsp/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-mongo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /spring-exception-handling/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-exception-handling/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-kotlin-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-metric-api/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /spring-okta-integration/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-okta-integration/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-exception-handling/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-okta-integration/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /spring-security-oauth-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-security-oauth-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-security-oauth-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-angular/sprular-server/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-custom-bean-validation/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-custom-bean-validation/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-custom-bean-validation/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-dynamic-properties-load/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-dynamic-properties-load/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /spring-okta-integration/src/main/resources/saml/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-okta-integration/src/main/resources/saml/keystore.jks -------------------------------------------------------------------------------- /spring-angular/sprular-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YogenRaii/spring-examples/HEAD/spring-angular/sprular-web/src/main/web/np-app/src/favicon.ico -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8083 3 | 4 | api: 5 | version: 0.1 6 | 7 | logging: 8 | config: classpath:log4j2-local.yml -------------------------------------------------------------------------------- /spring-metric-api/src/main/resources/messages.properties: -------------------------------------------------------------------------------- 1 | NotEmpty={0} can not be EMPTY. 2 | NotNull={0} can not be NULL. 3 | Size={0} must be of length between {2} to {1}. 4 | metricName=Metric Name -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | errors: 2 | description: 3 | EXC400: INVALID INPUT 4 | EXC404: NO CONTENT FOUND 5 | 6 | 7 | server: 8 | port: 5000 9 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | properties.path=/Yogen/api/project/common_utils/src/resources/properties/test1.properties 3 | updateFrequency=1 -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/models/RoleType.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.models; 2 | 3 | public enum RoleType { 4 | ROLE_USER, ROLE_ADMIN 5 | } -------------------------------------------------------------------------------- /spring-okta-integration/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spring Security SAML Example 5 | 6 | 7 | Hello eProgrammerz! 8 | 9 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/resources/messages.properties: -------------------------------------------------------------------------------- 1 | org.hibernate.validator.referenceguide.chapter06.CheckCase.message=Case mode must be {value}. 2 | 3 | CheckCase = {0} is invalid. 4 | 5 | licensePlate = License Plate -------------------------------------------------------------------------------- /spring-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.couchbase.bootstrap-host=couchbase://127.0.0.1 2 | spring.couchbase.bucket-name=tacos 3 | spring.couchbase.username=tacoadmin 4 | spring.couchbase.password=password 5 | 6 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | filter.table.source= FILE 2 | cache.time.milliseconds=300000 3 | filter.table.baseDir=http://dlkd1.delta.com:17021/content/dam/delta-content-api/ 4 | filter.table.defaultName=filter 5 | -------------------------------------------------------------------------------- /spring-mvc-annotation/src/main/webapp/WEB-INF/views/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 |

Spring MVC Hello World Annotation Example

5 | 6 |

${msg}

7 | 8 | -------------------------------------------------------------------------------- /spring-mvc-xml-demo/src/main/webapp/WEB-INF/pages/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 |

Spring MVC Hello World Annotation Example

5 | 6 |

${msg}

7 | 8 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/models/CompactDisc.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models; 2 | 3 | /** 4 | * Created by 542596 on 2/12/2017. 5 | */ 6 | public interface CompactDisc { 7 | void play(); 8 | } 9 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/models/MediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models; 2 | 3 | /** 4 | * Created by 542596 on 2/12/2017. 5 | */ 6 | public interface MediaPlayer { 7 | void play(); 8 | } 9 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/webapp/WEB-INF/views/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 |

Spring MVC Hello World Annotation Example

5 | 6 |

${msg}

7 | 8 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/README.md: -------------------------------------------------------------------------------- 1 | ### Docker build 2 | 3 | 1. Create docker image 4 | ```bash 5 | docker build -t spring-bean-validation . 6 | ``` 7 | 8 | 2. Create container 9 | 10 | ```bash 11 | docker run -p 8080:8081 12 | ``` 13 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/service/IProductService.java: -------------------------------------------------------------------------------- 1 | package com.eShop.service; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | public interface IProductService { 6 | Product getProduct(int productNumber); 7 | } 8 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/service/IProductService.java: -------------------------------------------------------------------------------- 1 | package com.eShop.service; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | public interface IProductService { 6 | Product getProduct(int productNumber); 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-jpa-example/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8086 3 | spring: 4 | jpa: 5 | hibernate: 6 | ddl-auto: create 7 | datasource: 8 | url: jdbc:mysql://localhost:3306/db_example 9 | username: root 10 | password: -------------------------------------------------------------------------------- /spring-webflux/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | VOLUME /tmp 3 | COPY target/spring-custom-bean-validation*.jar spring-bean-validation.jar 4 | EXPOSE 8081 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/spring-bean-validation.jar"] 6 | -------------------------------------------------------------------------------- /spring-trasaction/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/webapp-1/WEB-INF/jsp/hello.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello ${name}! 6 | 7 | 8 |

Hello ${name}!

9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/models/types/CaseMode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.validation.models.types; 5 | 6 | /** 7 | * @author Yogen 8 | * 9 | */ 10 | public enum CaseMode { 11 | UPPER, 12 | LOWER 13 | } 14 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/exceptions/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.exceptions; 2 | 3 | public abstract class BaseException extends RuntimeException { 4 | public BaseException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-mongo/src/main/java/com/eprogrammerz/examples/springbootmongo/models/Base.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springbootmongo.models; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | @Data 7 | public class Base { 8 | private String fieldA; 9 | } 10 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/repository/IProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.eShop.repository; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | /** 6 | * Created by rajkumar on 6/3/2016. 7 | */ 8 | public interface IProductRepository { 9 | Product findOne(int productNumber); 10 | } 11 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/repository/IProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.eShop.repository; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | /** 6 | * Created by rajkumar on 6/3/2016. 7 | */ 8 | public interface IProductRepository { 9 | Product findOne(int productNumber); 10 | } 11 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/') as Promise; 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | # JACKSON 3 | spring: 4 | jackson: 5 | serialization: 6 | INDENT_OUTPUT: true 7 | 8 | jwt: 9 | header: Authorization 10 | secret: mySecret 11 | expiration: 386500 12 | 13 | logging: 14 | level: 15 | org.springframework: 16 | security: DEBUG -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [RouterModule.forRoot(routes)], 8 | exports: [RouterModule] 9 | }) 10 | export class AppRoutingModule { } 11 | -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/models/Message.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel.models; 2 | 3 | import lombok.*; 4 | 5 | /** 6 | * Created by Yogen on 10/8/2017. 7 | */ 8 | @Data 9 | @AllArgsConstructor 10 | public class Message { 11 | private Integer id; 12 | private String content; 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/services/ResumeService.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring.services; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class ResumeService { 7 | public void storeResume() { 8 | System.out.println("Storing resume..."); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: ${BOOKMARK_SVC_PORT:9098} 3 | 4 | spring: 5 | jpa: 6 | generate-ddl: true 7 | datasource: 8 | driverClassName: com.mysql.jdbc.Driver 9 | url: jdbc:mysql://localhost:3306/bookmark 10 | username: root 11 | password: 12 | 13 | --- 14 | spring: 15 | profiles: cloud -------------------------------------------------------------------------------- /spring-okta-integration/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8443 2 | server.ssl.enabled=true 3 | server.ssl.key-alias=spring-okta-integration 4 | server.ssl.key-store=classpath:saml/keystore.jks 5 | server.ssl.key-store-password= secret-password 6 | 7 | security.saml2.metadata-url=https://dev-808481.oktapreview.com/app/exkdqg4cuamoHtmR10h7/sso/saml/metadata -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/repositories/ApplicantRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring.repositories; 2 | 3 | import com.eprogrammerz.activiti.hiring.models.Applicant; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface ApplicantRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-mongo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /spring-metric-api/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | *.DS_Store -------------------------------------------------------------------------------- /spring-kotlin-demo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-exception-handling/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-okta-integration/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-security-oauth-demo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/repositories/TacoRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.repositories; 2 | 3 | import com.eprogrammez.examples.webflux.models.Taco; 4 | import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository; 5 | 6 | public interface TacoRepository extends ReactiveCouchbaseRepository { 7 | } 8 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-dynamic-properties-load/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/repositories/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.repositories; 2 | 3 | import com.eprogrammez.examples.webflux.models.Order; 4 | import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository; 5 | 6 | public interface OrderRepository extends ReactiveCouchbaseRepository { 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-rest-template/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .mvn/wrapper/maven-wrapper.jar 3 | .mvn 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-filter-custom-fields/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .mvn/wrapper/maven-wrapper.jar 3 | .mvn 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/models/KeyBody.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | 7 | /** 8 | * @author Yogen Rai 9 | */ 10 | @AllArgsConstructor 11 | @Getter 12 | @ToString 13 | public class KeyBody { 14 | private String key; 15 | } 16 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NpApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/repositories/IngredientRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.repositories; 2 | 3 | import com.eprogrammez.examples.webflux.models.Ingredient; 4 | import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository; 5 | 6 | public interface IngredientRepository extends ReactiveCouchbaseRepository { 7 | } 8 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-camel/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | camel.springboot.name=MyCamel 2 | server.address=0.0.0.0 3 | management.address=0.0.0.0 4 | management.port=8081 5 | endpoints.enabled = true 6 | endpoints.health.enabled = true 7 | 8 | message.route.uri=direct:action.message.route 9 | file.route.uri=direct:action.file.route 10 | keys.root.dir=/Users/yrai/examples/apache-camel-examples/apache-camel-spring-boot -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/repositories/MetricRepository.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.repositories; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.core.Metric; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MetricRepository extends JpaRepository { 7 | Metric findByName(String name); 8 | } 9 | -------------------------------------------------------------------------------- /spring-mvc-xml-demo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | out 27 | spring-mvc.iml -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/models/interfaces/MessageResponse.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel.models.interfaces; 2 | 3 | import com.eprogrammerz.examples.apacheCamel.models.Message; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | public class MessageResponse { 10 | private Message message; 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | *.iml 27 | mvnw 28 | mvnw.cmd -------------------------------------------------------------------------------- /spring-mvc-annotation/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | out 27 | spring-mvc-annotation.iml -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/web/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: rajkumar 4 | Date: 6/3/2016 5 | Time: 6:54 PM 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | $Title$ 12 | 13 | 14 | $END$ 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/web/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: rajkumar 4 | Date: 6/3/2016 5 | Time: 7:07 PM 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | $Title$ 12 | 13 | 14 | $END$ 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.eprogrammerz.examples.security.models.Role; 6 | 7 | 8 | /** 9 | * Created by Yogen 10 | */ 11 | public interface RoleRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/repository/MockProjectRepo.java: -------------------------------------------------------------------------------- 1 | package com.eShop.repository; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | /** 6 | * Created by rajkumar on 6/3/2016. 7 | */ 8 | public class MockProjectRepo implements IProductRepository { 9 | @Override 10 | public Product findOne(int productNumber) { 11 | return new Product(423,"Mock Object",123.00); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/kotlin/com/eprogrammerz/examples/repositories/CustomerRepository.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.repositories 2 | 3 | import com.eprogrammerz.examples.models.Customer 4 | import org.springframework.data.repository.CrudRepository 5 | 6 | /** 7 | * Created by Yogen on 9/11/2017. 8 | */ 9 | interface CustomerRepository: CrudRepository { 10 | fun findByLastName(name: String): List 11 | } -------------------------------------------------------------------------------- /spring-boot-activiti/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | #.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | mvnw.cmd 27 | mvnw 28 | .mvn 29 | spring-boot-activiti.iml -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | out 27 | ProductApplication.iml -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | out 27 | ProductApplicationDI.iml -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/HiringApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HiringApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HiringApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/exception/ResourceException.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.exception; 2 | 3 | public class ResourceException extends Exception { 4 | 5 | private static final long serialVersionUID = -8926637401097864935L; 6 | 7 | public ResourceException(String message) 8 | { 9 | super(message); 10 | } 11 | public ResourceException(Throwable error) 12 | { 13 | super(error); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /spring-boot-jpa-example/src/main/java/com/eprogrammerz/examples/jpa/ApplicantListener.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.jpa; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import javax.persistence.PrePersist; 6 | 7 | public class ApplicantListener { 8 | @Autowired 9 | private ApplicantRepository applicantRepository; 10 | 11 | @PrePersist 12 | public void setApplicantId(Applicant applicant) { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/MetricApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MetricApiApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MetricApiApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-okta-integration/src/main/java/com/eprogrammerz/examples/okta/springOktaIntegration/controllers/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.okta.springOktaIntegration.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class IndexController { 8 | @GetMapping("/") 9 | public String index() { 10 | return "index"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.eprogrammerz.examples.security.models.User; 6 | 7 | /** 8 | * Created by Yogen 9 | */ 10 | public interface UserRepository extends JpaRepository { 11 | User findByUsername(String username); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-camel/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | mvnw 27 | mvnw.cmd 28 | apache-camel-spring-boot.iml 29 | 30 | .DS_Store 31 | *.DS_Store -------------------------------------------------------------------------------- /spring-kotlin-demo/src/test/kotlin/com/eprogrammerz/examples/KotlinDemoApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class KotlinDemoApplicationTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/java/com/eprogrammerz/examples/springangular/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | @RequestMapping 8 | public class HomeController { 9 | @RequestMapping 10 | public String home() { 11 | return "index.html"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/interfaces/MetricRequest.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.interfaces; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.Min; 6 | import javax.validation.constraints.NotNull; 7 | import javax.validation.constraints.Size; 8 | 9 | @Data 10 | public class MetricRequest { 11 | @NotNull 12 | @Size(min = 2, max = 20) 13 | private String metricName; 14 | } 15 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/exceptions/DataException.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.exceptions; 2 | 3 | import org.springframework.validation.Errors; 4 | 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public class DataException extends RuntimeException { 9 | 10 | private final Errors errors; 11 | 12 | public DataException(String message, Errors errors) { 13 | super(message); 14 | this.errors = errors; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/heros.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {HttpClient} from '@angular/common/http'; 3 | import {Observable} from "rxjs"; 4 | import {Hero} from "./Hero"; 5 | 6 | @Injectable() 7 | export class HeroService { 8 | constructor(private http: HttpClient) { 9 | } 10 | 11 | configUrl = 'http://localhost:8090/api/heroes'; 12 | 13 | getHeroes() { 14 | return this.http.get(this.configUrl); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/CamelSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CamelSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CamelSpringBootApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/RestBeanValidationApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RestBeanValidationApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RestBeanValidationApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/messages.properties: -------------------------------------------------------------------------------- 1 | NotEmpty = {0} can not be empty. 2 | NotNull = {0} can not be null. 3 | Past = {0} must be in the past. 4 | Min = {0} must be greater than or equal to 1. 5 | 6 | 7 | Size.address.state = State must be of two character. 8 | Pattern.address.zip = Zip code must be of 5 digit. 9 | 10 | state = State 11 | city = City 12 | street = Street 13 | firstName = First Name 14 | lastName = lastName 15 | dateOfBirth = Date of birth 16 | age = Age -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/exceptions/DataException.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.validation.Errors; 5 | 6 | @Getter 7 | public class DataException extends BaseException { 8 | private final Errors errors; 9 | 10 | public DataException(String message, Errors errors) { 11 | super(message); 12 | this.errors = errors; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/interfaces/MetricEntryRequest.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.interfaces; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.Min; 6 | import javax.validation.constraints.NotNull; 7 | import javax.validation.constraints.Size; 8 | 9 | @Data 10 | public class MetricEntryRequest { 11 | @Min(0) 12 | private long metricId; 13 | 14 | private double value; 15 | } 16 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/JwtDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JwtDemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(JwtDemoApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-jsp/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-mongo/src/main/java/com/eprogrammerz/examples/springbootmongo/models/Derived.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springbootmongo.models; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | @Data 7 | @Document 8 | public class Derived extends Base { 9 | private String fieldB; 10 | 11 | @Override 12 | public String toString() { 13 | return "{fieldA: " + getFieldA() + ", fieldB: " + fieldB + "}"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/DynamicPropertiesLoadApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DynamicPropertiesLoadApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DynamicPropertiesLoadApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/domains/Error.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.domains; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | @Getter 10 | @Setter 11 | @ToString 12 | @JsonIgnoreProperties(ignoreUnknown = true) 13 | public class Error { 14 | private String errorCode; 15 | private String field; 16 | private String message; 17 | } 18 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/java/com/eprogrammerz/examples/springangular/SpringAngularApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringAngularApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringAngularApplication.class, args); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /spring-security-oauth-demo/src/test/java/com/eprogrammerz/examples/SpringSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringSecurityApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-trasaction/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 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 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/models/Applicant.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring.models; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | 9 | @Data 10 | @Entity 11 | public class Applicant { 12 | @Id 13 | @GeneratedValue 14 | private Long id; 15 | 16 | private String name; 17 | private String email; 18 | private String phoneNumber; 19 | } 20 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/CustomBeanValidationApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.validation; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CustomBeanValidationApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CustomBeanValidationApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.exceptions; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.common.Error; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public class NotFoundException extends BaseException { 8 | private final Error error; 9 | 10 | public NotFoundException(String message, Error error) { 11 | super(message); 12 | this.error = error; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-metric-api/src/test/java/com/company/dpt/metric/api/metricapi/MetricApiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MetricApiApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-activiti/src/test/java/com/eprogrammerz/activiti/hiring/SpringBootActivitiApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootActivitiApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-camel/src/test/java/com/eprogrammerz/examples/apacheCamel/CamelSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class CamelSpringBootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rest-template/src/test/java/com/eprogrammerz/examples/spring/getToken/GetTokenApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.getToken; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class GetTokenApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/test/java/com/eprogrammerz/examples/DynamicPropertiesLoadApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DynamicPropertiesLoadApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-exception-handling/src/test/java/com/eprogrammerz/examples/rest/RestBeanValidationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class RestBeanValidationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/test/java/com/eprogrammerz/examples/security/JwtDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class JwtDemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/java/com/eprogrammerz/examples/springangular/models/Hero.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular.models; 2 | 3 | public class Hero { 4 | private String name; 5 | private String rating; 6 | 7 | public Hero(String name, String rating) { 8 | this.name = name; 9 | this.rating = rating; 10 | } 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public String getRating() { 17 | return rating; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/test/java/com/eprogrammerz/examples/bookmarkSvc/BookmarkServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class BookmarkServiceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-mongo/src/test/java/com/eprogrammerz/examples/springbootmongo/SpringBootMongoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springbootmongo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootMongoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/test/java/com/eprogrammerz/examples/spring/springbootjsp/SpringBootJspApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springbootjsp; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootJspApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/common/Error.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.ToString; 7 | 8 | @Getter 9 | @AllArgsConstructor 10 | @ToString 11 | @JsonIgnoreProperties(ignoreUnknown = true) 12 | public class Error { 13 | private String errorCode; 14 | private String field; 15 | private String message; 16 | } -------------------------------------------------------------------------------- /spring-okta-integration/src/main/java/com/eprogrammerz/examples/okta/springOktaIntegration/SpringOktaIntegrationApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.okta.springOktaIntegration; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringOktaIntegrationApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringOktaIntegrationApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/test/java/com/eprogrammerz/examples/springangular/SpringAngularApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringAngularApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-mongo/src/main/java/com/eprogrammerz/examples/springbootmongo/repositories/DerivedRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springbootmongo.repositories; 2 | 3 | import com.eprogrammerz.examples.springbootmongo.models.Derived; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface DerivedRepository extends MongoRepository { 9 | List findByFieldA(String fieldA); 10 | 11 | List findByFieldB(String fieldB); 12 | } 13 | -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/kotlin/com/eprogrammerz/examples/models/Customer.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models 2 | 3 | import javax.persistence.Entity 4 | import javax.persistence.GeneratedValue 5 | import javax.persistence.GenerationType 6 | import javax.persistence.Id 7 | 8 | /** 9 | * Created by Yogen on 9/11/2017. 10 | */ 11 | @Entity 12 | class Customer(var firstName: String = "", 13 | var lastName: String = "", 14 | @Id @GeneratedValue(strategy = GenerationType.AUTO) 15 | var id: Long = 0) -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/core/MetricEntry.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.core; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | @Entity 9 | public class MetricEntry { 10 | @Id 11 | @Column(name = "ENT_ID") 12 | private long id; 13 | 14 | @Column(name = "ENT_VALUE") 15 | private double value; 16 | 17 | @ManyToOne(fetch = FetchType.LAZY) 18 | @JoinColumn(name = "MET_ID") 19 | private Metric metric; 20 | } 21 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/test/java/com/eprogrammerz/examples/validation/CustomBeanValidationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.validation; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class CustomBeanValidationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/models/common/Error.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.validation.models.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.ToString; 8 | 9 | @Getter 10 | @AllArgsConstructor 11 | @ToString 12 | @JsonIgnoreProperties(ignoreUnknown = true) 13 | public class Error { 14 | private String errorCode; 15 | private String field; 16 | private String message; 17 | } 18 | -------------------------------------------------------------------------------- /spring-filter-custom-fields/src/main/java/com/eprogrammerz/examples/spring/filterCustomFields/SpringFilterCustomFieldsApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.filterCustomFields; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringFilterCustomFieldsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringFilterCustomFieldsApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-trasaction/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.0.3.RELEASE' 3 | id 'java' 4 | } 5 | 6 | apply plugin: 'io.spring.dependency-management' 7 | 8 | group = 'com.eprogrammerz.examples.spring' 9 | version = '0.0.1-SNAPSHOT' 10 | sourceCompatibility = '1.8' 11 | 12 | repositories { 13 | mavenCentral() 14 | } 15 | 16 | dependencies { 17 | implementation 'org.springframework.boot:spring-boot-starter-jdbc' 18 | runtime 'com.h2database:h2' 19 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 20 | } 21 | -------------------------------------------------------------------------------- /spring-trasaction/src/test/java/com/eprogrammerz/examples/spring/springtrasaction/SpringTrasactionApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springtrasaction; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringTrasactionApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/domains/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.domains; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | @Getter 12 | @Setter 13 | @ToString 14 | @JsonIgnoreProperties(ignoreUnknown = true) 15 | public class ErrorResponse { 16 | private int code; 17 | private String developersMessage; 18 | private List errors; 19 | } 20 | -------------------------------------------------------------------------------- /spring-webflux/README.md: -------------------------------------------------------------------------------- 1 | ###Steps: 2 | 1. [Install Couchbase](https://docs.couchbase.com/server/current/install/install-intro.html) 3 | 2. After installation, you can start from Applications, and will be available at: 4 | 5 | http://127.0.0.1:8091/ui/index.html 6 | 7 | Now, create a cluster with credentials: 8 | 9 | Cluster name: tacosvc 10 | 11 | Password: tacosvc 12 | 13 | Once you get into cluster, add user, which will be used in `ReactiveCouchbaseConfig.java` to configure the connection, as: 14 | 15 | username: tacoadmin 16 | 17 | password: password 18 | -------------------------------------------------------------------------------- /spring-filter-custom-fields/src/main/java/com/eprogrammerz/examples/spring/filterCustomFields/User.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.filterCustomFields; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @Setter 10 | @Getter 11 | @AllArgsConstructor 12 | public class User { 13 | private String name; 14 | private Integer age; 15 | private Float salary; 16 | private String gender; 17 | } 18 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/exception/JwtTokenExpiredException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.security.security.exception; 5 | 6 | import org.springframework.security.core.AuthenticationException; 7 | 8 | /** 9 | * @author Yogen 10 | * 11 | */ 12 | public class JwtTokenExpiredException extends AuthenticationException { 13 | 14 | /** 15 | * @param msg 16 | */ 17 | public JwtTokenExpiredException(String msg) { 18 | super(msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/exception/JwtTokenMissingException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.security.security.exception; 5 | 6 | import org.springframework.security.core.AuthenticationException; 7 | 8 | /** 9 | * @author Yogen 10 | * 11 | */ 12 | public class JwtTokenMissingException extends AuthenticationException { 13 | 14 | /** 15 | * @param msg 16 | */ 17 | public JwtTokenMissingException(String msg) { 18 | super(msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/exception/JwtUserNotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.security.security.exception; 5 | 6 | import org.springframework.security.core.AuthenticationException; 7 | 8 | /** 9 | * @author Yogen 10 | * 11 | */ 12 | public class JwtUserNotFoundException extends AuthenticationException { 13 | 14 | /** 15 | * @param msg 16 | */ 17 | public JwtUserNotFoundException(String msg) { 18 | super(msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-webflux/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/services/MessageService.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel.services; 2 | 3 | import com.eprogrammerz.examples.apacheCamel.models.Message; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * Created by Yogen on 10/8/2017. 8 | */ 9 | @Service 10 | public class MessageService { 11 | public void transform(Message message) { 12 | message.setId(message.getId() * 10); 13 | message.setContent(message.getContent() + " has been changed."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/exception/JwtTokenMalformedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.security.security.exception; 5 | 6 | import org.springframework.security.core.AuthenticationException; 7 | 8 | /** 9 | * @author Yogen 10 | * 11 | */ 12 | public class JwtTokenMalformedException extends AuthenticationException { 13 | 14 | /** 15 | * @param msg 16 | */ 17 | public JwtTokenMalformedException(String msg) { 18 | super(msg); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/WebfluxApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebfluxApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(WebfluxApplication.class, args); 11 | 12 | GreetingWebClient client = new GreetingWebClient(); 13 | System.out.println(client.getResult()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-okta-integration/src/test/java/com/eprogrammerz/examples/okta/springOktaIntegration/SpringOktaIntegrationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.okta.springOktaIntegration; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringOktaIntegrationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-security-oauth-demo/src/main/java/com/eprogrammerz/examples/controllers/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | import java.security.Principal; 7 | 8 | /** 9 | * Created by Yogen on 2/24/2017. 10 | */ 11 | @RestController 12 | public class LoginController { 13 | @RequestMapping("/user") 14 | public Principal getUser(Principal principal) { 15 | return principal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/exceptions/AlreadyExistsException.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.exceptions; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.common.Error; 4 | import lombok.Getter; 5 | import org.springframework.validation.Errors; 6 | 7 | @Getter 8 | public class AlreadyExistsException extends BaseException { 9 | private final Error error; 10 | 11 | public AlreadyExistsException(String message, Error error) { 12 | super(message); 13 | this.error = error; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-filter-custom-fields/src/test/java/com/eprogrammerz/examples/spring/filterCustomFields/SpringFilterCustomFieldsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.filterCustomFields; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringFilterCustomFieldsApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/java/com/eprogrammerz/examples/bookmarkSvc/repositories/BookmarkRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc.repositories; 2 | 3 | import com.eprogrammerz.examples.bookmarkSvc.models.Bookmark; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Yogen on 9/26/2017. 10 | */ 11 | public interface BookmarkRepository extends JpaRepository { 12 | List findByUserId(String userId); 13 | Bookmark findByUserIdAndId(String userId, Long id); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-rest-template/src/main/java/com/eprogrammerz/examples/spring/getToken/config/BeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.getToken.config; 2 | 3 | import org.springframework.boot.web.client.RestTemplateBuilder; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Configuration 9 | public class BeanConfig { 10 | @Bean 11 | public RestTemplate restTemplate(RestTemplateBuilder builder) { 12 | return builder.build(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/model/JwtUserDto.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * Holds info extracted from JWT 10 | * 11 | * @author Yogen 12 | * 13 | */ 14 | @Getter 15 | @AllArgsConstructor 16 | @ToString 17 | public class JwtUserDto { 18 | private String id; 19 | 20 | private String username; 21 | 22 | private String role; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/services/MetricEntryService.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.services; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.core.Metric; 4 | import com.company.dpt.metric.api.metricapi.models.core.MetricEntry; 5 | import com.company.dpt.metric.api.metricapi.models.interfaces.MetricEntryRequest; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | 9 | public interface MetricEntryService { 10 | MetricEntry createMetricEntry(MetricEntryRequest metric); 11 | } 12 | -------------------------------------------------------------------------------- /spring-trasaction/src/main/java/com/eprogrammerz/examples/spring/springtrasaction/SpringTrasactionApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springtrasaction; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableAsync; 6 | 7 | @SpringBootApplication 8 | @EnableAsync 9 | public class SpringTrasactionApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringTrasactionApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.eShop.service; 2 | 3 | import com.eShop.domain.Product; 4 | import com.eShop.repository.IProductRepository; 5 | 6 | public class ProductService implements IProductService{ 7 | private IProductRepository productRepository; 8 | 9 | public ProductService(){} 10 | 11 | public void setProductRepository(IProductRepository productRepository) { 12 | this.productRepository = productRepository; 13 | } 14 | 15 | public Product getProduct(int productNumber) { 16 | return productRepository.findOne(productNumber); 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/interfaces/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.interfaces; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.common.Error; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | import java.util.List; 10 | 11 | @Getter 12 | @Setter 13 | @ToString 14 | @JsonIgnoreProperties(ignoreUnknown = true) 15 | public class ErrorResponse { 16 | private int code; 17 | private String developersMessage; 18 | private List errors; 19 | } -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/springconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | 7 | import { HttpClientModule } from '@angular/common/http'; 8 | import {HeroService} from "./heros.service"; 9 | 10 | @NgModule({ 11 | declarations: [ 12 | AppComponent 13 | ], 14 | imports: [ 15 | BrowserModule, 16 | AppRoutingModule, 17 | HttpClientModule 18 | ], 19 | providers: [HeroService], 20 | bootstrap: [AppComponent] 21 | }) 22 | export class AppModule { } 23 | -------------------------------------------------------------------------------- /spring-boot-jpa-example/src/main/java/com/eprogrammerz/examples/jpa/ApplicantRepository.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.jpa; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Modifying; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | @Transactional 10 | public interface ApplicantRepository extends JpaRepository { 11 | @Modifying 12 | @Query("delete from Applicant a where a.applicantId=:id") 13 | void deleteById(@Param("id") String id); 14 | } -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/models/impl/SgtPeppers.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models.impl; 2 | 3 | import com.eprogrammerz.examples.models.CompactDisc; 4 | 5 | /** 6 | * Created by 542596 on 2/12/2017. 7 | */ 8 | //@Component 9 | public class SgtPeppers implements CompactDisc { 10 | private String title;// = "Hello"; 11 | private String artist;// = "Adele"; 12 | 13 | public SgtPeppers(String title, String artist) { 14 | this.title = title; 15 | this.artist = artist; 16 | } 17 | 18 | public void play() { 19 | System.out.print(String.format("Playing %s by %s.", title, artist)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/eprogrammerz/examples/spring/springbootjsp/controllers/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springbootjsp.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | @GetMapping({"/", "/hello"}) 11 | public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { 12 | model.addAttribute("name", name); 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/models/impl/CDPlayer.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models.impl; 2 | 3 | import com.eprogrammerz.examples.models.CompactDisc; 4 | import com.eprogrammerz.examples.models.MediaPlayer; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by 542596 on 2/12/2017. 10 | */ 11 | @Component 12 | public class CDPlayer implements MediaPlayer { 13 | private CompactDisc cd; 14 | 15 | @Autowired 16 | public CDPlayer(CompactDisc cd) { 17 | this.cd = cd; 18 | } 19 | 20 | public void play() { 21 | cd.play(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-mvc-xml-demo/src/main/java/com/eprogrammerz/examples/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | 8 | /** 9 | * Created by 542596 on 2/12/2017. 10 | */ 11 | @Controller 12 | public class HomeController { 13 | @RequestMapping(value = "/", method = RequestMethod.GET) 14 | public String index(Model model) { 15 | model.addAttribute("msg", "Welcom to the Spring MVC Application!!!"); 16 | return "index"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/Application.java: -------------------------------------------------------------------------------- 1 | package com.eShop; 2 | 3 | 4 | import com.eShop.domain.Product; 5 | import com.eShop.service.IProductService; 6 | import com.eShop.service.ProductService; 7 | public class Application { 8 | public static void main(String[] args) { 9 | IProductService productService = new ProductService(); 10 | 11 | Product product1 = productService.getProduct(423); 12 | if (product1 != null) { 13 | System.out.println(product1); 14 | } 15 | Product product2 = productService.getProduct(239); 16 | if (product2 != null) { 17 | System.out.println(product2); 18 | } 19 | } 20 | 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-security-oauth-demo/src/main/java/com/eprogrammerz/examples/SpringSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 6 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client; 7 | 8 | @SpringBootApplication 9 | @EnableOAuth2Client 10 | @EnableAuthorizationServer 11 | public class SpringSecurityApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SpringSecurityApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.eShop.service; 2 | 3 | import com.eShop.domain.Product; 4 | import com.eShop.repository.IProductRepository; 5 | import com.eShop.repository.ProductRepository; 6 | 7 | public class ProductService implements IProductService{ 8 | private IProductRepository productRepository; 9 | 10 | public ProductService(){ 11 | productRepository = new ProductRepository(); 12 | } 13 | 14 | public void setProductRepository(IProductRepository productRepository) { 15 | this.productRepository = productRepository; 16 | } 17 | 18 | public Product getProduct(int productNumber) { 19 | return productRepository.findOne(productNumber); 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/GreetingWebClient.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.web.reactive.function.client.ClientResponse; 5 | import org.springframework.web.reactive.function.client.WebClient; 6 | import reactor.core.publisher.Mono; 7 | 8 | public class GreetingWebClient { 9 | private WebClient webClient = WebClient.create("http://localhost:8080"); 10 | 11 | private Mono result = webClient.get().uri("/hello").accept(MediaType.TEXT_PLAIN).exchange(); 12 | public String getResult() { 13 | return ">> result >> " + result.flatMap(res -> res.bodyToMono(String.class)).block(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/configuration/CDPlayerConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.configuration; 2 | 3 | import com.eprogrammerz.examples.models.CompactDisc; 4 | import com.eprogrammerz.examples.models.impl.SgtPeppers; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * Created by 542596 on 2/12/2017. 11 | */ 12 | @Configuration 13 | @ComponentScan(basePackages = "com.eprogrammerz.examples") 14 | public class CDPlayerConfig { 15 | @Bean 16 | public CompactDisc getCompactDisc() { 17 | return new SgtPeppers("Hello","Adele"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/services/MetricService.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.services; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.core.Metric; 4 | import com.company.dpt.metric.api.metricapi.models.interfaces.MetricEntryRequest; 5 | import com.company.dpt.metric.api.metricapi.models.interfaces.Statistics; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | 9 | import java.util.List; 10 | 11 | public interface MetricService { 12 | Metric createMetric(Metric metric); 13 | 14 | Page getMetricNames(Pageable pageable); 15 | 16 | Statistics getSummaryStatistics(long metricId, List statisticNames); 17 | } 18 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/GreetingHandler.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.reactive.function.BodyInserters; 6 | import org.springframework.web.reactive.function.server.ServerRequest; 7 | import org.springframework.web.reactive.function.server.ServerResponse; 8 | import reactor.core.publisher.Mono; 9 | 10 | @Component 11 | public class GreetingHandler { 12 | 13 | public Mono hello(ServerRequest request) { 14 | return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) 15 | .body(BodyInserters.fromValue("Hello, Spring!")); 16 | } 17 | } -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/kotlin/com/eprogrammerz/examples/controllers/CustomerController.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers 2 | 3 | import com.eprogrammerz.examples.repositories.CustomerRepository 4 | import org.springframework.web.bind.annotation.GetMapping 5 | import org.springframework.web.bind.annotation.PathVariable 6 | import org.springframework.web.bind.annotation.RestController 7 | 8 | /** 9 | * Created by Yogen on 9/11/2017. 10 | */ 11 | @RestController 12 | class CustomerController(val customerRepository: CustomerRepository) { 13 | @GetMapping("/") 14 | fun findAll() = customerRepository.findAll(); 15 | 16 | @GetMapping("/{name}") 17 | fun findByLastName(@PathVariable name: String) = customerRepository.findByLastName(name) 18 | } -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to np-app!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | })); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/common/ErrorCodes.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | 5 | public enum ErrorCodes { 6 | EXC400("INVALID INPUT"), 7 | EXC401("UNAUTHORIZED"), 8 | EXC404("NOT FOUND"), 9 | EXC409("ALREADY EXISTS"); 10 | 11 | private final String value; 12 | 13 | ErrorCodes(final String value) { 14 | this.value = value; 15 | } 16 | /** 17 | * Get enum value. 18 | * 19 | * @return Enum value 20 | */ 21 | @JsonValue 22 | public String getValue() { 23 | return value; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-mvc-annotation/src/main/java/com/eprogrammerz/examples/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | 9 | /** 10 | * Created by 542596 on 2/12/2017. 11 | */ 12 | @Slf4j 13 | @Controller 14 | @RequestMapping("/") 15 | public class HomeController { 16 | @RequestMapping(method = RequestMethod.GET) 17 | public String index(Model model) { 18 | log.info("index()"); 19 | model.addAttribute("msg", "Welcom to the Spring MVC Application!!!"); 20 | return "index"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | 9 | /** 10 | * Created by 542596 on 2/12/2017. 11 | */ 12 | @Slf4j 13 | @Controller 14 | @RequestMapping("/") 15 | public class HomeController { 16 | 17 | @RequestMapping(method = RequestMethod.GET) 18 | public String index(Model model) { 19 | log.info("index()"); 20 | model.addAttribute("msg", "Welcom to the Spring MVC Application!!!"); 21 | return "index"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/domains/Address.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.domains; 2 | 3 | import javax.validation.constraints.Min; 4 | import javax.validation.constraints.NotNull; 5 | import javax.validation.constraints.Pattern; 6 | import javax.validation.constraints.Size; 7 | 8 | import org.hibernate.validator.constraints.NotEmpty; 9 | 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | import lombok.ToString; 13 | 14 | @Getter 15 | @Setter 16 | @ToString 17 | public class Address { 18 | 19 | @NotEmpty @NotNull 20 | private String street; 21 | 22 | @NotEmpty @NotNull 23 | private String city; 24 | 25 | @NotEmpty @NotNull @Size(min = 2, max = 2) 26 | private String state; 27 | 28 | @Pattern(regexp = "[1-9]\\d{4}") 29 | private String zip; 30 | } 31 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/domains/User.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.domains; 2 | 3 | import java.util.Date; 4 | 5 | import javax.validation.Valid; 6 | import javax.validation.constraints.Min; 7 | import javax.validation.constraints.NotNull; 8 | import javax.validation.constraints.Past; 9 | 10 | import org.hibernate.validator.constraints.NotEmpty; 11 | 12 | import lombok.Getter; 13 | import lombok.Setter; 14 | import lombok.ToString; 15 | 16 | @Getter 17 | @Setter 18 | @ToString 19 | public class User { 20 | @NotEmpty @NotNull 21 | private String firstName; 22 | 23 | @NotEmpty @NotNull 24 | private String lastName; 25 | 26 | @Min(1) 27 | private int age; 28 | 29 | @Past 30 | private Date dateOfBirth; 31 | 32 | @Valid 33 | private Address address; 34 | } 35 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | /node 11 | 12 | # profiling files 13 | chrome-profiler-events.json 14 | speed-measure-plugin.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/eprogrammerz/examples/spring/springbootjsp/SpringBootJspApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springbootjsp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 7 | 8 | @SpringBootApplication 9 | public class SpringBootJspApplication extends SpringBootServletInitializer { 10 | @Override 11 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 12 | return application.sources(SpringBootJspApplication.class); 13 | } 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(SpringBootJspApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/log4j2.yml: -------------------------------------------------------------------------------- 1 | Configuration: 2 | status: info 3 | 4 | Appenders: 5 | Console: 6 | - name: Console 7 | target: SYSTEM_OUT 8 | PatternLayout: 9 | Pattern: "%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n" 10 | File: 11 | - name: File 12 | fileName: /logs/logfile.log 13 | PatternLayout: 14 | Pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" 15 | 16 | Loggers: 17 | Root: 18 | level: info 19 | AppenderRef: 20 | - ref: Console 21 | 22 | # begin Application Logging 23 | Logger: 24 | - name: com.eprogrammerz.examples 25 | level: trace 26 | additivity: false 27 | AppenderRef: 28 | - ref: Console 29 | level: trace 30 | - ref: File 31 | level: trace -------------------------------------------------------------------------------- /spring-trasaction/src/main/java/com/eprogrammerz/examples/spring/springtrasaction/ThreadConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springtrasaction; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.core.task.TaskExecutor; 6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 7 | 8 | @Configuration 9 | public class ThreadConfig { 10 | @Bean 11 | public TaskExecutor taskExecutor() { 12 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 13 | executor.setCorePoolSize(4); 14 | executor.setMaxPoolSize(10); 15 | executor.setQueueCapacity(25); 16 | executor.setThreadNamePrefix("st_task_executor_thread"); 17 | executor.initialize(); 18 | 19 | return executor; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/log4j2-dev.yml: -------------------------------------------------------------------------------- 1 | Configuration: 2 | status: info 3 | 4 | Appenders: 5 | Console: 6 | - name: Console 7 | target: SYSTEM_OUT 8 | PatternLayout: 9 | Pattern: "%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n" 10 | File: 11 | - name: File 12 | fileName: /dev/logs/logfile.log 13 | PatternLayout: 14 | Pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" 15 | 16 | Loggers: 17 | Root: 18 | level: info 19 | AppenderRef: 20 | - ref: Console 21 | 22 | # begin Application Logging 23 | Logger: 24 | - name: com.eprogrammerz.examples 25 | level: trace 26 | additivity: false 27 | AppenderRef: 28 | - ref: Console 29 | level: trace 30 | - ref: File 31 | level: trace -------------------------------------------------------------------------------- /spring-exception-handling/src/main/resources/log4j2-local.yml: -------------------------------------------------------------------------------- 1 | Configuration: 2 | status: info 3 | 4 | Appenders: 5 | Console: 6 | - name: Console 7 | target: SYSTEM_OUT 8 | PatternLayout: 9 | Pattern: "%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n" 10 | File: 11 | - name: File 12 | fileName: /logs/logfile.log 13 | PatternLayout: 14 | Pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" 15 | 16 | Loggers: 17 | Root: 18 | level: info 19 | AppenderRef: 20 | - ref: Console 21 | 22 | # begin Application Logging 23 | Logger: 24 | - name: com.eprogrammerz.examples 25 | level: trace 26 | additivity: false 27 | AppenderRef: 28 | - ref: Console 29 | level: trace 30 | - ref: File 31 | level: trace -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/models/Role.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.models; 2 | 3 | import javax.persistence.*; 4 | import javax.validation.constraints.NotNull; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | import lombok.ToString; 11 | 12 | import java.util.List; 13 | 14 | @Getter 15 | @Setter 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @ToString 19 | 20 | @Entity 21 | @Table(name = "ROLE") 22 | public class Role { 23 | 24 | @Id 25 | @Column(name = "ID") 26 | @GeneratedValue(strategy = GenerationType.AUTO) 27 | private Long id; 28 | 29 | @Column(name = "NAME", length = 50) 30 | @NotNull 31 | @Enumerated(EnumType.STRING) 32 | private RoleType name; 33 | 34 | } -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/model/JwtAuthenticationToken.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security.model; 2 | 3 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 4 | 5 | import lombok.Getter; 6 | 7 | /** 8 | * Holder for JWT token from the request. 9 | * 10 | * @author Yogen 11 | * 12 | */ 13 | @Getter 14 | public class JwtAuthenticationToken extends UsernamePasswordAuthenticationToken { 15 | 16 | private final String token; 17 | 18 | public JwtAuthenticationToken(String token) { 19 | super(null, null); 20 | this.token = token; 21 | } 22 | 23 | @Override 24 | public Object getCredentials() { 25 | return null; 26 | } 27 | 28 | @Override 29 | public Object getPrincipal() { 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-angular/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.eprogrammerz.examples.springangular 5 | spring-angular 6 | 0.0.1 7 | pom 8 | 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 2.1.2.RELEASE 14 | 15 | 16 | 17 | 18 | sprular-server 19 | sprular-web 20 | 21 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/config/MessageSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.support.MessageSourceAccessor; 6 | import org.springframework.context.support.ReloadableResourceBundleMessageSource; 7 | 8 | @Configuration 9 | public class MessageSourceConfig { 10 | 11 | @Bean 12 | public ReloadableResourceBundleMessageSource messageSource() { 13 | ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); 14 | source.setBasenames("classpath:messages"); 15 | return source; 16 | } 17 | 18 | @Bean 19 | public MessageSourceAccessor messageSourceAccessor() { 20 | return new MessageSourceAccessor(messageSource()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/java/com/eprogrammerz/examples/springangular/controllers/HeroController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular.controllers; 2 | 3 | import com.eprogrammerz.examples.springangular.models.Hero; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @RestController 12 | @RequestMapping("/api") 13 | public class HeroController { 14 | @GetMapping("/heroes") 15 | public List getHeroes() { 16 | List heroes = new ArrayList<>(); 17 | heroes.add(new Hero("Yogen", "3.5")); 18 | heroes.add(new Hero("Ramesh", "4.5")); 19 | heroes.add(new Hero("Prateema", "3.7")); 20 | 21 | return heroes; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/config/MessageSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.validation.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.support.MessageSourceAccessor; 6 | import org.springframework.context.support.ReloadableResourceBundleMessageSource; 7 | 8 | @Configuration 9 | public class MessageSourceConfig { 10 | 11 | @Bean 12 | public ReloadableResourceBundleMessageSource messageSource() { 13 | ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); 14 | source.setBasenames("classpath:messages"); 15 | return source; 16 | } 17 | 18 | @Bean 19 | public MessageSourceAccessor messageSourceAccessor() { 20 | return new MessageSourceAccessor(messageSource()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/config/MessageSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.support.MessageSourceAccessor; 6 | import org.springframework.context.support.ReloadableResourceBundleMessageSource; 7 | 8 | @Configuration 9 | public class MessageSourceConfig { 10 | 11 | @Bean 12 | public ReloadableResourceBundleMessageSource messageSource() { 13 | ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); 14 | source.setBasenames("classpath:messages"); 15 | return source; 16 | } 17 | 18 | @Bean 19 | public MessageSourceAccessor messageSourceAccessor() { 20 | return new MessageSourceAccessor(messageSource()); 21 | } 22 | } -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/models/Car.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.validation.models; 5 | 6 | import javax.validation.constraints.Min; 7 | import javax.validation.constraints.NotNull; 8 | import javax.validation.constraints.Size; 9 | 10 | import com.eprogrammerz.examples.validation.validators.enumValidator.CheckCase; 11 | 12 | import lombok.Getter; 13 | import lombok.Setter; 14 | import lombok.ToString; 15 | 16 | import com.eprogrammerz.examples.validation.models.types.CaseMode; 17 | 18 | /** 19 | * @author Yogen 20 | * 21 | */ 22 | @Getter 23 | @Setter 24 | @ToString 25 | public class Car { 26 | @NotNull 27 | private String manufacturer; 28 | 29 | @NotNull 30 | @Size(min = 2, max = 14) 31 | @CheckCase(enumClass = CaseMode.class) 32 | private String licensePlate; 33 | 34 | @Min(2) 35 | private int seatCount; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/JwtAuthenticationSuccessHandler.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 11 | 12 | /** 13 | * @author Yogen 14 | * 15 | */ 16 | public class JwtAuthenticationSuccessHandler implements AuthenticationSuccessHandler { 17 | 18 | @Override 19 | public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) 20 | throws IOException, ServletException { 21 | // no need implementation as no redirect required 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/Application.java: -------------------------------------------------------------------------------- 1 | package com.eShop; 2 | 3 | import com.eShop.domain.Product; 4 | import com.eShop.service.IProductService; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.support.ClassPathXmlApplicationContext; 7 | 8 | public class Application { 9 | public static void main(String[] args) { 10 | ApplicationContext context = new ClassPathXmlApplicationContext("springconfig.xml"); 11 | 12 | IProductService productService = context.getBean("productService", IProductService.class); 13 | 14 | Product product1 = productService.getProduct(423); 15 | if (product1 != null) { 16 | System.out.println(product1); 17 | } 18 | Product product2 = productService.getProduct(239); 19 | if (product2 != null) { 20 | System.out.println(product2); 21 | } 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/domain/Product.java: -------------------------------------------------------------------------------- 1 | package com.eShop.domain; 2 | 3 | public class Product { 4 | private int productNumber; 5 | private String name; 6 | private double price; 7 | 8 | public Product(int productNumber,String name,double price){ 9 | this.productNumber=productNumber; 10 | this.name=name; 11 | this.price=price; 12 | } 13 | public String getName() { 14 | return name; 15 | } 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | public double getPrice() { 20 | return price; 21 | } 22 | public void setPrice(double price) { 23 | this.price = price; 24 | } 25 | public int getProductNumber() { 26 | return productNumber; 27 | } 28 | public void setProductNumber(int productNumber) { 29 | this.productNumber = productNumber; 30 | } 31 | public String toString(){ 32 | return "[ Product number = "+productNumber+", name = "+name+", price = "+price+"]"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/domain/Product.java: -------------------------------------------------------------------------------- 1 | package com.eShop.domain; 2 | 3 | public class Product { 4 | private int productNumber; 5 | private String name; 6 | private double price; 7 | 8 | public Product(int productNumber,String name,double price){ 9 | this.productNumber=productNumber; 10 | this.name=name; 11 | this.price=price; 12 | } 13 | public String getName() { 14 | return name; 15 | } 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | public double getPrice() { 20 | return price; 21 | } 22 | public void setPrice(double price) { 23 | this.price = price; 24 | } 25 | public int getProductNumber() { 26 | return productNumber; 27 | } 28 | public void setProductNumber(int productNumber) { 29 | this.productNumber = productNumber; 30 | } 31 | public String toString(){ 32 | return "[ Product number = "+productNumber+", name = "+name+", price = "+price+"]"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/repositories/MetricEntryRepository.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.repositories; 2 | 3 | import com.company.dpt.metric.api.metricapi.models.core.MetricEntry; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | 8 | public interface MetricEntryRepository extends JpaRepository { 9 | @Query("SELECT max(ME.value) FROM MetricEntry ME WHERE ME.metric.id=:metricId") 10 | Double findMax(@Param("metricId") long metricId); 11 | 12 | @Query("SELECT min(ME.value) FROM MetricEntry ME WHERE ME.metric.id=:metricId") 13 | Double findMin(@Param("metricId") long metricId); 14 | 15 | @Query("SELECT avg(ME.value) FROM MetricEntry ME WHERE ME.metric.id=:metricId") 16 | Double findAverage(@Param("metricId") long metricId); 17 | } 18 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/GreetingRouter.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.http.MediaType; 6 | import org.springframework.web.reactive.function.server.RequestPredicates; 7 | import org.springframework.web.reactive.function.server.RouterFunction; 8 | import org.springframework.web.reactive.function.server.RouterFunctions; 9 | import org.springframework.web.reactive.function.server.ServerResponse; 10 | 11 | @Configuration 12 | public class GreetingRouter { 13 | @Bean 14 | public RouterFunction route(GreetingHandler greetingHandler) { 15 | return RouterFunctions.route( 16 | RequestPredicates.GET("/hello") 17 | .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), greetingHandler::hello); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-angular/sprular-server/src/main/java/com/eprogrammerz/examples/springangular/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springangular.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 8 | 9 | @Configuration 10 | public class CorsConfig { 11 | 12 | @Bean 13 | public WebMvcConfigurer corsConfigurer() { 14 | return new WebMvcConfigurerAdapter() { 15 | @Override 16 | public void addCorsMappings(CorsRegistry registry) { 17 | registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*") 18 | .allowedHeaders("*"); 19 | } 20 | }; 21 | } 22 | } -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/kotlin/com/eprogrammerz/examples/config/SwaggerConfig.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.config 2 | 3 | import org.springframework.context.annotation.Bean 4 | import org.springframework.context.annotation.Configuration 5 | import springfox.documentation.builders.PathSelectors 6 | import springfox.documentation.builders.RequestHandlerSelectors 7 | import springfox.documentation.spi.DocumentationType 8 | import springfox.documentation.spring.web.plugins.Docket 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2 10 | 11 | /** 12 | * Created by Yogen on 9/11/2017. 13 | */ 14 | @Configuration 15 | @EnableSwagger2 16 | class SwaggerConfig { 17 | @Bean 18 | fun api(): Docket { 19 | return Docket(DocumentationType.SWAGGER_2) 20 | .select() 21 | .apis(RequestHandlerSelectors.basePackage("com.eprogrammerz.examples.controllers")) 22 | .paths(PathSelectors.any()) 23 | .build(); 24 | } 25 | } -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/manifest.yml: -------------------------------------------------------------------------------- 1 | #helpful commands 2 | #cf marketplace 3 | #cleardb spark, boost*, amp*, shock* 4 | # 5 | #cf create-service cleardb spark MY-DB 6 | #now, update mainfest.yml with new service 7 | # 8 | #cf push YOUR-HOST-APP 9 | #cf enable-ssh YOUR-HOST-APP 10 | # 11 | #ssh to your app 12 | #cf ssh YOUR-HOST-APP 13 | # 14 | #ssh to your service 15 | #1. generate key 16 | #cf create-service-key MY-DB EXTERNAL-ACCESS-KEY 17 | #2. copy key 18 | #cf service-key MY-DB EXTERNAL-ACCESS-KEY 19 | #3 (a) ssh tunnel 20 | #cf ssh -L 63306:us-cdbr-iron-east-01.cleardb.net:3306 YOUR-HOST-APP 21 | #3 (b) direct connect 22 | #mysql -u b5136e448be920 -h 0 -p -D ad_b2fca6t49704585d -P 63306 23 | 24 | --- 25 | applications: 26 | - name: spring-cf 27 | memory: 1024M 28 | instances: 1 29 | random-route: false 30 | path: target/spring-boot-cloud-foundry-0.0.1-SNAPSHOT.jar 31 | buildpacks: 32 | - https://github.com/cloudfoundry/java-buildpack.git 33 | services: 34 | - mysql -------------------------------------------------------------------------------- /spring-boot-camel/src/main/java/com/eprogrammerz/examples/apacheCamel/config/CamelConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.apacheCamel.config; 2 | 3 | import org.apache.camel.component.servlet.CamelHttpTransportServlet; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * Created by Yogen on 10/8/2017. 11 | */ 12 | @Configuration 13 | public class CamelConfig { 14 | @Value("${api.path}") 15 | private String contextPath; 16 | 17 | @Bean 18 | public ServletRegistrationBean servletRegistrationBean() { 19 | ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean( 20 | new CamelHttpTransportServlet(), contextPath + "/*"); 21 | servletRegistrationBean.setName("CamelServlet"); 22 | return servletRegistrationBean; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfiguration { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.basePackage("com.company.dpt.metric.api.metricapi.controllers")) 20 | .paths(PathSelectors.ant("/**")) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /spring-kotlin-demo/src/main/kotlin/com/eprogrammerz/examples/KotlinDemoApplication.kt: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples 2 | 3 | import com.eprogrammerz.examples.models.Customer 4 | import com.eprogrammerz.examples.repositories.CustomerRepository 5 | import org.springframework.boot.CommandLineRunner 6 | import org.springframework.boot.SpringApplication 7 | import org.springframework.boot.autoconfigure.SpringBootApplication 8 | import org.springframework.context.annotation.Bean 9 | 10 | @SpringBootApplication 11 | class KotlinDemoApplication { 12 | @Bean 13 | fun init(customerRepository: CustomerRepository) = CommandLineRunner { 14 | customerRepository.save(Customer("Yogen", "Rai")) 15 | customerRepository.save(Customer("Gogen", "Gurung")) 16 | customerRepository.save(Customer("Yogesh", "Bhattrai")) 17 | customerRepository.save(Customer("Yogendra", "Rai")) 18 | } 19 | } 20 | 21 | fun main(args: Array) { 22 | SpringApplication.run(KotlinDemoApplication::class.java, *args) 23 | } 24 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/models/Taco.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.models; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.couchbase.core.mapping.Document; 6 | import org.springframework.data.couchbase.core.mapping.Field; 7 | import org.springframework.data.couchbase.core.mapping.id.GeneratedValue; 8 | import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy; 9 | import org.springframework.data.couchbase.core.mapping.id.IdAttribute; 10 | 11 | import java.time.LocalDateTime; 12 | import java.util.List; 13 | 14 | @Data 15 | @Document 16 | public class Taco { 17 | @Id 18 | @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES) 19 | private String id; 20 | @Field @IdAttribute 21 | private String name; 22 | @Field @IdAttribute 23 | private LocalDateTime createdAt = LocalDateTime.now(); 24 | 25 | @Field 26 | private List ingredients; 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/java/com/eprogrammerz/examples/bookmarkSvc/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfiguration { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.basePackage("com.eprogrammerz.examples.bookmarkSvc.controllers")) 20 | .paths(PathSelectors.ant("/**")) 21 | .build(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /spring-mvc-xml-demo/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | Spring Web MVC Application 8 | 9 | 10 | mvc-dispatcher 11 | org.springframework.web.servlet.DispatcherServlet 12 | 13 | contextConfigLocation 14 | 15 | /WEB-INF/spring-context/DispatcherServlet-context.xml 16 | 17 | 18 | 1 19 | 20 | 21 | 22 | mvc-dispatcher 23 | / 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-security-oauth-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | facebook: 2 | client: 3 | clientId: 200259380450957 4 | clientSecret: 4a9f2ac6bf97f383ed18bc1b606bce6b 5 | accessTokenUri: https://graph.facebook.com/oauth/access_token 6 | userAuthorizationUri: https://www.facebook.com/dialog/oauth 7 | tokenName: oauth_token 8 | authenticationScheme: query 9 | clientAuthenticationScheme: form 10 | resource: 11 | userInfoUri: https://graph.facebook.com/me 12 | github: 13 | client: 14 | clientId: 110c61f8b178800a3c7a 15 | clientSecret: f5cef5f91d434321ef41be793a933cf454e02d31 16 | accessTokenUri: https://github.com/login/oauth/access_token 17 | userAuthorizationUri: https://github.com/login/oauth/authorize 18 | clientAuthenticationScheme: form 19 | resource: 20 | userInfoUri: https://api.github.com/user 21 | server: 22 | port: 8087 23 | security: 24 | oauth2: 25 | client: 26 | client-id: sse 27 | client-secret: sse-secret 28 | scope: read, write 29 | auto-approve-scopes: '.*' -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring.config; 2 | 3 | import com.google.common.base.Predicates; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SwaggerConfiguration { 15 | 16 | @Bean 17 | public Docket api() { 18 | return new Docket(DocumentationType.SWAGGER_2) 19 | .select() 20 | .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot"))) 21 | .paths(PathSelectors.ant("/**")) 22 | .build(); 23 | } 24 | } -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/models/Ingredient.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.models; 2 | 3 | import lombok.Data; 4 | import lombok.RequiredArgsConstructor; 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.couchbase.core.mapping.Document; 7 | import org.springframework.data.couchbase.core.mapping.Field; 8 | import org.springframework.data.couchbase.core.mapping.id.GeneratedValue; 9 | import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy; 10 | import org.springframework.data.couchbase.core.mapping.id.IdAttribute; 11 | 12 | 13 | @Data 14 | @RequiredArgsConstructor 15 | @Document 16 | public class Ingredient { 17 | @Id 18 | @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES, delimiter = "-") 19 | private final String id; 20 | @Field @IdAttribute 21 | private final String name; 22 | @Field @IdAttribute 23 | private final Type type; 24 | 25 | public enum Type { 26 | WRAP, PROTEIN, CHEESE, SAUCE 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/test/groovy/com/eprogrammerz/examples/bookmarkSvc/controllers/BookmarkControllerTest.groovy: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc.controllers 2 | 3 | import com.eprogrammerz.examples.bookmarkSvc.repositories.BookmarkRepository 4 | import spock.lang.Specification 5 | 6 | class BookmarkControllerTest extends Specification { 7 | 8 | BookmarkController bookmarkController 9 | 10 | BookmarkRepository bookmarkRepository 11 | 12 | void setup() { 13 | bookmarkRepository = Mock() 14 | bookmarkController = new BookmarkController(bookmarkRepository) 15 | } 16 | 17 | def "Get bookmarks with userId" () { 18 | given: 19 | def userId = "yogen" 20 | def bookmarks = [] 21 | bookmarkRepository.findByUserId(userId) >> bookmarks 22 | 23 | when: 24 | def response = bookmarkController.getBookmarks(userId) 25 | 26 | then: 27 | response == [] 28 | 29 | 1 * bookmarkRepository.findByUserId(userId) >> bookmarks 30 | 0 * _ 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/config/CouchbaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.config; 2 | 3 | import lombok.Getter; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Getter 8 | @Configuration 9 | public class CouchbaseConfig { 10 | private String bootstrapperHost; 11 | private String bucketName; 12 | private String username; 13 | private String password; 14 | 15 | public CouchbaseConfig(@Value("${spring.couchbase.bootstrap-host}") String bootstrapperHost, 16 | @Value("${spring.couchbase.bucket-name}") String bucketName, 17 | @Value("${spring.couchbase.username}") String username, 18 | @Value("${spring.couchbase.password}") String password) { 19 | this.bootstrapperHost = bootstrapperHost; 20 | this.bucketName = bucketName; 21 | this.username = username; 22 | this.password = password; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/config/PropertiesConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.config; 2 | 3 | import com.eprogrammerz.examples.exception.ResourceException; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.annotation.PostConstruct; 9 | 10 | /** 11 | * Created by 542596 on 3/16/2017. 12 | */ 13 | @Component 14 | public class PropertiesConfigurer { 15 | @Value("${properties.path}") 16 | private String propertiesFilePath; 17 | 18 | @Autowired 19 | private DynamicEnvironmentProperties dynamicEnvironmentProperties; 20 | 21 | public PropertiesConfigurer() { 22 | 23 | } 24 | 25 | @PostConstruct 26 | public void loadProperties() { 27 | try { 28 | dynamicEnvironmentProperties.loadProperties(propertiesFilePath); 29 | } catch (ResourceException e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-metric-api/src/main/java/com/company/dpt/metric/api/metricapi/models/interfaces/Statistics.java: -------------------------------------------------------------------------------- 1 | package com.company.dpt.metric.api.metricapi.models.interfaces; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | @JsonInclude(JsonInclude.Include.NON_NULL) 6 | public class Statistics { 7 | private Double mean; 8 | private Double median; 9 | private Double max; 10 | private Double min; 11 | 12 | public void setMean(Double mean) { 13 | this.mean = mean; 14 | } 15 | 16 | public void setMedian(Double median) { 17 | this.median = median; 18 | } 19 | 20 | public void setMax(Double max) { 21 | this.max = max; 22 | } 23 | 24 | public void setMin(Double min) { 25 | this.min = min; 26 | } 27 | 28 | public Double getMean() { 29 | return mean; 30 | } 31 | 32 | public Double getMedian() { 33 | return median; 34 | } 35 | 36 | public Double getMax() { 37 | return max; 38 | } 39 | 40 | public Double getMin() { 41 | return min; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplicationDI/src/com/eShop/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.eShop.repository; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by rajkumar on 6/3/2016. 12 | */ 13 | public class ProductRepository implements IProductRepository { 14 | 15 | private Collection productList; 16 | 17 | public ProductRepository(){ 18 | productList = new ArrayList(){ 19 | { 20 | add(new Product(234,"LCD TV", 895.50)); 21 | add(new Product(239,"DVD player", 315.00)); 22 | add(new Product(423,"Plasma TV", 992.55)); 23 | } 24 | }; 25 | } 26 | 27 | 28 | @Override 29 | public Product findOne(int productNumber) { 30 | for (Product product : productList) { 31 | if (product.getProductNumber() == productNumber) 32 | return product; 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/models/Order.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.models; 2 | 3 | import lombok.Data; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.couchbase.core.mapping.Document; 6 | import org.springframework.data.couchbase.core.mapping.Field; 7 | import org.springframework.data.couchbase.core.mapping.id.GeneratedValue; 8 | import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy; 9 | import org.springframework.data.couchbase.core.mapping.id.IdAttribute; 10 | 11 | import java.time.LocalDateTime; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | @Data 16 | @Document 17 | public class Order { 18 | @Id 19 | @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES) 20 | private String id; 21 | 22 | @Field 23 | @IdAttribute 24 | private LocalDateTime createdAt = LocalDateTime.now(); 25 | 26 | private List tacos = new ArrayList<>(); 27 | 28 | public void addDesign(Taco design) { 29 | this.tacos.add(design); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/JwtAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security; 2 | 3 | import java.io.IOException; 4 | import java.io.Serializable; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.springframework.security.core.AuthenticationException; 11 | import org.springframework.security.web.AuthenticationEntryPoint; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * @author Yogen 16 | * 17 | */ 18 | @Component 19 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable { 20 | 21 | private static final long serialVersionUID = -3676716105442039003L; 22 | 23 | @Override 24 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) 25 | throws IOException, ServletException { 26 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import {Component} from '@angular/core'; 2 | import {Hero} from "./Hero"; 3 | import {HeroService} from "./heros.service"; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: ` 8 | 9 |
10 |

11 | Welcome to {{title}}! 12 |

13 |
14 |

Here are Heros:

15 |
    16 |
  • 17 |

    {{hero.name}}

    18 |

    {{hero.rating}}

    19 |
  • 20 |
21 | 22 | `, 23 | styleUrls: ['./app.component.css'] 24 | }) 25 | export class AppComponent { 26 | title = 'Sprular App'; 27 | 28 | heroes: Hero[]; 29 | 30 | constructor(private heroService: HeroService) {} 31 | 32 | ngOnInit() { 33 | this.getHeroes(); 34 | } 35 | 36 | getHeroes(): void { 37 | this.heroService.getHeroes().subscribe((heroes: Hero[]) => { 38 | this.heroes = heroes; 39 | console.log(this.heroes); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /spring-dependency-injection/ProductApplication/src/com/eShop/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.eShop.repository; 2 | 3 | import com.eShop.domain.Product; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by rajkumar on 6/3/2016. 12 | */ 13 | public class ProductRepository implements IProductRepository { 14 | 15 | //list to hold the products 16 | private Collection productList; 17 | public ProductRepository(){ 18 | //initialize list with products 19 | productList = new ArrayList(){ 20 | { 21 | add(new Product(234,"LCD TV", 895.50)); 22 | add(new Product(239,"DVD player", 315.00)); 23 | add(new Product(423,"Plasma TV", 992.55)); 24 | } 25 | }; 26 | } 27 | 28 | @Override 29 | public Product findOne(int productNumber) { 30 | for (Product product : productList) { 31 | if (product.getProductNumber() == productNumber) 32 | return product; 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-exception-handling/src/main/java/com/eprogrammerz/examples/rest/controllers/UserController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.rest.controllers; 2 | 3 | import javax.validation.Valid; 4 | 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import com.eprogrammerz.examples.rest.domains.User; 13 | import com.eprogrammerz.examples.rest.exceptions.DataException; 14 | 15 | import lombok.extern.slf4j.Slf4j; 16 | 17 | @Slf4j 18 | @RestController 19 | public class UserController { 20 | 21 | @PostMapping(value = "/users") 22 | public ResponseEntity createUser(@Valid @RequestBody User user, BindingResult bindingResult) { 23 | if(bindingResult.hasErrors()) { 24 | throw new DataException("Invalid Input", bindingResult); 25 | } 26 | log.info("Input user is: {}", user.toString()); 27 | return new ResponseEntity<>(HttpStatus.CREATED); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/README.md: -------------------------------------------------------------------------------- 1 | # NpApp 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /spring-mvc-xml-demo/src/main/webapp/WEB-INF/spring-context/DispatcherServlet-context.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | /WEB-INF/pages/ 17 | 18 | 19 | .jsp 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Stephan Zerhusen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/controllers/TacoController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.controllers; 2 | 3 | import com.eprogrammez.examples.webflux.models.Taco; 4 | import com.eprogrammez.examples.webflux.repositories.TacoRepository; 5 | import lombok.RequiredArgsConstructor; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.web.bind.annotation.*; 8 | import reactor.core.publisher.Flux; 9 | import reactor.core.publisher.Mono; 10 | 11 | @RequiredArgsConstructor 12 | @RestController 13 | @CrossOrigin(origins = "*") 14 | @RequestMapping("/tacos") 15 | public class TacoController { 16 | private final TacoRepository tacoRepository; 17 | 18 | @GetMapping("/recent") 19 | public Flux recentTacos() { 20 | return tacoRepository.findAll().take(12); 21 | } 22 | 23 | @GetMapping("/{id}") 24 | public Mono tacoById(@PathVariable String id) { 25 | return tacoRepository.findById(id); 26 | } 27 | 28 | @PostMapping 29 | @ResponseStatus(HttpStatus.CREATED) 30 | public Mono createTaco(@RequestBody Mono tacoMono) { 31 | return tacoRepository.saveAll(tacoMono).next(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import org.springframework.scheduling.annotation.Scheduled; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * Created by 542596 on 3/9/2017. 9 | */ 10 | @RestController 11 | public class HomeController { 12 | // @Value("${comparisonChart.file.name}") 13 | // private String comparisonChartFileName = System.getProperty("comparisonChart.file.name"); 14 | 15 | @RequestMapping("/") 16 | public String home() { 17 | String property = System.getProperty("key1"); 18 | String comparisonChartFileName = System.getProperty("comparisonChart.file.name"); 19 | String comparisonChartFile = System.getProperty("comparisonChart.file"); 20 | return "HOME Page --> key1 = " + property + ", comparison chart file name: " + comparisonChartFileName + ", comparison chart file: " + comparisonChartFile; 21 | } 22 | 23 | @Scheduled(fixedRateString = "${refresh.rate}") 24 | public void fixedTask() { 25 | System.out.println("Time changed..."); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/java/com/eprogrammerz/examples/bookmarkSvc/models/Bookmark.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc.models; 2 | 3 | import com.eprogrammerz.examples.bookmarkSvc.models.types.BookmarkType; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import javax.persistence.ElementCollection; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by Yogen on 9/26/2017. 16 | */ 17 | @Entity 18 | @Getter 19 | @Setter 20 | @NoArgsConstructor 21 | public class Bookmark { 22 | private String userId; 23 | 24 | @Id 25 | @GeneratedValue 26 | private Long id; 27 | 28 | private String href; 29 | 30 | private String description; 31 | 32 | private String label; 33 | 34 | @ElementCollection(targetClass = BookmarkType.class) 35 | private List bookmarkTypes; 36 | 37 | public Bookmark(String userId, String href, 38 | String description, String label) { 39 | this.userId = userId; 40 | this.href = href; 41 | this.description = description; 42 | this.label = label; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/controller/MethodProtectedRestController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.controller; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.security.access.prepost.PreAuthorize; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @RequestMapping("protected") 11 | public class MethodProtectedRestController { 12 | 13 | /** 14 | * This is an example of some different kinds of granular restriction for endpoints. You can use the built-in SPEL expressions 15 | * in @PreAuthorize such as 'hasRole()' to determine if a user has access. Remember that the hasRole expression assumes a 16 | * 'ROLE_' prefix on all role names. So 'ADMIN' here is actually stored as 'ROLE_ADMIN' in database! 17 | **/ 18 | @RequestMapping(method = RequestMethod.GET) 19 | @PreAuthorize("hasRole('ADMIN')") 20 | public ResponseEntity getProtectedGreeting() { 21 | return ResponseEntity.ok("Greetings from admin protected method!"); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/utils/JwtTokenGenerator.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security.utils; 2 | 3 | 4 | import com.eprogrammerz.examples.security.security.model.JwtUserDto; 5 | 6 | import io.jsonwebtoken.Claims; 7 | import io.jsonwebtoken.Jwts; 8 | import io.jsonwebtoken.SignatureAlgorithm; 9 | 10 | /** 11 | * @author Yogen 12 | * 13 | */ 14 | public class JwtTokenGenerator { 15 | /** 16 | * Generates a JWT token containing username as subject, and userId and role as additional claims. 17 | * These properties are taken from the specified user object. 18 | * Tokens validity is infinite. 19 | * 20 | * @param u the user for which the token will be generated 21 | * @return the JWT token 22 | */ 23 | public static String generateToken(JwtUserDto u, String secret) { 24 | Claims claims = Jwts.claims().setSubject(u.getUsername()); 25 | claims.put("userId", u.getId() + ""); 26 | claims.put("role", u.getRole()); 27 | 28 | return Jwts.builder() 29 | .setClaims(claims) 30 | .signWith(SignatureAlgorithm.HS512, secret) 31 | .compact(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/java/com/eprogrammerz/examples/bookmarkSvc/models/types/BookmarkType.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc.models.types; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum BookmarkType { 7 | GENERAL("general"), 8 | COMPLEX("complex"); 9 | 10 | private final String value; 11 | 12 | /** 13 | * Internal constructor. 14 | * 15 | * @param value Enum value 16 | */ 17 | BookmarkType(final String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonCreator 22 | public static BookmarkType forValue(final String value) { 23 | for (BookmarkType bookmarkType : values()) { 24 | if (bookmarkType.value.equalsIgnoreCase(value)) { 25 | return bookmarkType; 26 | } 27 | } 28 | throw new IllegalArgumentException("No matching constant for [" + value + "]"); 29 | } 30 | 31 | /** 32 | * Get enum value. 33 | * 34 | * @return Enum value 35 | */ 36 | @JsonValue 37 | public String getValue() { 38 | return value; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return value; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-cloud-foundry/src/main/java/com/eprogrammerz/examples/bookmarkSvc/BookmarkServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.bookmarkSvc; 2 | 3 | import com.eprogrammerz.examples.bookmarkSvc.models.Bookmark; 4 | import com.eprogrammerz.examples.bookmarkSvc.repositories.BookmarkRepository; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | import java.util.Arrays; 11 | 12 | @SpringBootApplication 13 | public class BookmarkServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(BookmarkServiceApplication.class, args); 17 | } 18 | 19 | @Bean 20 | CommandLineRunner init(BookmarkRepository bookmarkRepository) { 21 | return args -> { 22 | bookmarkRepository.deleteAll(); 23 | 24 | Arrays.asList("yogen", "dipa").forEach(n -> 25 | bookmarkRepository.save(new Bookmark(n, 26 | "http://some-other-host" + n + ".com/", 27 | "A description for " + n + "'s link", 28 | n))); 29 | }; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | })); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.debugElement.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'np-app'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.debugElement.componentInstance; 26 | expect(app.title).toEqual('np-app'); 27 | }); 28 | 29 | it('should render title in a h1 tag', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.debugElement.nativeElement; 33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to np-app!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/service/JwtUserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.core.userdetails.UserDetails; 5 | import org.springframework.security.core.userdetails.UserDetailsService; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.eprogrammerz.examples.security.models.User; 10 | import com.eprogrammerz.examples.security.repository.UserRepository; 11 | 12 | /** 13 | * Created by stephan on 20.03.16. 14 | */ 15 | @Service 16 | public class JwtUserDetailsServiceImpl implements UserDetailsService { 17 | 18 | @Autowired 19 | private UserRepository userRepository; 20 | 21 | @Override 22 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 23 | User user = userRepository.findByUsername(username); 24 | 25 | if (user == null) { 26 | throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username)); 27 | } else { 28 | return null; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/config/PropertyParts.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.config; 2 | 3 | public class PropertyParts { 4 | 5 | private S1 one; 6 | private S2 two; 7 | private S3 three; 8 | 9 | PropertyParts(S1 one, S2 two, S3 three) { 10 | this.one = one; 11 | this.two = two; 12 | this.three = three; 13 | } 14 | 15 | public S1 getPartOne() { 16 | return this.one; 17 | } 18 | 19 | public S2 getPartTwo() { 20 | return this.two; 21 | } 22 | 23 | public S3 getPartThree() { 24 | return this.three; 25 | } 26 | 27 | public void setPartOne(S1 one) { 28 | this.one = one; 29 | } 30 | 31 | public void setPartTwo(S2 two) { 32 | this.two = two; 33 | } 34 | 35 | public void setPartThree(S3 three) { 36 | this.three = three; 37 | } 38 | 39 | @Override 40 | public int hashCode() { 41 | return one.hashCode() ^ two.hashCode() ^ three.hashCode(); 42 | } 43 | 44 | @Override 45 | public boolean equals(Object o) { 46 | if ((o instanceof PropertyParts)) { 47 | @SuppressWarnings("unchecked") 48 | PropertyParts parto = (PropertyParts) o; 49 | return this.one.equals(parto.getPartOne()) && this.two.equals(parto.getPartTwo()) 50 | && this.three.equals((parto.getPartThree())); 51 | } else { 52 | return false; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-webflux/src/main/java/com/eprogrammez/examples/webflux/config/ReactiveCouchbaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration; 5 | import org.springframework.data.couchbase.repository.config.EnableReactiveCouchbaseRepositories; 6 | 7 | @Configuration 8 | @EnableReactiveCouchbaseRepositories(basePackages = "com.eprogrammez.examples.webflux.repositories") 9 | public class ReactiveCouchbaseConfig extends AbstractCouchbaseConfiguration { 10 | private final CouchbaseConfig couchbaseConfig; 11 | 12 | public ReactiveCouchbaseConfig(CouchbaseConfig couchbaseConfig) { 13 | this.couchbaseConfig = couchbaseConfig; 14 | } 15 | 16 | @Override 17 | public String getConnectionString() { 18 | return couchbaseConfig.getBootstrapperHost(); 19 | } 20 | 21 | @Override 22 | public String getUserName() { 23 | return couchbaseConfig.getUsername(); 24 | } 25 | 26 | @Override 27 | public String getPassword() { 28 | return couchbaseConfig.getPassword(); 29 | } 30 | 31 | @Override 32 | public String getBucketName() { 33 | return couchbaseConfig.getBucketName(); 34 | } 35 | 36 | @Override 37 | protected boolean autoIndexCreation() { 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import com.eprogrammerz.examples.security.models.User; 14 | import com.eprogrammerz.examples.security.repository.UserRepository; 15 | 16 | import java.util.List; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | 20 | @RestController 21 | public class UserController { 22 | 23 | @Value("${jwt.header}") 24 | private String tokenHeader; 25 | 26 | 27 | @Autowired 28 | private UserRepository userRepository; 29 | 30 | @GetMapping("/users") 31 | public ResponseEntity> getUsers() { 32 | List users = this.userRepository.findAll(); 33 | return new ResponseEntity<>(users, HttpStatus.OK); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-activiti/src/main/java/com/eprogrammerz/activiti/hiring/controllers/ApplicantController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.activiti.hiring.controllers; 2 | 3 | import com.eprogrammerz.activiti.hiring.models.Applicant; 4 | import com.eprogrammerz.activiti.hiring.repositories.ApplicantRepository; 5 | import lombok.RequiredArgsConstructor; 6 | import org.activiti.engine.RuntimeService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @RestController 17 | @RequiredArgsConstructor(onConstructor = @_(@Autowired)) 18 | public class ApplicantController { 19 | private final RuntimeService runtimeService; 20 | private final ApplicantRepository applicantRepository; 21 | 22 | @PostMapping(value = "/start-hire-process", consumes= MediaType.APPLICATION_JSON_UTF8_VALUE) 23 | public void startHireProcess(@RequestBody Applicant applicant) { 24 | applicantRepository.save(applicant); 25 | 26 | Map variables = new HashMap<>(); 27 | variables.put("applicant", applicant); 28 | runtimeService.startProcessInstanceByKey("hireProcessWithJpa", variables); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-rest-template/src/main/java/com/eprogrammerz/examples/spring/getToken/GetTokenApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.getToken; 2 | 3 | import com.eprogrammerz.examples.spring.getToken.clients.RemoteServiceClient; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.MediaType; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | @Slf4j 16 | @RestController 17 | @SpringBootApplication 18 | public class GetTokenApplication { 19 | @Autowired 20 | private RemoteServiceClient serviceClient; 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(GetTokenApplication.class, args); 24 | } 25 | 26 | @PostMapping(value = "/login", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) 27 | public ResponseEntity login(@RequestBody String string) throws Exception { 28 | 29 | Object response = this.serviceClient.authenticateToIcon(string); 30 | 31 | log.info("Cookies: {}", response); 32 | return new ResponseEntity<>(HttpStatus.OK); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/security/utils/JwtTokenValidator.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.security.utils; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | import com.eprogrammerz.examples.security.security.model.JwtUserDto; 7 | 8 | import io.jsonwebtoken.Claims; 9 | import io.jsonwebtoken.JwtException; 10 | import io.jsonwebtoken.Jwts; 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | /** 14 | * @author Yogen 15 | * 16 | */ 17 | @Slf4j 18 | @Component 19 | public class JwtTokenValidator { 20 | 21 | @Value("${jwt.secret}") 22 | private String secret; 23 | 24 | /** 25 | * 26 | * @param token the JWT token to parse 27 | * @return the User object extracted from specified token or null if a token 28 | * is invalid. 29 | */ 30 | public JwtUserDto parseToken(String token) { 31 | JwtUserDto u = null; 32 | 33 | try { 34 | Claims body = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); 35 | 36 | u = new JwtUserDto((String) body.get("userId"), body.getSubject(), (String) body.get("role")); 37 | 38 | } catch (JwtException e) { 39 | // Simply print the exception and null will be returned for the 40 | // userDto 41 | log.error("Exception while parsing token : {}", e); 42 | } 43 | return u; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/validators/enumValidator/CheckCaseValidator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.validation.validators.enumValidator; 5 | 6 | import javax.validation.ConstraintValidator; 7 | import javax.validation.ConstraintValidatorContext; 8 | 9 | import com.eprogrammerz.examples.validation.models.types.CaseMode; 10 | 11 | /** 12 | * @author Yogen 13 | * 14 | */ 15 | public class CheckCaseValidator implements ConstraintValidator { 16 | 17 | private CheckCase caseMode; 18 | 19 | @Override 20 | public void initialize(CheckCase constraintAnnotation) { 21 | this.caseMode = constraintAnnotation; 22 | } 23 | 24 | @Override 25 | public boolean isValid(String object, ConstraintValidatorContext constraintContext) { 26 | if ( object == null ) { 27 | return true; 28 | } 29 | 30 | boolean result = false; 31 | 32 | Object[] enumValues = this.caseMode.enumClass().getEnumConstants(); 33 | 34 | if(enumValues != null) 35 | { 36 | for(Object enumValue:enumValues) 37 | { 38 | if(object.equals(enumValue.toString())) 39 | { 40 | result = true; 41 | break; 42 | } 43 | } 44 | } 45 | 46 | return result; 47 | } 48 | } -------------------------------------------------------------------------------- /spring-dependency-injection/libraries/org.springframework.spring-library-3.0.2.RELEASE.libd: -------------------------------------------------------------------------------- 1 | Library-SymbolicName: org.springframework.spring 2 | Library-Version: 3.0.2.RELEASE 3 | Library-Name: Spring Framework 4 | Import-Bundle: 5 | org.springframework.aop;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 6 | org.springframework.asm;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 7 | org.springframework.aspects;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 8 | org.springframework.beans;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 9 | org.springframework.context;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 10 | org.springframework.context.support;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 11 | org.springframework.core;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 12 | org.springframework.expression;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 13 | org.springframework.jdbc;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 14 | org.springframework.jms;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 15 | org.springframework.orm;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 16 | org.springframework.oxm;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 17 | org.springframework.transaction;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 18 | org.springframework.web;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 19 | org.springframework.web.servlet;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 20 | org.springframework.web.portlet;version="[3.0.2.RELEASE, 3.0.2.RELEASE]", 21 | com.springsource.org.aopalliance;version="[1.0.0, 1.0.0]" 22 | -------------------------------------------------------------------------------- /spring-mvc-annotation/src/main/java/com/eprogrammerz/examples/configuration/ApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.configuration; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | /** 6 | * Created by 542596 on 2/12/2017. 7 | * 8 | * Best way to initialize application context. 9 | */ 10 | public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 11 | protected Class[] getRootConfigClasses() { 12 | return new Class[]{ApplicationConfiguration.class}; 13 | } 14 | 15 | protected Class[] getServletConfigClasses() { 16 | return null; 17 | } 18 | 19 | protected String[] getServletMappings() { 20 | return new String[]{"/"}; 21 | } 22 | } 23 | 24 | /** 25 | * can also be done this way 26 | 27 | public class ApplicationInitializer implements WebApplicationInitializer { 28 | 29 | public void onStartup(ServletContext container) throws ServletException { 30 | 31 | AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); 32 | ctx.register(ApplicationConfiguration.class); 33 | ctx.setServletContext(container); 34 | 35 | ServletRegistration.Dynamic servlet = container.addServlet( 36 | "dispatcher", new DispatcherServlet(ctx)); 37 | 38 | servlet.setLoadOnStartup(1); 39 | servlet.addMapping("/"); 40 | }*/ 41 | -------------------------------------------------------------------------------- /spring-custom-bean-validation/src/main/java/com/eprogrammerz/examples/validation/validators/enumValidator/CheckCase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.eprogrammerz.examples.validation.validators.enumValidator; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | import javax.validation.Constraint; 13 | import javax.validation.Payload; 14 | 15 | 16 | import com.eprogrammerz.examples.validation.models.types.CaseMode; 17 | 18 | 19 | /** 20 | * @author Yogen 21 | * 22 | */ 23 | @Documented 24 | @Constraint(validatedBy = CheckCaseValidator.class) 25 | @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER, 26 | ElementType.CONSTRUCTOR }) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface CheckCase { 29 | String message() default "{org.hibernate.validator.referenceguide.chapter06.CheckCase." + 30 | "message}"; 31 | 32 | Class[] groups() default { }; 33 | 34 | Class[] payload() default { }; 35 | 36 | Class> enumClass(); 37 | 38 | @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER }) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | @Documented 41 | @interface List { 42 | CheckCase[] value(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-filter-custom-fields/src/main/java/com/eprogrammerz/examples/spring/filterCustomFields/UserController.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.filterCustomFields; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.util.ReflectionUtils; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.lang.reflect.Modifier; 10 | import java.util.List; 11 | 12 | @RestController 13 | public class UserController { 14 | @GetMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) 15 | public User getString(@RequestParam List fields) { 16 | User user = new User("Yogen", 26, 3000.00f, "male"); 17 | filterFields(user, fields); 18 | return user; 19 | } 20 | 21 | private void filterFields(User user, List fields) { 22 | ReflectionUtils.doWithFields(User.class, field -> { 23 | if (!fields.contains(field.getName())) { 24 | field.setAccessible(true); 25 | field.set(user, null); 26 | } 27 | }, 28 | field -> { 29 | final int modifiers = field.getModifiers(); 30 | // no static fields please 31 | return !Modifier.isStatic(modifiers); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/configuration/ApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.configuration; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | /** 6 | * Created by 542596 on 2/12/2017. 7 | * 8 | * Best way to initialize application context. 9 | */ 10 | public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 11 | protected Class[] getRootConfigClasses() { 12 | return new Class[]{ApplicationConfiguration.class}; 13 | } 14 | 15 | protected Class[] getServletConfigClasses() { 16 | return null; 17 | } 18 | 19 | protected String[] getServletMappings() { 20 | return new String[]{"/"}; 21 | } 22 | } 23 | 24 | /** 25 | * can also be done this way 26 | 27 | public class ApplicationInitializer implements WebApplicationInitializer { 28 | 29 | public void onStartup(ServletContext container) throws ServletException { 30 | 31 | AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); 32 | ctx.register(ApplicationConfiguration.class); 33 | ctx.setServletContext(container); 34 | 35 | ServletRegistration.Dynamic servlet = container.addServlet( 36 | "dispatcher", new DispatcherServlet(ctx)); 37 | 38 | servlet.setLoadOnStartup(1); 39 | servlet.addMapping("/"); 40 | }*/ 41 | -------------------------------------------------------------------------------- /spring-webflux/src/test/java/com/eprogrammez/examples/webflux/GreetingRouterTests.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammez.examples.webflux; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.test.context.junit.jupiter.SpringExtension; 9 | import org.springframework.test.web.reactive.server.WebTestClient; 10 | 11 | @ExtendWith(SpringExtension.class) 12 | // We create a `@SpringBootTest`, starting an actual server on a `RANDOM_PORT` 13 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 14 | public class GreetingRouterTests { 15 | 16 | // Spring Boot will create a `WebTestClient` for you, 17 | // already configure and ready to issue requests against "localhost:RANDOM_PORT" 18 | @Autowired 19 | private WebTestClient webTestClient; 20 | 21 | @Test 22 | public void testHello() { 23 | webTestClient 24 | // Create a GET request to test an endpoint 25 | .get().uri("/hello") 26 | .accept(MediaType.TEXT_PLAIN) 27 | .exchange() 28 | // and use the dedicated DSL to test assertions against the response 29 | .expectStatus().isOk() 30 | .expectBody(String.class).isEqualTo("Hello, Spring!"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-security-jwt-demo/.gitignore: -------------------------------------------------------------------------------- 1 | ### JetBrains template 2 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion 3 | 4 | *.iml 5 | 6 | ## Directory-based project format: 7 | .idea/ 8 | # if you remove the above rule, at least ignore the following: 9 | 10 | # User-specific stuff: 11 | # .idea/workspace.xml 12 | # .idea/tasks.xml 13 | # .idea/dictionaries 14 | 15 | # Sensitive or high-churn files: 16 | # .idea/dataSources.ids 17 | # .idea/dataSources.xml 18 | # .idea/sqlDataSources.xml 19 | # .idea/dynamic.xml 20 | # .idea/uiDesigner.xml 21 | 22 | # Gradle: 23 | # .idea/gradle.xml 24 | # .idea/libraries 25 | 26 | # Mongo Explorer plugin: 27 | # .idea/mongoSettings.xml 28 | 29 | ## File-based project format: 30 | *.ipr 31 | *.iws 32 | 33 | ## Plugin-specific files: 34 | 35 | # IntelliJ 36 | /out/ 37 | 38 | # mpeltonen/sbt-idea plugin 39 | .idea_modules/ 40 | 41 | ### Maven template 42 | target/ 43 | pom.xml.tag 44 | pom.xml.releaseBackup 45 | pom.xml.versionsBackup 46 | pom.xml.next 47 | release.properties 48 | dependency-reduced-pom.xml 49 | buildNumber.properties 50 | .mvn/timing.properties 51 | 52 | ### Java 53 | 54 | *.class 55 | 56 | # Mobile Tools for Java (J2ME) 57 | .mtj.tmp/ 58 | 59 | # Package Files # 60 | *.jar 61 | *.war 62 | *.ear 63 | 64 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 65 | hs_err_pid* 66 | 67 | .fbExcludeFilterFile 68 | .springBeans 69 | -------------------------------------------------------------------------------- /spring-dynamic-properties-load/src/main/java/com/eprogrammerz/examples/config/DynamicEnvironmentProperties.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.config; 2 | 3 | import com.eprogrammerz.examples.exception.ResourceException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.util.Enumeration; 10 | import java.util.Properties; 11 | 12 | @Component 13 | public class DynamicEnvironmentProperties extends DynamicResourceLoader { 14 | 15 | private final static Logger logger = LoggerFactory.getLogger(DynamicEnvironmentProperties.class); 16 | private final static Object mutex = new Object(); 17 | public DynamicEnvironmentProperties() { 18 | super(30000); //set update frequency each 30 sec 19 | } 20 | 21 | public void loadProperties(String location) throws ResourceException 22 | { 23 | this.addResource(location); 24 | } 25 | 26 | public void resourceChange(byte[] resource) { 27 | ByteArrayInputStream bais = new ByteArrayInputStream(resource); 28 | Properties props = new Properties(); 29 | try 30 | { 31 | props.load(bais); 32 | } 33 | catch(Exception e) 34 | { 35 | //do nothing 36 | } 37 | Enumeration en = props.keys(); 38 | while(en.hasMoreElements()) 39 | { 40 | String key = (String)en.nextElement(); 41 | System.setProperty(key, props.getProperty(key)); 42 | } 43 | } 44 | 45 | @Override 46 | public void notifyChange(byte[] content) { 47 | this.resourceChange(content); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-angular/sprular-web/src/main/web/np-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "np-app", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~7.2.0", 15 | "@angular/common": "~7.2.0", 16 | "@angular/compiler": "~7.2.0", 17 | "@angular/core": "~7.2.0", 18 | "@angular/forms": "~7.2.0", 19 | "@angular/platform-browser": "~7.2.0", 20 | "@angular/platform-browser-dynamic": "~7.2.0", 21 | "@angular/router": "~7.2.0", 22 | "core-js": "^2.5.4", 23 | "rxjs": "~6.3.3", 24 | "tslib": "^1.9.0", 25 | "zone.js": "~0.8.26" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~0.12.0", 29 | "@angular/cli": "~7.2.3", 30 | "@angular/compiler-cli": "~7.2.0", 31 | "@angular/language-service": "~7.2.0", 32 | "@types/node": "~8.9.4", 33 | "@types/jasmine": "~2.8.8", 34 | "@types/jasminewd2": "~2.0.3", 35 | "codelyzer": "~4.5.0", 36 | "jasmine-core": "~2.99.1", 37 | "jasmine-spec-reporter": "~4.2.1", 38 | "karma": "~3.1.1", 39 | "karma-chrome-launcher": "~2.2.0", 40 | "karma-coverage-istanbul-reporter": "~2.0.1", 41 | "karma-jasmine": "~1.1.2", 42 | "karma-jasmine-html-reporter": "^0.2.2", 43 | "protractor": "~5.4.0", 44 | "ts-node": "~7.0.0", 45 | "tslint": "~5.11.0", 46 | "typescript": "~3.2.2" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-rest-template/src/main/java/com/eprogrammerz/examples/spring/getToken/clients/RemoteServiceClient.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.getToken.clients; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.http.HttpEntity; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.LinkedMultiValueMap; 11 | import org.springframework.util.MultiValueMap; 12 | import org.springframework.web.client.RestTemplate; 13 | 14 | import java.util.List; 15 | 16 | @Component 17 | public class RemoteServiceClient { 18 | 19 | @Value("${remote.service.host.uri}") 20 | private String remoteServiceUri; 21 | 22 | 23 | @Autowired 24 | private RestTemplate restTemplate; 25 | 26 | public String authenticateToIcon(String saml) { 27 | HttpHeaders headers = new HttpHeaders(); 28 | headers.setContentType(MediaType.APPLICATION_JSON); 29 | 30 | MultiValueMap map= new LinkedMultiValueMap<>(); 31 | map.add("SAMLResponse", saml); 32 | 33 | HttpEntity> request = new HttpEntity<>(map, headers); 34 | 35 | ResponseEntity response = restTemplate.postForEntity(remoteServiceUri, request , Object.class ); 36 | return response.getBody().toString(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-in-action-example/src/test/java/com/eprogrammerz/examples/models/impl/CDPlayerTest.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.models.impl; 2 | 3 | import com.eprogrammerz.examples.configuration.CDPlayerConfig; 4 | import com.eprogrammerz.examples.models.CompactDisc; 5 | import com.eprogrammerz.examples.models.MediaPlayer; 6 | import org.junit.Rule; 7 | import org.junit.Test; 8 | import org.junit.contrib.java.lang.system.StandardOutputStreamLog; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.test.context.ContextConfiguration; 12 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 13 | import org.springframework.test.context.web.WebAppConfiguration; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | import static org.junit.Assert.assertNotNull; 17 | 18 | /** 19 | * Created by 542596 on 2/12/2017. 20 | */ 21 | @WebAppConfiguration 22 | @RunWith(SpringJUnit4ClassRunner.class) 23 | @ContextConfiguration(classes=CDPlayerConfig.class) 24 | public class CDPlayerTest { 25 | @Rule 26 | public final StandardOutputStreamLog log = new StandardOutputStreamLog(); 27 | 28 | @Autowired 29 | private MediaPlayer player; 30 | 31 | @Autowired 32 | private CompactDisc cd; 33 | 34 | @Test 35 | public void cdShouldNotBeNull() { 36 | assertNotNull(cd); 37 | } 38 | 39 | @Test 40 | public void testPlay() { 41 | player.play(); 42 | assertEquals("Playing Hello by Adele.", log.getLog()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-in-action-example/src/test/java/com/eprogrammerz/examples/controllers/HomeControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.controllers; 2 | 3 | import com.eprogrammerz.examples.configuration.ApplicationConfiguration; 4 | import org.junit.After; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | import org.springframework.test.context.web.WebAppConfiguration; 11 | import org.springframework.test.web.servlet.MockMvc; 12 | 13 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 14 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; 15 | import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; 16 | 17 | /** 18 | * Created by 542596 on 2/12/2017. 19 | */ 20 | @RunWith(SpringJUnit4ClassRunner.class) 21 | @WebAppConfiguration 22 | @ContextConfiguration(classes = ApplicationConfiguration.class) 23 | public class HomeControllerTest { 24 | @Before 25 | public void setUp() throws Exception { 26 | 27 | } 28 | 29 | @After 30 | public void tearDown() throws Exception { 31 | 32 | } 33 | 34 | @Test 35 | public void testIndexPage() throws Exception { 36 | HomeController homeController = new HomeController(); 37 | MockMvc mockMvc = standaloneSetup(homeController).build(); 38 | 39 | mockMvc.perform(get("/")).andExpect(view().name("index")); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /spring-security-jwt-demo/src/main/java/com/eprogrammerz/examples/security/data/MockUserData.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.security.data; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.CommandLineRunner; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import com.eprogrammerz.examples.security.models.Role; 11 | import com.eprogrammerz.examples.security.models.RoleType; 12 | import com.eprogrammerz.examples.security.models.User; 13 | import com.eprogrammerz.examples.security.repository.RoleRepository; 14 | import com.eprogrammerz.examples.security.repository.UserRepository; 15 | 16 | /** 17 | * @author Yogen 18 | * 19 | */ 20 | @Configuration 21 | public class MockUserData implements CommandLineRunner { 22 | 23 | @Autowired 24 | private UserRepository userRepository; 25 | 26 | @Autowired 27 | private RoleRepository roleRepository; 28 | 29 | @Override 30 | public void run(String... arg0) throws Exception { 31 | List roles = Arrays.asList( 32 | new Role(null, RoleType.ROLE_ADMIN), 33 | new Role(null, RoleType.ROLE_USER) 34 | ); 35 | List users = Arrays.asList( 36 | new User(null, "admin", "admin", "Yogen Rai", "ygn@gmail.com", Arrays.asList(roles.get(0))), 37 | new User(null, "user", "user", "John Dow", "john@gmail.com", Arrays.asList(roles.get(1))) 38 | ); 39 | 40 | this.roleRepository.save(roles); 41 | 42 | this.userRepository.save(users); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-mvc-xml-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.eprogrammerz.examples 8 | spring-mvc-xml-demo 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | 13 | 4.3.2.RELEASE 14 | 1.2 15 | 2.5 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.springframework 23 | spring-webmvc 24 | ${spring.version} 25 | 26 | 27 | 28 | 29 | javax.servlet 30 | jstl 31 | ${jstl.version} 32 | 33 | 34 | 35 | 36 | javax.servlet 37 | servlet-api 38 | ${servletapi.version} 39 | provided 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-mvc-annotation/src/main/java/com/eprogrammerz/examples/configuration/ApplicationConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.configuration; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.servlet.ViewResolver; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 10 | import org.springframework.web.servlet.view.JstlView; 11 | 12 | /** 13 | * Created by 542596 on 2/12/2017. 14 | */ 15 | @Slf4j 16 | @Configuration 17 | @EnableWebMvc 18 | @ComponentScan(basePackages = "com.eprogrammerz.examples") 19 | public class ApplicationConfiguration { 20 | @Bean(name = "viewResolver") 21 | public ViewResolver viewResolver() { 22 | log.info("viewResolver(): View Resolver Bean created."); 23 | InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); 24 | viewResolver.setViewClass(JstlView.class); 25 | viewResolver.setPrefix("/WEB-INF/views/"); 26 | viewResolver.setSuffix(".jsp"); 27 | 28 | return viewResolver; 29 | } 30 | /*public InternalResourceViewResolver jspViewResolver() { 31 | InternalResourceViewResolver jspViewResolver = new InternalResourceViewResolver(); 32 | jspViewResolver.setViewClass(JstlView.class); 33 | jspViewResolver.setPrefix("/WEB-INF/pages/"); 34 | jspViewResolver.setSuffix(".jsp"); 35 | return jspViewResolver; 36 | }*/ 37 | } 38 | -------------------------------------------------------------------------------- /spring-in-action-example/src/main/java/com/eprogrammerz/examples/configuration/ApplicationConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.configuration; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.servlet.ViewResolver; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 10 | import org.springframework.web.servlet.view.JstlView; 11 | 12 | /** 13 | * Created by 542596 on 2/12/2017. 14 | */ 15 | @Slf4j 16 | @Configuration 17 | @EnableWebMvc 18 | @ComponentScan(basePackages = "com.eprogrammerz.examples") 19 | public class ApplicationConfiguration { 20 | @Bean(name = "viewResolver") 21 | public ViewResolver viewResolver() { 22 | log.info("viewResolver(): View Resolver Bean created."); 23 | InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); 24 | viewResolver.setViewClass(JstlView.class); 25 | viewResolver.setPrefix("/WEB-INF/views/"); 26 | viewResolver.setSuffix(".jsp"); 27 | 28 | return viewResolver; 29 | } 30 | /*public InternalResourceViewResolver jspViewResolver() { 31 | InternalResourceViewResolver jspViewResolver = new InternalResourceViewResolver(); 32 | jspViewResolver.setViewClass(JstlView.class); 33 | jspViewResolver.setPrefix("/WEB-INF/pages/"); 34 | jspViewResolver.setSuffix(".jsp"); 35 | return jspViewResolver; 36 | }*/ 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-mongo/src/main/java/com/eprogrammerz/examples/springbootmongo/SpringBootMongoApplication.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.springbootmongo; 2 | 3 | import com.eprogrammerz.examples.springbootmongo.models.Derived; 4 | import com.eprogrammerz.examples.springbootmongo.repositories.DerivedRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | @SpringBootApplication 14 | public class SpringBootMongoApplication implements CommandLineRunner { 15 | @Autowired 16 | private DerivedRepository derivedRepository; 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(SpringBootMongoApplication.class, args); 20 | } 21 | 22 | @Override 23 | public void run(String... strings) throws Exception { 24 | System.out.println("logging app..."); 25 | Derived derived1 = new Derived(); 26 | derived1.setFieldB("fieldB1"); 27 | derived1.setFieldA("fieldA1"); 28 | 29 | Derived derived2 = new Derived(); 30 | derived2.setFieldB("fieldB2"); 31 | derived2.setFieldA("fieldA2"); 32 | this.derivedRepository.save(Arrays.asList(derived1, derived2)); 33 | 34 | List deriveds = this.derivedRepository.findByFieldA("fieldA1"); 35 | System.out.println(deriveds); 36 | 37 | List deriveds1 = this.derivedRepository.findByFieldB("fieldB2"); 38 | System.out.println(deriveds1); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-trasaction/src/main/java/com/eprogrammerz/examples/spring/springtrasaction/BookingService.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.spring.springtrasaction; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.jdbc.core.JdbcTemplate; 7 | import org.springframework.scheduling.annotation.Async; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.util.List; 12 | import java.util.concurrent.CompletableFuture; 13 | 14 | @Service 15 | public class BookingService { 16 | private final static Logger log = LoggerFactory.getLogger(BookingService.class); 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * Send and forget async method 23 | * 24 | * @param persons 25 | */ 26 | @Transactional 27 | // @Async 28 | public void book(String... persons) { 29 | for (String person : persons) { 30 | log.info("Booking {} in a seat . . .", person); 31 | jdbcTemplate.update("insert into BOOKINGS(FIRST_NAME) values(?)", person); 32 | } 33 | } 34 | 35 | /** 36 | * The result should be wrapped in CompleteableFuture for function returning value 37 | * 38 | * @return 39 | */ 40 | @Async 41 | public CompletableFuture> findAllBookings() { 42 | log.info("Querying bookings . . ."); 43 | List bookings = jdbcTemplate.query("select FIRST_NAME from BOOKINGS", ((rs, rowNum) -> rs.getString("FIRST_NAME"))); 44 | return CompletableFuture.completedFuture(bookings); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-jpa-example/src/main/java/com/eprogrammerz/examples/jpa/ApplicantIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.eprogrammerz.examples.jpa; 2 | 3 | import org.hibernate.HibernateException; 4 | import org.hibernate.engine.spi.SessionImplementor; 5 | import org.hibernate.id.IdentifierGenerator; 6 | import org.hibernate.internal.SessionImpl; 7 | 8 | import java.io.Serializable; 9 | import java.sql.Connection; 10 | import java.sql.PreparedStatement; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.util.IllegalFormatException; 14 | 15 | public class ApplicantIdGenerator implements IdentifierGenerator { 16 | 17 | @Override 18 | public synchronized Serializable generate(SessionImplementor session, Object o) throws HibernateException { 19 | if(!(o instanceof Applicant)) { 20 | throw new IllegalArgumentException("Invalid class"); 21 | } 22 | final Applicant applicant = (Applicant) o; 23 | String prefix = "I-"; 24 | Connection connection = session.connection(); 25 | try (PreparedStatement ps = connection 26 | .prepareStatement("SELECT MAX(id) AS id FROM APPLICANT for update"); ResultSet rs = ps.executeQuery()) { 27 | if (rs.next()) { 28 | // int id = rs.getString("id") != null ? Integer.valueOf(rs.getString("id").split("-")[1]) + 1 : 1; 29 | int id = rs.getInt("id") + 1; 30 | String code = prefix + id; 31 | System.out.println("Generated Stock Code: " + code); 32 | applicant.setApplicantId(code); 33 | return id; 34 | } 35 | } catch (SQLException e) { 36 | e.printStackTrace(); 37 | } 38 | session.flush(); 39 | return null; 40 | } 41 | } --------------------------------------------------------------------------------