├── .DS_Store ├── .gitignore ├── CacheDemo ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ └── java │ └── hello │ ├── AppRunner.java │ ├── Application.java │ ├── Book.java │ ├── BookRepository.java │ └── SimpleBookRepository.java ├── DemoBatch ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── java │ └── hello │ │ ├── Application.java │ │ ├── BatchConfiguration.java │ │ ├── JobCompletionNotificationListener.java │ │ ├── Person.java │ │ └── PersonItemProcessor.java │ └── resources │ ├── sample-data.csv │ └── schema-all.sql ├── LICENSE ├── README.md ├── SpringWS ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mvnw ├── mvnw.cmd ├── pom.xml ├── request.xml └── src │ ├── main │ ├── java │ │ ├── .gitignore │ │ └── hello │ │ │ ├── Application.java │ │ │ ├── CountryEndpoint.java │ │ │ ├── CountryRepository.java │ │ │ └── WebServiceConfig.java │ └── resources │ │ └── countries.xsd │ └── test │ └── java │ └── hello │ └── ApplicationIntegrationTests.java ├── bootangular ├── .DS_Store ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── pe │ │ │ └── joedayz │ │ │ ├── BootangularApplication.java │ │ │ ├── modelo │ │ │ └── User.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── rest │ │ │ ├── IndexController.java │ │ │ └── UserRestController.java │ │ │ └── service │ │ │ ├── UserService.java │ │ │ └── UserServiceImpl.java │ ├── resources │ │ ├── application.properties │ │ └── static │ │ │ ├── css │ │ │ ├── app.css │ │ │ └── bootstrap.css │ │ │ └── js │ │ │ ├── app.js │ │ │ ├── controller │ │ │ └── user_controller.js │ │ │ └── service │ │ │ └── user_service.js │ └── webapp │ │ └── WEB-INF │ │ └── jsp │ │ └── UserManagement.jsp │ └── test │ └── java │ └── pe │ └── joedayz │ └── BootangularApplicationTests.java ├── cfp-example ├── .DS_Store ├── README.adoc ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── cfp │ │ │ ├── CfpApplication.java │ │ │ ├── CfpProperties.java │ │ │ ├── domain │ │ │ ├── Submission.java │ │ │ ├── SubmissionRepository.java │ │ │ ├── SubmissionStatus.java │ │ │ ├── Track.java │ │ │ ├── User.java │ │ │ └── UserRepository.java │ │ │ ├── integration │ │ │ └── github │ │ │ │ ├── Commit.java │ │ │ │ ├── CommitDeserializer.java │ │ │ │ ├── GithubClient.java │ │ │ │ └── GithubUser.java │ │ │ ├── security │ │ │ └── SecurityConfig.java │ │ │ ├── submission │ │ │ ├── SubmissionRequest.java │ │ │ └── SubmissionService.java │ │ │ └── web │ │ │ ├── AdminController.java │ │ │ ├── CfpController.java │ │ │ ├── HomeController.java │ │ │ ├── Navigation.java │ │ │ ├── NewsController.java │ │ │ ├── Section.java │ │ │ ├── SubmissionForm.java │ │ │ └── WebConfig.java │ └── resources │ │ ├── application-local.properties │ │ ├── application-secrets.properties │ │ ├── application.properties │ │ ├── db │ │ └── migration │ │ │ ├── V1_1__Add_Notes.sql │ │ │ └── V1__Initial_Setup.sql │ │ ├── static │ │ ├── bootstrap │ │ │ ├── css │ │ │ │ ├── bootstrap-theme.min.css │ │ │ │ ├── bootstrap-theme.min.css.map │ │ │ │ └── bootstrap.min.css │ │ │ └── js │ │ │ │ └── bootstrap.min.js │ │ ├── css │ │ │ └── main.css │ │ └── img │ │ │ └── cfp-background.png │ │ └── templates │ │ ├── admin │ │ └── index.html │ │ ├── error │ │ └── 4xx.html │ │ ├── index.html │ │ ├── layouts │ │ └── main.html │ │ ├── login.html │ │ ├── news.html │ │ └── submit.html │ └── test │ ├── java │ └── com │ │ └── example │ │ └── cfp │ │ ├── domain │ │ ├── SubmissionTest.java │ │ └── UserTest.java │ │ ├── integration │ │ └── github │ │ │ └── GithubClientTest.java │ │ ├── submission │ │ └── SubmissionServiceTest.java │ │ └── web │ │ └── CfpControllerTest.java │ └── resources │ ├── github │ ├── jsmith.json │ ├── no-commit.json │ ├── spring-framework-commits-no-polish.json │ └── spring-framework-commits.json │ └── logback-test.xml ├── demo-boot-jpa ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── demo │ │ │ │ ├── DemoBootJpaApplication.java │ │ │ │ ├── controller │ │ │ │ └── InicioController.java │ │ │ │ ├── domain │ │ │ │ ├── Etiqueta.java │ │ │ │ └── Nota.java │ │ │ │ └── repository │ │ │ │ ├── EtiquetaRepository.java │ │ │ │ ├── JpaEtiquetaRepository.java │ │ │ │ ├── JpaNotaRepository.java │ │ │ │ └── NotaRepository.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── import.txt │ │ │ └── templates │ │ │ └── inicio.ftl │ └── test │ │ └── java │ │ └── demo │ │ └── DemoBootJpaApplicationTests.java └── target │ └── classes │ ├── META-INF │ ├── MANIFEST.MF │ └── maven │ │ └── com.mycompany │ │ └── demobootjpa │ │ ├── pom.properties │ │ └── pom.xml │ └── application.properties ├── demo-data-jpa ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── demo │ │ │ ├── DemoDataJpaApplication.java │ │ │ ├── controller │ │ │ └── HotelController.java │ │ │ ├── domain │ │ │ ├── City.java │ │ │ ├── Hotel.java │ │ │ ├── HotelSummary.java │ │ │ ├── Rating.java │ │ │ ├── RatingCount.java │ │ │ ├── Review.java │ │ │ ├── ReviewDetails.java │ │ │ └── TripType.java │ │ │ └── service │ │ │ ├── CityRepository.java │ │ │ ├── CitySearchCriteria.java │ │ │ ├── CityService.java │ │ │ ├── CityServiceImpl.java │ │ │ ├── HotelRepository.java │ │ │ ├── HotelService.java │ │ │ ├── HotelServiceImpl.java │ │ │ ├── ReviewRepository.java │ │ │ └── ReviewsSummary.java │ └── resources │ │ ├── application.properties │ │ └── import.sql │ └── test │ ├── java │ └── demo │ │ ├── DemoDataJpaApplicationTests.java │ │ └── service │ │ ├── CityRepositoryIntegrationTests.java │ │ └── HotelRepositoryIntegrationTests.java │ └── resources │ └── application-qa.properties ├── spring-boot-activemq ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── demo │ │ │ ├── ActiveMQConfig.java │ │ │ ├── Consumer.java │ │ │ ├── DemoActiveMqApplication.java │ │ │ └── Producer.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── demo │ └── DemoActiveMqApplicationTests.java ├── spring-boot-jms-javaconfig ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── activemq-data │ └── embedded │ │ └── KahaDB │ │ ├── db-1.log │ │ ├── db.data │ │ └── db.redo ├── pom.xml └── src │ ├── main │ └── java │ │ └── xpadro │ │ └── spring │ │ └── jms │ │ ├── JmsJavaconfigApplication.java │ │ ├── listener │ │ ├── InListener.java │ │ ├── OutListener.java │ │ └── SimpleListener.java │ │ ├── model │ │ └── Order.java │ │ └── service │ │ ├── ClientService.java │ │ ├── ClientServiceImpl.java │ │ ├── RegisterService.java │ │ ├── RegisterServiceImpl.java │ │ ├── StoreService.java │ │ └── StoreServiceImpl.java │ └── test │ └── java │ └── xpadro │ └── spring │ └── jms │ ├── InOutListenerTest.java │ └── SimpleListenerTest.java ├── spring-boot-messaging ├── build.gradle ├── demo.iml └── src │ ├── main │ ├── java │ │ └── demo │ │ │ ├── Application.java │ │ │ ├── config │ │ │ ├── CamelConfig.java │ │ │ ├── SecurityConfig.java │ │ │ └── WebSocketConfig.java │ │ │ ├── controllers │ │ │ ├── APIController.java │ │ │ └── WebSocketController.java │ │ │ ├── dto │ │ │ └── MessageDTO.java │ │ │ └── handlers │ │ │ └── QueueHandler.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── index.html │ └── test │ └── java │ └── demo │ └── Demowebsocket3ApplicationTests.java ├── spring-boot-sample-data-mongodb ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml └── src │ ├── main │ └── java │ │ └── sample │ │ └── data │ │ └── mongo │ │ ├── Customer.java │ │ ├── CustomerRepository.java │ │ └── SampleMongoApplication.java │ └── test │ └── java │ └── sample │ └── data │ └── mongo │ └── SampleMongoApplicationTests.java ├── spring-boot-websocket ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pom.xml └── src │ └── main │ ├── java │ └── hello │ │ ├── Application.java │ │ ├── Greeting.java │ │ ├── GreetingController.java │ │ ├── HelloMessage.java │ │ └── WebSocketConfig.java │ └── resources │ └── static │ ├── index.html │ ├── sockjs-0.3.4.js │ └── stomp.js ├── spring-boot-ws-holiday ├── .gitignore ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── demo │ │ │ ├── DemoSpringWsApplication.java │ │ │ ├── WebServiceConfig.java │ │ │ ├── endpoint │ │ │ └── HolidayEndpoint.java │ │ │ └── service │ │ │ ├── HumanResourceService.java │ │ │ └── StubHumanResourceService.java │ └── resources │ │ ├── META-INF │ │ └── schemas │ │ │ ├── hr.xsd │ │ │ └── students.xsd │ │ └── application.properties │ └── test │ └── java │ └── demo │ └── DemoSpringWsApplicationTests.java ├── visitas ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.wst.common.project.facet.core.xml ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── demo │ │ │ ├── MvcConfig.java │ │ │ ├── VisitasApplication.java │ │ │ ├── WebSecurityConfig.java │ │ │ ├── controller │ │ │ └── InicioController.java │ │ │ ├── model │ │ │ ├── Usuario.java │ │ │ └── Visita.java │ │ │ └── repository │ │ │ └── VisitasRepository.java │ │ └── resources │ │ ├── application.properties │ │ └── templates │ │ ├── admin.html │ │ ├── home.html │ │ └── login.html └── target │ └── classes │ ├── application.properties │ └── templates │ ├── home.html │ └── login.html └── weather-app ├── .DS_Store ├── .factorypath ├── README.adoc ├── pom.xml └── src ├── main ├── asciidoc │ └── index.adoc ├── java │ └── com │ │ └── example │ │ └── weather │ │ ├── WeatherApp.java │ │ ├── WeatherAppProperties.java │ │ ├── integration │ │ └── ows │ │ │ ├── Weather.java │ │ │ ├── WeatherEntry.java │ │ │ ├── WeatherForecast.java │ │ │ └── WeatherService.java │ │ └── web │ │ ├── WeatherApiController.java │ │ ├── WeatherSummary.java │ │ └── WeatherSummaryController.java └── resources │ ├── application.properties │ ├── banner.jpg │ ├── static │ ├── css │ │ ├── owfont-regular.css │ │ ├── owfont-regular.min.css │ │ └── style.css │ ├── error │ │ └── 404.html │ ├── favicon.ico │ ├── fonts │ │ ├── SpringOnePlatform.eot │ │ ├── SpringOnePlatform.svg │ │ ├── SpringOnePlatform.ttf │ │ ├── SpringOnePlatform.woff │ │ ├── owfont-regular.eot │ │ ├── owfont-regular.otf │ │ ├── owfont-regular.svg │ │ ├── owfont-regular.ttf │ │ └── owfont-regular.woff │ └── img │ │ ├── background.jpg │ │ └── twitter-logo.png │ └── templates │ └── summary.html └── test ├── java └── com │ └── example │ └── weather │ ├── integration │ └── ows │ │ └── WeatherServiceTest.java │ └── web │ ├── WeatherApiControllerTest.java │ └── WeatherApiDocumentationTest.java └── resources ├── com └── example │ └── weather │ └── integration │ └── ows │ ├── forecast-barcelona.json │ └── weather-barcelona.json └── logback-test.xml /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Intellij project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | 31 | #Gradle 32 | .gradletasknamecache 33 | .gradle/ 34 | build/ 35 | bin/ 36 | target/ -------------------------------------------------------------------------------- /CacheDemo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/CacheDemo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /CacheDemo/.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 | -------------------------------------------------------------------------------- /CacheDemo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.7.RELEASE") 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'eclipse' 12 | apply plugin: 'idea' 13 | apply plugin: 'org.springframework.boot' 14 | 15 | jar { 16 | baseName = 'gs-caching' 17 | version = '0.1.0' 18 | } 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | dependencies { 28 | compile("org.springframework.boot:spring-boot-starter-cache") 29 | } 30 | 31 | -------------------------------------------------------------------------------- /CacheDemo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/CacheDemo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /CacheDemo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:04:54 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /CacheDemo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-caching 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.7.RELEASE 14 | 15 | 16 | 17 | 1.8 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-cache 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /CacheDemo/src/main/java/hello/AppRunner.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class AppRunner implements CommandLineRunner { 10 | 11 | private static final Logger logger = LoggerFactory.getLogger(AppRunner.class); 12 | 13 | private final BookRepository bookRepository; 14 | 15 | public AppRunner(BookRepository bookRepository) { 16 | this.bookRepository = bookRepository; 17 | } 18 | 19 | @Override 20 | public void run(String... args) throws Exception { 21 | logger.info(".... Fetching books"); 22 | logger.info("isbn-1234 -->" + bookRepository.getByIsbn("isbn-1234")); 23 | logger.info("isbn-4567 -->" + bookRepository.getByIsbn("isbn-4567")); 24 | logger.info("isbn-1234 -->" + bookRepository.getByIsbn("isbn-1234")); 25 | logger.info("isbn-4567 -->" + bookRepository.getByIsbn("isbn-4567")); 26 | logger.info("isbn-1234 -->" + bookRepository.getByIsbn("isbn-1234")); 27 | logger.info("isbn-1234 -->" + bookRepository.getByIsbn("isbn-1234")); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /CacheDemo/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @SpringBootApplication 8 | @EnableCaching 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /CacheDemo/src/main/java/hello/Book.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class Book { 4 | 5 | private String isbn; 6 | private String title; 7 | 8 | public Book(String isbn, String title) { 9 | this.isbn = isbn; 10 | this.title = title; 11 | } 12 | 13 | public String getIsbn() { 14 | return isbn; 15 | } 16 | 17 | public void setIsbn(String isbn) { 18 | this.isbn = isbn; 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Book{" + "isbn='" + isbn + '\'' + ", title='" + title + '\'' + '}'; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /CacheDemo/src/main/java/hello/BookRepository.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public interface BookRepository { 4 | 5 | Book getByIsbn(String isbn); 6 | 7 | } -------------------------------------------------------------------------------- /CacheDemo/src/main/java/hello/SimpleBookRepository.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.cache.annotation.Cacheable; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class SimpleBookRepository implements BookRepository { 8 | 9 | @Override 10 | @Cacheable("books") 11 | public Book getByIsbn(String isbn) { 12 | simulateSlowService(); 13 | return new Book(isbn, "Some book"); 14 | } 15 | 16 | // Don't do this at home 17 | private void simulateSlowService() { 18 | try { 19 | long time = 3000L; 20 | Thread.sleep(time); 21 | } catch (InterruptedException e) { 22 | throw new IllegalStateException(e); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /DemoBatch/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/DemoBatch/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /DemoBatch/.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 | -------------------------------------------------------------------------------- /DemoBatch/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.7.RELEASE") 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'eclipse' 12 | apply plugin: 'idea' 13 | apply plugin: 'org.springframework.boot' 14 | 15 | jar { 16 | baseName = 'gs-batch-processing' 17 | version = '0.1.0' 18 | } 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | dependencies { 28 | compile("org.springframework.boot:spring-boot-starter-batch") 29 | compile("org.hsqldb:hsqldb") 30 | testCompile("junit:junit") 31 | } 32 | 33 | -------------------------------------------------------------------------------- /DemoBatch/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/DemoBatch/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /DemoBatch/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:04:47 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /DemoBatch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-batch-processing 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.7.RELEASE 14 | 15 | 16 | 17 | 1.8 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-batch 24 | 25 | 26 | org.hsqldb 27 | hsqldb 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /DemoBatch/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) throws Exception { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DemoBatch/src/main/java/hello/JobCompletionNotificationListener.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.util.List; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import org.springframework.batch.core.BatchStatus; 11 | import org.springframework.batch.core.JobExecution; 12 | import org.springframework.batch.core.listener.JobExecutionListenerSupport; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.jdbc.core.JdbcTemplate; 15 | import org.springframework.jdbc.core.RowMapper; 16 | import org.springframework.stereotype.Component; 17 | 18 | @Component 19 | public class JobCompletionNotificationListener extends JobExecutionListenerSupport { 20 | 21 | private static final Logger log = LoggerFactory.getLogger(JobCompletionNotificationListener.class); 22 | 23 | private final JdbcTemplate jdbcTemplate; 24 | 25 | @Autowired 26 | public JobCompletionNotificationListener(JdbcTemplate jdbcTemplate) { 27 | this.jdbcTemplate = jdbcTemplate; 28 | } 29 | 30 | @Override 31 | public void afterJob(JobExecution jobExecution) { 32 | if(jobExecution.getStatus() == BatchStatus.COMPLETED) { 33 | log.info("!!! JOB FINISHED! Time to verify the results"); 34 | 35 | List results = jdbcTemplate.query("SELECT first_name, last_name FROM people", new RowMapper() { 36 | @Override 37 | public Person mapRow(ResultSet rs, int row) throws SQLException { 38 | return new Person(rs.getString(1), rs.getString(2)); 39 | } 40 | }); 41 | 42 | for (Person person : results) { 43 | log.info("Found <" + person + "> in the database."); 44 | } 45 | 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /DemoBatch/src/main/java/hello/Person.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class Person { 4 | private String lastName; 5 | private String firstName; 6 | 7 | public Person() { 8 | 9 | } 10 | 11 | public Person(String firstName, String lastName) { 12 | this.firstName = firstName; 13 | this.lastName = lastName; 14 | } 15 | 16 | public void setFirstName(String firstName) { 17 | this.firstName = firstName; 18 | } 19 | 20 | public String getFirstName() { 21 | return firstName; 22 | } 23 | 24 | public String getLastName() { 25 | return lastName; 26 | } 27 | 28 | public void setLastName(String lastName) { 29 | this.lastName = lastName; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "firstName: " + firstName + ", lastName: " + lastName; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /DemoBatch/src/main/java/hello/PersonItemProcessor.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import org.springframework.batch.item.ItemProcessor; 7 | 8 | public class PersonItemProcessor implements ItemProcessor { 9 | 10 | private static final Logger log = LoggerFactory.getLogger(PersonItemProcessor.class); 11 | 12 | @Override 13 | public Person process(final Person person) throws Exception { 14 | final String firstName = person.getFirstName().toUpperCase(); 15 | final String lastName = person.getLastName().toUpperCase(); 16 | 17 | final Person transformedPerson = new Person(firstName, lastName); 18 | 19 | log.info("Converting (" + person + ") into (" + transformedPerson + ")"); 20 | 21 | return transformedPerson; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /DemoBatch/src/main/resources/sample-data.csv: -------------------------------------------------------------------------------- 1 | Jill,Doe 2 | Joe,Doe 3 | Justin,Doe 4 | Jane,Doe 5 | John,Doe 6 | -------------------------------------------------------------------------------- /DemoBatch/src/main/resources/schema-all.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE people IF EXISTS; 2 | 3 | CREATE TABLE people ( 4 | person_id BIGINT IDENTITY NOT NULL PRIMARY KEY, 5 | first_name VARCHAR(20), 6 | last_name VARCHAR(20) 7 | ); 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-samples 2 | Spring Boot Demos of SpringSource or mine 3 | -------------------------------------------------------------------------------- /SpringWS/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/SpringWS/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /SpringWS/.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 | -------------------------------------------------------------------------------- /SpringWS/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/SpringWS/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /SpringWS/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 29 13:07:31 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip 7 | -------------------------------------------------------------------------------- /SpringWS/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-producing-web-service 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.5.7.RELEASE 14 | 15 | 16 | 17 | 1.8 18 | 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web-services 25 | 26 | 27 | wsdl4j 28 | wsdl4j 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | org.codehaus.mojo 48 | jaxb2-maven-plugin 49 | 1.6 50 | 51 | 52 | xjc 53 | 54 | xjc 55 | 56 | 57 | 58 | 59 | ${project.basedir}/src/main/resources/ 60 | ${project.basedir}/src/main/java 61 | false 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /SpringWS/request.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Spain 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /SpringWS/src/main/java/.gitignore: -------------------------------------------------------------------------------- 1 | io 2 | -------------------------------------------------------------------------------- /SpringWS/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SpringWS/src/main/java/hello/CountryEndpoint.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.ws.server.endpoint.annotation.Endpoint; 5 | import org.springframework.ws.server.endpoint.annotation.PayloadRoot; 6 | import org.springframework.ws.server.endpoint.annotation.RequestPayload; 7 | import org.springframework.ws.server.endpoint.annotation.ResponsePayload; 8 | 9 | import io.spring.guides.gs_producing_web_service.GetCountryRequest; 10 | import io.spring.guides.gs_producing_web_service.GetCountryResponse; 11 | 12 | @Endpoint 13 | public class CountryEndpoint { 14 | private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service"; 15 | 16 | private CountryRepository countryRepository; 17 | 18 | @Autowired 19 | public CountryEndpoint(CountryRepository countryRepository) { 20 | this.countryRepository = countryRepository; 21 | } 22 | 23 | @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest") 24 | @ResponsePayload 25 | public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) { 26 | GetCountryResponse response = new GetCountryResponse(); 27 | response.setCountry(countryRepository.findCountry(request.getName())); 28 | 29 | return response; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SpringWS/src/main/java/hello/CountryRepository.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import javax.annotation.PostConstruct; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import io.spring.guides.gs_producing_web_service.Country; 8 | import io.spring.guides.gs_producing_web_service.Currency; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.Assert; 11 | 12 | @Component 13 | public class CountryRepository { 14 | private static final Map countries = new HashMap<>(); 15 | 16 | @PostConstruct 17 | public void initData() { 18 | Country spain = new Country(); 19 | spain.setName("Spain"); 20 | spain.setCapital("Madrid"); 21 | spain.setCurrency(Currency.EUR); 22 | spain.setPopulation(46704314); 23 | 24 | countries.put(spain.getName(), spain); 25 | 26 | Country poland = new Country(); 27 | poland.setName("Poland"); 28 | poland.setCapital("Warsaw"); 29 | poland.setCurrency(Currency.PLN); 30 | poland.setPopulation(38186860); 31 | 32 | countries.put(poland.getName(), poland); 33 | 34 | Country uk = new Country(); 35 | uk.setName("United Kingdom"); 36 | uk.setCapital("London"); 37 | uk.setCurrency(Currency.GBP); 38 | uk.setPopulation(63705000); 39 | 40 | countries.put(uk.getName(), uk); 41 | } 42 | 43 | public Country findCountry(String name) { 44 | Assert.notNull(name, "The country's name must not be null"); 45 | return countries.get(name); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SpringWS/src/main/java/hello/WebServiceConfig.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.core.io.ClassPathResource; 8 | import org.springframework.ws.config.annotation.EnableWs; 9 | import org.springframework.ws.config.annotation.WsConfigurerAdapter; 10 | import org.springframework.ws.transport.http.MessageDispatcherServlet; 11 | import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; 12 | import org.springframework.xml.xsd.SimpleXsdSchema; 13 | import org.springframework.xml.xsd.XsdSchema; 14 | 15 | @EnableWs 16 | @Configuration 17 | public class WebServiceConfig extends WsConfigurerAdapter { 18 | @Bean 19 | public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { 20 | MessageDispatcherServlet servlet = new MessageDispatcherServlet(); 21 | servlet.setApplicationContext(applicationContext); 22 | servlet.setTransformWsdlLocations(true); 23 | return new ServletRegistrationBean(servlet, "/ws/*"); 24 | } 25 | 26 | @Bean(name = "countries") 27 | public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { 28 | DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); 29 | wsdl11Definition.setPortTypeName("CountriesPort"); 30 | wsdl11Definition.setLocationUri("/ws"); 31 | wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); 32 | wsdl11Definition.setSchema(countriesSchema); 33 | return wsdl11Definition; 34 | } 35 | 36 | @Bean 37 | public XsdSchema countriesSchema() { 38 | return new SimpleXsdSchema(new ClassPathResource("countries.xsd")); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SpringWS/src/main/resources/countries.xsd: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /SpringWS/src/test/java/hello/ApplicationIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package hello; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.Before; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.springframework.boot.context.embedded.LocalServerPort; 25 | import org.springframework.boot.test.context.SpringBootTest; 26 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 27 | import org.springframework.oxm.jaxb.Jaxb2Marshaller; 28 | import org.springframework.test.context.junit4.SpringRunner; 29 | import org.springframework.util.ClassUtils; 30 | import org.springframework.ws.client.core.WebServiceTemplate; 31 | 32 | import io.spring.guides.gs_producing_web_service.GetCountryRequest; 33 | 34 | @RunWith(SpringRunner.class) 35 | @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) 36 | public class ApplicationIntegrationTests { 37 | 38 | private Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 39 | 40 | @LocalServerPort 41 | private int port = 0; 42 | 43 | @Before 44 | public void init() throws Exception { 45 | marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class)); 46 | marshaller.afterPropertiesSet(); 47 | } 48 | 49 | @Test 50 | public void testSendAndReceive() { 51 | WebServiceTemplate ws = new WebServiceTemplate(marshaller); 52 | GetCountryRequest request = new GetCountryRequest(); 53 | request.setName("Spain"); 54 | 55 | assertThat(ws.marshalSendAndReceive("http://localhost:" 56 | + port + "/ws", request)).isNotNull(); 57 | } 58 | } -------------------------------------------------------------------------------- /bootangular/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/bootangular/.DS_Store -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/BootangularApplication.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz; 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.support.SpringBootServletInitializer; 7 | 8 | @SpringBootApplication 9 | public class BootangularApplication extends SpringBootServletInitializer { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(BootangularApplication.class, args); 13 | } 14 | 15 | @Override 16 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 17 | return application.sources(BootangularApplication.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/modelo/User.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz.modelo; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.GenerationType; 6 | import javax.persistence.Id; 7 | 8 | @Entity 9 | public class User { 10 | 11 | @Id 12 | @GeneratedValue(strategy=GenerationType.AUTO) 13 | private long id; 14 | 15 | private String username; 16 | 17 | private String address; 18 | 19 | private String email; 20 | 21 | public User(){} 22 | 23 | public User(long id, String username, String address, String email){ 24 | this.id = id; 25 | this.username = username; 26 | this.address = address; 27 | this.email = email; 28 | } 29 | 30 | public long getId() { 31 | return id; 32 | } 33 | 34 | public void setId(long id) { 35 | this.id = id; 36 | } 37 | 38 | public String getUsername() { 39 | return username; 40 | } 41 | 42 | public void setUsername(String username) { 43 | this.username = username; 44 | } 45 | 46 | public String getAddress() { 47 | return address; 48 | } 49 | 50 | public void setAddress(String address) { 51 | this.address = address; 52 | } 53 | 54 | public String getEmail() { 55 | return email; 56 | } 57 | 58 | public void setEmail(String email) { 59 | this.email = email; 60 | } 61 | 62 | @Override 63 | public int hashCode() { 64 | final int prime = 31; 65 | int result = 1; 66 | result = prime * result + (int) (id ^ (id >>> 32)); 67 | return result; 68 | } 69 | 70 | @Override 71 | public boolean equals(Object obj) { 72 | if (this == obj) 73 | return true; 74 | if (obj == null) 75 | return false; 76 | if (!(obj instanceof User)) 77 | return false; 78 | User other = (User) obj; 79 | if (id != other.id) 80 | return false; 81 | return true; 82 | } 83 | 84 | @Override 85 | public String toString() { 86 | return "User [id=" + id + ", username=" + username + ", address=" + address 87 | + ", email=" + email + "]"; 88 | } 89 | 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import pe.joedayz.modelo.User; 6 | 7 | public interface UserRepository extends CrudRepository { 8 | 9 | User findByUsername(String name); 10 | } 11 | -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/rest/IndexController.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz.rest; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class IndexController { 8 | 9 | @RequestMapping("/") 10 | public String getIndexPage(){ 11 | return "UserManagement"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/service/UserService.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz.service; 2 | 3 | import java.util.List; 4 | 5 | import pe.joedayz.modelo.User; 6 | 7 | 8 | 9 | 10 | 11 | public interface UserService { 12 | 13 | User findById(long id); 14 | 15 | User findByName(String name); 16 | 17 | void saveUser(User user); 18 | 19 | void updateUser(User user); 20 | 21 | void deleteUserById(long id); 22 | 23 | List findAllUsers(); 24 | 25 | void deleteAllUsers(); 26 | 27 | public boolean isUserExist(User user); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bootangular/src/main/java/pe/joedayz/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz.service; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | import java.util.concurrent.atomic.AtomicLong; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import pe.joedayz.modelo.User; 12 | import pe.joedayz.repository.UserRepository; 13 | 14 | 15 | 16 | @Service("userService") 17 | @Transactional 18 | public class UserServiceImpl implements UserService{ 19 | 20 | private static final AtomicLong counter = new AtomicLong(); 21 | 22 | private static List users; 23 | 24 | @Autowired 25 | private UserRepository userRepository; 26 | 27 | 28 | public List findAllUsers() { 29 | return (List) userRepository.findAll(); 30 | } 31 | 32 | public User findById(long id) { 33 | return userRepository.findOne(id); 34 | } 35 | 36 | public User findByName(String name) { 37 | return userRepository.findByUsername(name); 38 | } 39 | 40 | public void saveUser(User user) { 41 | userRepository.save(user); 42 | } 43 | 44 | public void updateUser(User user) { 45 | userRepository.save(user); 46 | } 47 | 48 | public void deleteUserById(long id) { 49 | userRepository.delete(id); 50 | 51 | } 52 | 53 | public boolean isUserExist(User user) { 54 | return findByName(user.getUsername())!=null; 55 | } 56 | 57 | public void deleteAllUsers(){ 58 | userRepository.deleteAll(); 59 | } 60 | 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /bootangular/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mvc.view.prefix: /WEB-INF/jsp/ 2 | spring.mvc.view.suffix: .jsp 3 | 4 | spring.datasource.url=jdbc:mysql://localhost/bootangular 5 | spring.datasource.username=root 6 | spring.datasource.password=12345678 7 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 8 | 9 | spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect 10 | spring.jpa.show-sql=true 11 | spring.jpa.hibernate.ddl-auto=update -------------------------------------------------------------------------------- /bootangular/src/main/resources/static/css/app.css: -------------------------------------------------------------------------------- 1 | body, #mainWrapper { 2 | height: 70%; 3 | background-color:rgb(245, 245, 245); 4 | } 5 | 6 | body, .form-control{ 7 | font-size:12px!important; 8 | } 9 | 10 | .floatRight{ 11 | float:right; 12 | margin-right: 18px; 13 | } 14 | 15 | .has-error{ 16 | color:red; 17 | } 18 | 19 | .formcontainer{ 20 | background-color: #DAE8E8; 21 | padding: 20px; 22 | } 23 | 24 | .tablecontainer{ 25 | padding-left: 20px; 26 | } 27 | 28 | .generic-container { 29 | width:80%; 30 | margin-left: 20px; 31 | margin-top: 20px; 32 | margin-bottom: 20px; 33 | padding: 20px; 34 | background-color: #EAE7E7; 35 | border: 1px solid #ddd; 36 | border-radius: 4px; 37 | box-shadow: 0 0 30px black; 38 | } 39 | 40 | .custom-width { 41 | width: 80px !important; 42 | } 43 | -------------------------------------------------------------------------------- /bootangular/src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var App = angular.module('myApp',[]); 4 | 5 | 6 | -------------------------------------------------------------------------------- /bootangular/src/main/resources/static/js/service/user_service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | App.factory('UserService', ['$http', '$q', function($http, $q){ 4 | 5 | return { 6 | 7 | fetchAllUsers: function() { 8 | return $http.get('http://localhost:8080/user/') 9 | .then( 10 | function(response){ 11 | return response.data; 12 | }, 13 | function(errResponse){ 14 | console.error('Error while fetching users'); 15 | return $q.reject(errResponse); 16 | } 17 | ); 18 | }, 19 | 20 | createUser: function(user){ 21 | return $http.post('http://localhost:8080/user/', user) 22 | .then( 23 | function(response){ 24 | return response.data; 25 | }, 26 | function(errResponse){ 27 | console.error('Error while creating user'); 28 | return $q.reject(errResponse); 29 | } 30 | ); 31 | }, 32 | 33 | updateUser: function(user, id){ 34 | return $http.put('http://localhost:8080/user/'+id, user) 35 | .then( 36 | function(response){ 37 | return response.data; 38 | }, 39 | function(errResponse){ 40 | console.error('Error while updating user'); 41 | return $q.reject(errResponse); 42 | } 43 | ); 44 | }, 45 | 46 | deleteUser: function(id){ 47 | return $http.delete('http://localhost:8080/user/'+id) 48 | .then( 49 | function(response){ 50 | return response.data; 51 | }, 52 | function(errResponse){ 53 | console.error('Error while deleting user'); 54 | return $q.reject(errResponse); 55 | } 56 | ); 57 | } 58 | 59 | }; 60 | 61 | }]); 62 | -------------------------------------------------------------------------------- /bootangular/src/test/java/pe/joedayz/BootangularApplicationTests.java: -------------------------------------------------------------------------------- 1 | package pe.joedayz; 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 BootangularApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /cfp-example/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/cfp-example/.DS_Store -------------------------------------------------------------------------------- /cfp-example/README.adoc: -------------------------------------------------------------------------------- 1 | = 10 ways to get super-productive with Spring Boot 2 | 3 | This sample project is going to be used for a talk demoing how Spring Boot helps 4 | you to be super-productive. -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/CfpApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp; 2 | 3 | import javax.cache.configuration.MutableConfiguration; 4 | import javax.cache.expiry.CreatedExpiryPolicy; 5 | import javax.cache.expiry.Duration; 6 | 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; 10 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 11 | import org.springframework.cache.annotation.EnableCaching; 12 | import org.springframework.context.annotation.Bean; 13 | 14 | @SpringBootApplication 15 | @EnableConfigurationProperties(CfpProperties.class) 16 | @EnableCaching 17 | public class CfpApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(CfpApplication.class, args); 21 | } 22 | 23 | @Bean 24 | public JCacheManagerCustomizer cacheManagerCustomizer() { 25 | return cm -> { 26 | cm.createCache("github.commits", initConfiguration(Duration.TEN_MINUTES)); 27 | cm.createCache("github.polishCommit", initConfiguration(Duration.ONE_HOUR)); 28 | cm.createCache("github.user", initConfiguration(Duration.ONE_HOUR)); 29 | }; 30 | } 31 | 32 | private MutableConfiguration initConfiguration(Duration duration) { 33 | return new MutableConfiguration<>() 34 | .setStoreByValue(false) 35 | .setStatisticsEnabled(true) 36 | .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(duration)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/CfpProperties.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | 8 | @ConfigurationProperties("cfp") 9 | public class CfpProperties { 10 | 11 | private final Github github = new Github(); 12 | 13 | private final Security security = new Security(); 14 | 15 | public Github getGithub() { 16 | return this.github; 17 | } 18 | 19 | public Security getSecurity() { 20 | return this.security; 21 | } 22 | 23 | 24 | public static class Github { 25 | 26 | /** 27 | * Access token ("username:access_token") to query public github endpoints. 28 | */ 29 | private String token; 30 | 31 | public String getToken() { 32 | return this.token; 33 | } 34 | 35 | public void setToken(String token) { 36 | this.token = token; 37 | } 38 | } 39 | 40 | public static class Security { 41 | 42 | /** 43 | * Github users that have admin rights. 44 | */ 45 | private List admins = Arrays.asList("snicoll", "bclozel", "joedayz"); 46 | 47 | public List getAdmins() { 48 | return admins; 49 | } 50 | 51 | public void setAdmins(List admins) { 52 | this.admins = admins; 53 | } 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/domain/SubmissionRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.PagingAndSortingRepository; 6 | 7 | public interface SubmissionRepository extends PagingAndSortingRepository { 8 | 9 | List findBySpeaker(User user); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/domain/SubmissionStatus.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | public enum SubmissionStatus { 4 | 5 | DRAFT("Draft"), 6 | 7 | SUBMITTED("Submitted"), 8 | 9 | ACCEPTED("Accepted"), 10 | 11 | REJECTED("Rejected"); 12 | 13 | private String displayName; 14 | 15 | SubmissionStatus(String displayName) { 16 | this.displayName = displayName; 17 | } 18 | 19 | public String getDisplayName() { 20 | return this.displayName; 21 | } 22 | 23 | public String getId() { 24 | return name(); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/domain/Track.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | public enum Track { 4 | 5 | ALTERNATE_LANGUAGES("Alternate Languages"), 6 | 7 | CLOUD("Cloud"), 8 | 9 | SERVER_SIDE_JAVA("Server side Java"), 10 | 11 | MOBILE("Mobile"), 12 | 13 | WEB("Web"); 14 | 15 | private String displayName; 16 | 17 | Track(String displayName) { 18 | this.displayName = displayName; 19 | } 20 | 21 | public String getDisplayName() { 22 | return this.displayName; 23 | } 24 | 25 | public String getId() { 26 | return name(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/domain/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | 7 | public interface UserRepository extends CrudRepository { 8 | 9 | User findByTwitter(String twitter); 10 | 11 | User findByGithub(String github); 12 | 13 | Collection findByName(String lastName); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/integration/github/Commit.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.integration.github; 2 | 3 | import java.io.Serializable; 4 | import java.time.Instant; 5 | 6 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 7 | 8 | @JsonDeserialize(using = CommitDeserializer.class) 9 | @SuppressWarnings("serial") 10 | public class Commit implements Serializable { 11 | 12 | private final String sha; 13 | 14 | private final String message; 15 | 16 | private final Committer committer; 17 | 18 | private final Instant date; 19 | 20 | public Commit(String sha, String message, Committer committer, Instant date) { 21 | this.sha = sha; 22 | this.message = message; 23 | this.committer = committer; 24 | this.date = date; 25 | } 26 | 27 | public String getSha() { 28 | return this.sha; 29 | } 30 | 31 | public String getMessage() { 32 | return this.message; 33 | } 34 | 35 | public Instant getDate() { 36 | return this.date; 37 | } 38 | 39 | public Committer getCommitter() { 40 | return this.committer; 41 | } 42 | 43 | public static class Committer implements Serializable { 44 | 45 | private final String id; 46 | 47 | private final String name; 48 | 49 | private final String avatarUrl; 50 | 51 | public Committer(String id, String name, String avatarUrl) { 52 | this.id = id; 53 | this.name = name; 54 | this.avatarUrl = avatarUrl; 55 | } 56 | 57 | public String getId() { 58 | return this.id; 59 | } 60 | 61 | public String getName() { 62 | return this.name; 63 | } 64 | 65 | public String getAvatarUrl() { 66 | return this.avatarUrl; 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/integration/github/CommitDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.integration.github; 2 | 3 | import java.io.IOException; 4 | import java.time.Instant; 5 | 6 | import com.fasterxml.jackson.core.JsonParser; 7 | import com.fasterxml.jackson.core.ObjectCodec; 8 | import com.fasterxml.jackson.databind.DeserializationContext; 9 | import com.fasterxml.jackson.databind.JsonNode; 10 | 11 | import org.springframework.boot.jackson.JsonObjectDeserializer; 12 | 13 | public class CommitDeserializer extends JsonObjectDeserializer { 14 | 15 | @Override 16 | protected Commit deserializeObject(JsonParser jsonParser, 17 | DeserializationContext deserializationContext, 18 | ObjectCodec objectCodec, JsonNode jsonNode) throws IOException { 19 | 20 | JsonNode commitNode = jsonNode.get("commit"); 21 | JsonNode committerNode = jsonNode.get("committer"); 22 | String sha = nullSafeValue(jsonNode.get("sha"), String.class); 23 | String message = singleLine(nullSafeValue(commitNode.get("message"), String.class)); 24 | 25 | String committerId = nullSafeValue(committerNode.get("login"), String.class); 26 | String committerName = nullSafeValue(commitNode.get("committer").get("name"), String.class); 27 | String date = nullSafeValue(commitNode.get("committer").get("date"), String.class); 28 | String committerAvatar = nullSafeValue(committerNode.get("avatar_url"), String.class); 29 | Commit.Committer committer = 30 | new Commit.Committer(committerId, committerName, committerAvatar); 31 | return new Commit(sha, message, committer, Instant.parse(date)); 32 | } 33 | 34 | private String singleLine(String s) { 35 | if (s == null) { 36 | return null; 37 | } 38 | int i = s.indexOf('\n'); 39 | if (i != -1) { 40 | return s.substring(0, i); 41 | } 42 | return s; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/integration/github/GithubUser.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.integration.github; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | @SuppressWarnings("serial") 8 | public class GithubUser implements Serializable { 9 | 10 | private String email; 11 | 12 | private String name; 13 | 14 | private String company; 15 | 16 | private String blog; 17 | 18 | private String avatar; 19 | 20 | public String getEmail() { 21 | return this.email; 22 | } 23 | 24 | public void setEmail(String email) { 25 | this.email = email; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getCompany() { 37 | return this.company; 38 | } 39 | 40 | public void setCompany(String company) { 41 | this.company = company; 42 | } 43 | 44 | public String getBlog() { 45 | return this.blog; 46 | } 47 | 48 | public void setBlog(String blog) { 49 | this.blog = blog; 50 | } 51 | 52 | public String getAvatar() { 53 | return avatar; 54 | } 55 | 56 | @JsonProperty("avatar_url") 57 | public void setAvatarUrl(String avatar) { 58 | this.avatar = avatar; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/submission/SubmissionRequest.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.submission; 2 | 3 | import com.example.cfp.domain.Track; 4 | import com.example.cfp.domain.User; 5 | 6 | public class SubmissionRequest { 7 | 8 | private User speaker; 9 | 10 | private String title; 11 | 12 | private String summary; 13 | 14 | private Track track; 15 | 16 | private String notes; 17 | 18 | public User getSpeaker() { 19 | return this.speaker; 20 | } 21 | 22 | public void setSpeaker(User speaker) { 23 | this.speaker = speaker; 24 | } 25 | 26 | public String getTitle() { 27 | return this.title; 28 | } 29 | 30 | public void setTitle(String title) { 31 | this.title = title; 32 | } 33 | 34 | public String getSummary() { 35 | return this.summary; 36 | } 37 | 38 | public void setSummary(String summary) { 39 | this.summary = summary; 40 | } 41 | 42 | public Track getTrack() { 43 | return this.track; 44 | } 45 | 46 | public void setTrack(Track track) { 47 | this.track = track; 48 | } 49 | 50 | public String getNotes() { 51 | return this.notes; 52 | } 53 | 54 | public void setNotes(String notes) { 55 | this.notes = notes; 56 | } 57 | 58 | public void setTalk(String title, String summary, Track track, String notes) { 59 | setTitle(title); 60 | setSummary(summary); 61 | setTrack(track); 62 | setNotes(notes); 63 | } 64 | 65 | @Override 66 | public boolean equals(Object o) { 67 | if (this == o) return true; 68 | if (o == null || getClass() != o.getClass()) return false; 69 | 70 | SubmissionRequest that = (SubmissionRequest) o; 71 | 72 | if (this.speaker != null ? !this.speaker.equals(that.speaker) : that.speaker != null) return false; 73 | if (this.title != null ? !this.title.equals(that.title) : that.title != null) return false; 74 | if (this.summary != null ? !this.summary.equals(that.summary) : that.summary != null) return false; 75 | return this.track == that.track; 76 | } 77 | 78 | @Override 79 | public int hashCode() { 80 | int result = this.speaker != null ? this.speaker.hashCode() : 0; 81 | result = 31 * result + (this.title != null ? this.title.hashCode() : 0); 82 | result = 31 * result + (this.summary != null ? this.summary.hashCode() : 0); 83 | result = 31 * result + (this.track != null ? this.track.hashCode() : 0); 84 | return result; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/submission/SubmissionService.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.submission; 2 | 3 | import com.example.cfp.domain.Submission; 4 | import com.example.cfp.domain.SubmissionRepository; 5 | 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | @Service 10 | public class SubmissionService { 11 | 12 | private final SubmissionRepository submissionRepository; 13 | 14 | public SubmissionService(SubmissionRepository submissionRepository) { 15 | this.submissionRepository = submissionRepository; 16 | } 17 | 18 | @Transactional 19 | public Submission create(SubmissionRequest request) { 20 | Submission submission = new Submission(); 21 | submission.setSpeaker(request.getSpeaker()); 22 | submission.setTitle(request.getTitle()); 23 | submission.setSummary(request.getSummary()); 24 | submission.setTrack(request.getTrack()); 25 | submission.setNotes(request.getNotes()); 26 | return this.submissionRepository.save(submission); 27 | } 28 | 29 | protected SubmissionRepository getSubmissionRepository() { 30 | return this.submissionRepository; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import com.example.cfp.domain.SubmissionRepository; 4 | import com.example.cfp.domain.SubmissionStatus; 5 | 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | @Controller 11 | @Navigation(Section.ADMIN) 12 | @RequestMapping("/admin") 13 | public class AdminController { 14 | 15 | private final SubmissionRepository submissionRepository; 16 | 17 | public AdminController(SubmissionRepository submissionRepository) { 18 | this.submissionRepository = submissionRepository; 19 | } 20 | 21 | @RequestMapping("") 22 | public String admin(Model model) { 23 | 24 | model.addAttribute("submissions", this.submissionRepository.findAll()); 25 | model.addAttribute("viewHelper", new ViewRenderingHelper()); 26 | return "admin/index"; 27 | } 28 | 29 | static class ViewRenderingHelper { 30 | 31 | public String submissionTableClass(SubmissionStatus status) { 32 | if (SubmissionStatus.ACCEPTED.equals(status)) { 33 | return "success"; 34 | } 35 | else if (SubmissionStatus.REJECTED.equals(status)) { 36 | return "error"; 37 | } 38 | return ""; 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import com.example.cfp.integration.github.Commit; 4 | import com.example.cfp.integration.github.GithubClient; 5 | 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | @Controller 11 | @Navigation(Section.HOME) 12 | public class HomeController { 13 | 14 | private final GithubClient githubClient; 15 | 16 | public HomeController(GithubClient githubClient) { 17 | this.githubClient = githubClient; 18 | } 19 | 20 | @RequestMapping("/") 21 | public String home(Model model) { 22 | model.addAttribute("latestFrameworkCommit", 23 | getLatestCommit("spring-projects", "spring-framework")); 24 | model.addAttribute("latestBootCommit", 25 | getLatestCommit("spring-projects", "spring-boot")); 26 | return "index"; 27 | } 28 | 29 | private Commit getLatestCommit(String organization, String project) { 30 | return this.githubClient 31 | .getRecentCommits(organization, project) 32 | .stream().findFirst().get(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/Navigation.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface Navigation { 11 | 12 | Section value(); 13 | 14 | } -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/NewsController.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import java.time.Duration; 4 | import java.time.Instant; 5 | import java.util.List; 6 | import java.util.Objects; 7 | import java.util.stream.Collectors; 8 | import java.util.stream.Stream; 9 | 10 | import com.example.cfp.integration.github.Commit; 11 | import com.example.cfp.integration.github.GithubClient; 12 | 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.Model; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | 17 | @Controller 18 | @Navigation(Section.NEWS) 19 | public class NewsController { 20 | 21 | private final GithubClient githubClient; 22 | 23 | public NewsController(GithubClient githubClient) { 24 | this.githubClient = githubClient; 25 | } 26 | 27 | @RequestMapping("/news") 28 | public String home(Model model) { 29 | model.addAttribute("latestFrameworkCommits", 30 | getRecentCommits("spring-projects", "spring-framework")); 31 | model.addAttribute("latestBootCommits", 32 | getRecentCommits("spring-projects", "spring-boot")); 33 | model.addAttribute("daysSinceLastPolish", daysSinceLastPolishCommit()); 34 | return "news"; 35 | } 36 | 37 | private List getRecentCommits(String organization, String project) { 38 | return this.githubClient 39 | .getRecentCommits(organization, project) 40 | .stream().limit(5).collect(Collectors.toList()); 41 | } 42 | 43 | private long daysSinceLastPolishCommit() { 44 | Commit fwkCommit = this.githubClient.getRecentPolishCommit("spring-projects", "spring-framework"); 45 | Commit bootCommit = this.githubClient.getRecentPolishCommit("spring-projects", "spring-boot"); 46 | Instant instant = Stream.of(fwkCommit, bootCommit) 47 | .filter(Objects::nonNull) 48 | .map(Commit::getDate) 49 | .max(Instant::compareTo).get(); 50 | return Duration.between(instant, Instant.now()).toDays(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/Section.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | public enum Section { 4 | HOME, SUBMIT, NEWS, ADMIN 5 | } -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/SubmissionForm.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | import com.example.cfp.domain.Track; 6 | import org.hibernate.validator.constraints.NotEmpty; 7 | 8 | class SubmissionForm { 9 | 10 | @NotEmpty(message="Title should not be empty") 11 | private String title; 12 | 13 | @NotEmpty(message="Summary should not be empty") 14 | private String summary; 15 | 16 | @NotNull 17 | private Track track; 18 | 19 | private String notes; 20 | 21 | public String getTitle() { 22 | return this.title; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | public String getSummary() { 30 | return this.summary; 31 | } 32 | 33 | public void setSummary(String summary) { 34 | this.summary = summary; 35 | } 36 | 37 | public Track getTrack() { 38 | return this.track; 39 | } 40 | 41 | public void setTrack(Track track) { 42 | this.track = track; 43 | } 44 | 45 | public String getNotes() { 46 | return this.notes; 47 | } 48 | 49 | public void setNotes(String notes) { 50 | this.notes = notes; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /cfp-example/src/main/java/com/example/cfp/web/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.web; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.method.HandlerMethod; 8 | import org.springframework.web.servlet.ModelAndView; 9 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 10 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 12 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 13 | 14 | @Configuration 15 | class WebConfig extends WebMvcConfigurerAdapter { 16 | 17 | @Override 18 | public void addViewControllers(ViewControllerRegistry registry) { 19 | registry.addViewController("/login").setViewName("login"); 20 | } 21 | 22 | @Override 23 | public void addInterceptors(InterceptorRegistry registry) { 24 | registry.addInterceptor(new HandlerInterceptorAdapter() { 25 | @Override 26 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, 27 | ModelAndView modelAndView) throws Exception { 28 | 29 | if (handler instanceof HandlerMethod) { 30 | HandlerMethod handlerMethod = (HandlerMethod) handler; 31 | Navigation navSection = handlerMethod.getBean().getClass().getAnnotation(Navigation.class); 32 | if (navSection != null && modelAndView != null) { 33 | modelAndView.addObject("navSection", navSection.value().toString().toLowerCase()); 34 | } 35 | } 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/application-local.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost/cfp?useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=12345678 4 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/application-secrets.properties: -------------------------------------------------------------------------------- 1 | # Works on localhost:8080 only 2 | security.oauth2.client.client-id=f3ef83172f75b8154e90 3 | security.oauth2.client.client-secret=fbea03d70467583bdb39b718032028d5e6d56161 -------------------------------------------------------------------------------- /cfp-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.profiles.include=secrets 2 | 3 | spring.jpa.hibernate.ddl-auto=none 4 | 5 | spring.jackson.serialization.write_dates_as_timestamps=false 6 | 7 | management.context-path=/admin 8 | spring.h2.console.path=/admin/h2-console 9 | 10 | security.oauth2.client.access-token-uri=https://github.com/login/oauth/access_token 11 | security.oauth2.client.user-authorization-uri=https://github.com/login/oauth/authorize 12 | security.oauth2.client.client-authentication-scheme=form 13 | security.oauth2.resource.user-info-uri=https://api.github.com/user -------------------------------------------------------------------------------- /cfp-example/src/main/resources/db/migration/V1_1__Add_Notes.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE SUBMISSION ADD notes TEXT; -------------------------------------------------------------------------------- /cfp-example/src/main/resources/db/migration/V1__Initial_Setup.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE USER ( 2 | id BIGINT auto_increment, 3 | email VARCHAR(100), 4 | name VARCHAR(100) NOT NULL, 5 | github VARCHAR(30), 6 | twitter VARCHAR(30), 7 | avatar_url VARCHAR(200), 8 | bio TEXT, 9 | PRIMARY KEY (id) 10 | ); 11 | 12 | CREATE TABLE SUBMISSION ( 13 | id BIGINT auto_increment, 14 | speaker_id BIGINT, 15 | title VARCHAR(100), 16 | status INTEGER, 17 | summary TEXT, 18 | track INT, 19 | PRIMARY KEY (id) 20 | ); -------------------------------------------------------------------------------- /cfp-example/src/main/resources/static/img/cfp-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/cfp-example/src/main/resources/static/img/cfp-background.png -------------------------------------------------------------------------------- /cfp-example/src/main/resources/templates/admin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Admin - Submissions list 4 | 5 | 6 | 7 | 8 | 9 | Cfp proposals 10 | 11 | 12 | 13 | 14 | # 15 | Title 16 | Speaker 17 | Track 18 | 19 | 20 | 21 | 22 | 1 23 | What's new in Spring Boot 1.4 24 | John Doe 25 | Track name 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/templates/error/4xx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ooops, page not found 5 | 15 | 16 | 17 | 18 | 19 | ¯\_(ツ)_/¯ 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Home 4 | 5 | 6 | 7 | 8 | 9 | Spring Conference 10 | 11 | 12 | 13 | 14 | Submit a talk to the CfP! 15 | Share your passion 16 | Submit 17 | 18 | 19 | 20 | 21 | Latest commits 22 | 23 | 24 | 25 | Spring Framework 26 | 27 | 28 | 29 | Fix a Spring Framework issue 30 | Committed by [[${latestFrameworkCommit.committer.name}]] 31 | 32 | 33 | 34 | 35 | Spring Boot 36 | 37 | 38 | 39 | Fix a Spring Boot issue 40 | Committed by [[${latestBootCommit.committer.name}]] 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cfp login page 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Please login 12 | 13 | 14 | 15 | Invalid username and password. 16 | 17 | 18 | You have been logged out. 19 | 20 | 21 | Username 22 | 23 | 24 | 25 | 26 | 27 | Password 28 | 29 | 30 | 31 | 32 | 33 | 34 | Sign in 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /cfp-example/src/main/resources/templates/news.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | News 4 | 5 | 6 | 7 | 8 | 9 | 10 | 2 DAYS 11 | 12 | since last Polish 13 | 14 | 15 | 16 | Latest commits on Spring Framework 17 | 18 | 19 | 20 | 21 | deadb33f 22 | Fix a Spring Framework issue 23 | Committed by [[${commit.committer.name}]] 24 | 25 | 26 | 27 | Latest commits on Spring Boot 28 | 29 | 30 | 31 | 32 | deadb33f 33 | Fix a Spring Framework issue 34 | Committed by [[${commit.committer.name}]] 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /cfp-example/src/test/java/com/example/cfp/domain/SubmissionTest.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase; 10 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 11 | import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | 16 | @RunWith(SpringRunner.class) 17 | @DataJpaTest 18 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 19 | public class SubmissionTest { 20 | 21 | @Autowired 22 | private TestEntityManager entityManager; 23 | 24 | @Autowired 25 | public SubmissionRepository submissionRepository; 26 | 27 | @Test 28 | public void newSubmissionHasDraftStatus() { 29 | User speaker = this.entityManager.persist( 30 | new User("juergen@example.com", "Jürgen Höller")); 31 | Submission submission = new Submission(); 32 | submission.setSpeaker(speaker); 33 | Submission saved = this.submissionRepository.save(submission); 34 | assertThat(saved.getStatus()).isEqualTo(SubmissionStatus.DRAFT); 35 | } 36 | 37 | @Test 38 | public void findBySpeaker() { 39 | User speaker = this.entityManager.persist( 40 | new User("juergen@example.com", "Jürgen Höller")); 41 | this.submissionRepository.save(createDummySubmission(speaker, "Foo")); 42 | this.submissionRepository.save(createDummySubmission(speaker, "Bar")); 43 | 44 | List submissions = this.submissionRepository.findBySpeaker(speaker); 45 | assertThat(submissions).hasSize(2); 46 | } 47 | 48 | private Submission createDummySubmission(User speaker, String title) { 49 | Submission submission = new Submission(); 50 | submission.setSpeaker(speaker); 51 | submission.setTitle(title); 52 | submission.setSummary("Live coding 4tw"); 53 | submission.setTrack(Track.SERVER_SIDE_JAVA); 54 | return submission; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /cfp-example/src/test/java/com/example/cfp/domain/UserTest.java: -------------------------------------------------------------------------------- 1 | package com.example.cfp.domain; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; 9 | import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase; 10 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | 15 | @RunWith(SpringRunner.class) 16 | @DataJpaTest 17 | @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) 18 | @ImportAutoConfiguration(FlywayAutoConfiguration.class) 19 | public class UserTest { 20 | 21 | @Autowired 22 | private UserRepository userRepository; 23 | 24 | @Test 25 | public void findByGithub() { 26 | User user = new User("brian@example.com", "Brian Clozel"); 27 | user.setGithub("bclozel"); 28 | this.userRepository.save(user); 29 | 30 | User brian = this.userRepository.findByGithub("bclozel"); 31 | assertThat(brian).isNotNull(); 32 | assertThat(brian.getName()).isEqualTo("Brian Clozel"); 33 | } 34 | 35 | @Test 36 | public void findByTwitter() { 37 | User user = new User("juergen@example.com", "Jürgen Höller"); 38 | user.setTwitter("springjuergen"); 39 | this.userRepository.save(user); 40 | 41 | User juergen = this.userRepository.findByTwitter("springjuergen"); 42 | assertThat(juergen).isNotNull(); 43 | assertThat(juergen.getName()).isEqualTo("Jürgen Höller"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /cfp-example/src/test/resources/github/jsmith.json: -------------------------------------------------------------------------------- 1 | { 2 | "login": "jsmith", 3 | "id": 123412341234, 4 | "avatar_url": "https://acme.org/team/jsmith/avatar", 5 | "gravatar_id": "", 6 | "url": "https://api.github.com/users/jsmith", 7 | "html_url": "https://github.com/jsmith", 8 | "followers_url": "https://api.github.com/users/jsmith/followers", 9 | "following_url": "https://api.github.com/users/jsmith/following{/other_user}", 10 | "gists_url": "https://api.github.com/users/jsmith/gists{/gist_id}", 11 | "starred_url": "https://api.github.com/users/jsmith/starred{/owner}{/repo}", 12 | "subscriptions_url": "https://api.github.com/users/jsmith/subscriptions", 13 | "organizations_url": "https://api.github.com/users/jsmith/orgs", 14 | "repos_url": "https://api.github.com/users/jsmith/repos", 15 | "events_url": "https://api.github.com/users/jsmith/events{/privacy}", 16 | "received_events_url": "https://api.github.com/users/jsmith/received_events", 17 | "type": "User", 18 | "site_admin": false, 19 | "name": "John Smith", 20 | "company": "Acme Inc.", 21 | "blog": "https://acme.org/blog", 22 | "location": null, 23 | "email": "john@example.com", 24 | "hireable": null, 25 | "bio": null, 26 | "public_repos": 55, 27 | "public_gists": 40, 28 | "followers": 145, 29 | "following": 13, 30 | "created_at": "2010-11-21T10:27:20Z", 31 | "updated_at": "2016-04-11T08:28:18Z" 32 | } -------------------------------------------------------------------------------- /cfp-example/src/test/resources/github/no-commit.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cfp-example/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /demo-boot-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /demo-boot-jpa/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /demo-boot-jpa/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /demo-boot-jpa/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /demo-boot-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo-boot-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mycompany 7 | demobootjpa 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | demo-boot-jpa 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.2.5.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-freemarker 34 | 35 | 36 | 37 | org.hsqldb 38 | hsqldb 39 | runtime 40 | 41 | 42 | 43 | mysql 44 | mysql-connector-java 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/DemoBootJpaApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoBootJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoBootJpaApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/controller/InicioController.java: -------------------------------------------------------------------------------- 1 | package demo.controller; 2 | 3 | 4 | 5 | import java.util.List; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.servlet.ModelAndView; 12 | 13 | import demo.domain.Nota; 14 | import demo.repository.NotaRepository; 15 | 16 | @Controller 17 | public class InicioController { 18 | 19 | @Autowired 20 | private NotaRepository notaRepository; 21 | 22 | @RequestMapping("/") 23 | @Transactional(readOnly=true) 24 | public ModelAndView inicio(){ 25 | List notas = notaRepository.findAll(); 26 | ModelAndView mav = new ModelAndView("inicio"); 27 | mav.addObject("notas",notas); 28 | return mav; 29 | } 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/domain/Etiqueta.java: -------------------------------------------------------------------------------- 1 | package demo.domain; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.ManyToMany; 10 | 11 | @Entity 12 | public class Etiqueta { 13 | 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.AUTO) 16 | private long id; 17 | 18 | private String nombre; 19 | 20 | @ManyToMany(mappedBy="etiquetas") 21 | private List notas; 22 | 23 | public long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getNombre() { 32 | return nombre; 33 | } 34 | 35 | public void setNombre(String nombre) { 36 | this.nombre = nombre; 37 | } 38 | 39 | public List getNotas() { 40 | return notas; 41 | } 42 | 43 | public void setNotas(List notas) { 44 | this.notas = notas; 45 | } 46 | 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/domain/Nota.java: -------------------------------------------------------------------------------- 1 | package demo.domain; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.ManyToMany; 10 | 11 | @Entity 12 | public class Nota { 13 | 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.AUTO) 16 | private long id; 17 | 18 | private String titulo; 19 | 20 | private String contenido; 21 | 22 | @ManyToMany 23 | private List etiquetas; 24 | 25 | public long getId() { 26 | return id; 27 | } 28 | 29 | public void setId(long id) { 30 | this.id = id; 31 | } 32 | 33 | public String getTitulo() { 34 | return titulo; 35 | } 36 | 37 | public void setTitulo(String titulo) { 38 | this.titulo = titulo; 39 | } 40 | 41 | public String getContenido() { 42 | return contenido; 43 | } 44 | 45 | public void setContenido(String contenido) { 46 | this.contenido = contenido; 47 | } 48 | 49 | public List getEtiquetas() { 50 | return etiquetas; 51 | } 52 | 53 | public void setEtiquetas(List etiquetas) { 54 | this.etiquetas = etiquetas; 55 | } 56 | 57 | 58 | 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/repository/EtiquetaRepository.java: -------------------------------------------------------------------------------- 1 | package demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import demo.domain.Etiqueta; 6 | 7 | public interface EtiquetaRepository { 8 | 9 | List findAll(); 10 | } 11 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/repository/JpaEtiquetaRepository.java: -------------------------------------------------------------------------------- 1 | package demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | 8 | import org.springframework.stereotype.Repository; 9 | 10 | import demo.domain.Etiqueta; 11 | 12 | @Repository 13 | public class JpaEtiquetaRepository implements EtiquetaRepository { 14 | 15 | 16 | @PersistenceContext 17 | private EntityManager entityManager; 18 | 19 | 20 | @Override 21 | public List findAll() { 22 | return this.entityManager.createQuery("SELECT e FROM Etiqueta e",Etiqueta.class) 23 | .getResultList(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/repository/JpaNotaRepository.java: -------------------------------------------------------------------------------- 1 | package demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | 8 | import org.springframework.stereotype.Repository; 9 | 10 | import demo.domain.Nota; 11 | 12 | @Repository 13 | public class JpaNotaRepository implements NotaRepository { 14 | 15 | @PersistenceContext 16 | private EntityManager entityManager; 17 | 18 | @Override 19 | public List findAll() { 20 | return this.entityManager.createQuery("SELECT n FROM Nota n", Nota.class) 21 | .getResultList(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/java/demo/repository/NotaRepository.java: -------------------------------------------------------------------------------- 1 | package demo.repository; 2 | 3 | import java.util.List; 4 | 5 | import demo.domain.Nota; 6 | 7 | public interface NotaRepository { 8 | 9 | List findAll(); 10 | } 11 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring.datasource.url=jdbc:mysql://localhost/notas 4 | spring.datasource.username=root 5 | spring.datasource.password=password 6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | 9 | spring.jpa.show-sql = true 10 | 11 | spring.jpa.hibernate.ddl-auto = create -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/resources/import.txt: -------------------------------------------------------------------------------- 1 | insert into etiqueta(nombre) values ('Spring projects') 2 | insert into etiqueta(nombre) values ('Apache projects') 3 | insert into etiqueta(nombre) values ('Open source') 4 | 5 | insert into nota(titulo, contenido) values ('Spring Boot', 'Takes an opinionated view of building production-ready Spring applications.') 6 | insert into nota(titulo, contenido) values ('Spring Framework', 'Core support for dependency injection, transaction management, web applications, data access, messaging, testing and more.') 7 | insert into nota(titulo, contenido) values ('Spring Integration', 'Extends the Spring programming model to support the well-known Enterprise Integration Patterns.') 8 | insert into nota(titulo, contenido) values ('Tomcat', 'Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.') 9 | 10 | insert into nota_etiquetas(notas_id, etiquetas_id) values (1, 1) 11 | insert into nota_etiquetas(notas_id, etiquetas_id) values (2, 1) 12 | insert into nota_etiquetas(notas_id, etiquetas_id) values (3, 1) 13 | insert into nota_etiquetas(notas_id, etiquetas_id) values (1, 3) 14 | insert into nota_etiquetas(notas_id, etiquetas_id) values (2, 3) 15 | insert into nota_etiquetas(notas_id, etiquetas_id) values (3, 3) 16 | insert into nota_etiquetas(notas_id, etiquetas_id) values (4, 2) 17 | insert into nota_etiquetas(notas_id, etiquetas_id) values (4, 3) -------------------------------------------------------------------------------- /demo-boot-jpa/src/main/resources/templates/inicio.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Title 10 | Body 11 | Tags 12 | 13 | 14 | 15 | <#list notas as note> 16 | 17 | ${note.titulo} 18 | ${note.contenido} 19 | 20 | <#list note.etiquetas as tag> 21 | ${tag.nombre} 22 | #list> 23 | 24 | 25 | #list> 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /demo-boot-jpa/src/test/java/demo/DemoBootJpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.web.WebAppConfiguration; 6 | import org.springframework.boot.test.SpringApplicationConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | @RunWith(SpringJUnit4ClassRunner.class) 10 | @SpringApplicationConfiguration(classes = DemoBootJpaApplication.class) 11 | @WebAppConfiguration 12 | public class DemoBootJpaApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /demo-boot-jpa/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: demo-boot-jpa 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: Celeritech Peru 5 | Implementation-Vendor-Id: com.mycompany 6 | Build-Jdk: 1.8.0_45 7 | Created-By: Maven Integration for Eclipse 8 | Implementation-Vendor: Pivotal Software, Inc. 9 | 10 | -------------------------------------------------------------------------------- /demo-boot-jpa/target/classes/META-INF/maven/com.mycompany/demobootjpa/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon Sep 07 11:53:58 COT 2015 3 | version=0.0.1-SNAPSHOT 4 | groupId=com.mycompany 5 | m2e.projectName=demobootjpa 6 | m2e.projectLocation=C\:\\joe\\spring-boot-samples\\demo-boot-jpa 7 | artifactId=demobootjpa 8 | -------------------------------------------------------------------------------- /demo-boot-jpa/target/classes/META-INF/maven/com.mycompany/demobootjpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mycompany 7 | demobootjpa 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | demo-boot-jpa 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.2.5.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-freemarker 34 | 35 | 36 | 37 | org.hsqldb 38 | hsqldb 39 | runtime 40 | 41 | 42 | 43 | mysql 44 | mysql-connector-java 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /demo-boot-jpa/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | spring.datasource.url=jdbc:mysql://localhost/notas 4 | spring.datasource.username=root 5 | spring.datasource.password=password 6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | 9 | spring.jpa.show-sql = true 10 | 11 | spring.jpa.hibernate.ddl-auto = create -------------------------------------------------------------------------------- /demo-data-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /demo-data-jpa/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /demo-data-jpa/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /demo-data-jpa/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles=pom.xml 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /demo-data-jpa/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo-data-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.mycompany 7 | demodatajpa 8 | 1.0 9 | jar 10 | 11 | demo-data-jpa 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.2.5.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | org.hsqldb 38 | hsqldb 39 | runtime 40 | 41 | 42 | mysql 43 | mysql-connector-java 44 | runtime 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-test 49 | test 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/DemoDataJpaApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoDataJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoDataJpaApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/controller/HotelController.java: -------------------------------------------------------------------------------- 1 | package demo.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.transaction.annotation.Transactional; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | import demo.service.CityService; 11 | 12 | @Controller 13 | public class HotelController { 14 | 15 | @Autowired 16 | private CityService cityService; 17 | 18 | @RequestMapping("/") 19 | @ResponseBody 20 | @Transactional(readOnly=true) 21 | public String hola(){ 22 | return this.cityService.getCity("Bath", "UK") 23 | .getName(); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/City.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | 19 | import java.io.Serializable; 20 | 21 | import javax.persistence.Column; 22 | import javax.persistence.Entity; 23 | import javax.persistence.GeneratedValue; 24 | import javax.persistence.Id; 25 | 26 | @Entity 27 | public class City implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @Id 32 | @GeneratedValue 33 | private Long id; 34 | 35 | @Column(nullable = false) 36 | private String name; 37 | 38 | @Column(nullable = false) 39 | private String state; 40 | 41 | @Column(nullable = false) 42 | private String country; 43 | 44 | @Column(nullable = false) 45 | private String map; 46 | 47 | protected City() { 48 | } 49 | 50 | public City(String name, String country) { 51 | super(); 52 | this.name = name; 53 | this.country = country; 54 | } 55 | 56 | public String getName() { 57 | return this.name; 58 | } 59 | 60 | public String getState() { 61 | return this.state; 62 | } 63 | 64 | public String getCountry() { 65 | return this.country; 66 | } 67 | 68 | public String getMap() { 69 | return this.map; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return getName() + "," + getState() + "," + getCountry(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/Hotel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | import java.io.Serializable; 19 | import java.util.Set; 20 | 21 | import javax.persistence.Column; 22 | import javax.persistence.Entity; 23 | import javax.persistence.FetchType; 24 | import javax.persistence.GeneratedValue; 25 | import javax.persistence.Id; 26 | import javax.persistence.ManyToOne; 27 | import javax.persistence.OneToMany; 28 | 29 | import org.hibernate.annotations.NaturalId; 30 | 31 | @Entity 32 | public class Hotel implements Serializable { 33 | 34 | private static final long serialVersionUID = 1L; 35 | 36 | @Id 37 | @GeneratedValue 38 | private Long id; 39 | 40 | @ManyToOne(optional = false) 41 | @NaturalId 42 | private City city; 43 | 44 | @Column(nullable = false) 45 | @NaturalId 46 | private String name; 47 | 48 | @Column(nullable = false) 49 | private String address; 50 | 51 | @Column(nullable = false) 52 | private String zip; 53 | 54 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "hotel") 55 | private Set reviews; 56 | 57 | protected Hotel() { 58 | } 59 | 60 | public Hotel(City city, String name) { 61 | this.city = city; 62 | this.name = name; 63 | } 64 | 65 | public City getCity() { 66 | return this.city; 67 | } 68 | 69 | public String getName() { 70 | return this.name; 71 | } 72 | 73 | public String getAddress() { 74 | return this.address; 75 | } 76 | 77 | public String getZip() { 78 | return this.zip; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/HotelSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | import java.io.Serializable; 19 | import java.math.BigDecimal; 20 | import java.math.MathContext; 21 | import java.math.RoundingMode; 22 | 23 | public class HotelSummary implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | private static final MathContext MATH_CONTEXT = new MathContext(2, 28 | RoundingMode.HALF_UP); 29 | 30 | private final City city; 31 | 32 | private final String name; 33 | 34 | private final Double averageRating; 35 | 36 | private final Integer averageRatingRounded; 37 | 38 | public HotelSummary(City city, String name, Double averageRating) { 39 | this.city = city; 40 | this.name = name; 41 | this.averageRating = averageRating == null ? null : new BigDecimal(averageRating, 42 | MATH_CONTEXT).doubleValue(); 43 | this.averageRatingRounded = averageRating == null ? null : (int) Math 44 | .round(averageRating); 45 | } 46 | 47 | public City getCity() { 48 | return this.city; 49 | } 50 | 51 | public String getName() { 52 | return this.name; 53 | } 54 | 55 | public Double getAverageRating() { 56 | return this.averageRating; 57 | } 58 | 59 | public Integer getAverageRatingRounded() { 60 | return this.averageRatingRounded; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/Rating.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | public enum Rating { 19 | TERRIBLE, POOR, AVERAGE, GOOD, EXCELLENT, 20 | } 21 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/RatingCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | import java.io.Serializable; 19 | 20 | public class RatingCount implements Serializable { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | private final Rating rating; 25 | 26 | private final long count; 27 | 28 | public RatingCount(Rating rating, long count) { 29 | this.rating = rating; 30 | this.count = count; 31 | } 32 | 33 | public Rating getRating() { 34 | return this.rating; 35 | } 36 | 37 | public long getCount() { 38 | return this.count; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/ReviewDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.domain; 18 | import java.io.Serializable; 19 | import java.util.Date; 20 | 21 | public class ReviewDetails implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | private Rating rating; 26 | 27 | private Date checkInDate; 28 | 29 | private TripType tripType; 30 | 31 | private String title; 32 | 33 | private String details; 34 | 35 | public ReviewDetails() { 36 | } 37 | 38 | public Rating getRating() { 39 | return this.rating; 40 | } 41 | 42 | public void setRating(Rating rating) { 43 | this.rating = rating; 44 | } 45 | 46 | public Date getCheckInDate() { 47 | return this.checkInDate; 48 | } 49 | 50 | public void setCheckInDate(Date checkInDate) { 51 | this.checkInDate = checkInDate; 52 | } 53 | 54 | public TripType getTripType() { 55 | return this.tripType; 56 | } 57 | 58 | public void setTripType(TripType tripType) { 59 | this.tripType = tripType; 60 | } 61 | 62 | public String getTitle() { 63 | return this.title; 64 | } 65 | 66 | public void setTitle(String title) { 67 | this.title = title; 68 | } 69 | 70 | public String getDetails() { 71 | return this.details; 72 | } 73 | 74 | public void setDetails(String details) { 75 | this.details = details; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/domain/TripType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package demo.domain; 17 | public enum TripType { 18 | BUSINESS, COUPLES, FAMILY, FRIENDS, SOLO 19 | } 20 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/CityRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | 19 | import org.springframework.data.domain.Page; 20 | import org.springframework.data.domain.Pageable; 21 | import org.springframework.data.repository.Repository; 22 | 23 | import demo.domain.City; 24 | 25 | interface CityRepository extends Repository { 26 | 27 | Page findAll(Pageable pageable); 28 | 29 | Page findByNameContainingAndCountryContainingAllIgnoringCase(String name, 30 | String country, Pageable pageable); 31 | 32 | City findByNameAndCountryAllIgnoringCase(String name, String country); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/CitySearchCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import java.io.Serializable; 19 | 20 | import org.springframework.util.Assert; 21 | 22 | public class CitySearchCriteria implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | private String name; 27 | 28 | public CitySearchCriteria() { 29 | } 30 | 31 | public CitySearchCriteria(String name) { 32 | Assert.notNull(name, "Name must not be null"); 33 | this.name = name; 34 | } 35 | 36 | public String getName() { 37 | return this.name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/CityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import org.springframework.data.domain.Page; 19 | import org.springframework.data.domain.Pageable; 20 | 21 | import demo.domain.City; 22 | import demo.domain.HotelSummary; 23 | 24 | public interface CityService { 25 | 26 | Page findCities(CitySearchCriteria criteria, Pageable pageable); 27 | 28 | City getCity(String name, String country); 29 | 30 | Page getHotels(City city, Pageable pageable); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/HotelRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import java.util.List; 19 | 20 | import org.springframework.data.domain.Page; 21 | import org.springframework.data.domain.Pageable; 22 | import org.springframework.data.jpa.repository.Query; 23 | import org.springframework.data.repository.Repository; 24 | 25 | import demo.domain.City; 26 | import demo.domain.Hotel; 27 | import demo.domain.HotelSummary; 28 | import demo.domain.RatingCount; 29 | 30 | interface HotelRepository extends Repository { 31 | 32 | Hotel findByCityAndName(City city, String name); 33 | 34 | @Query("select new demo.domain.HotelSummary(h.city, h.name, avg(r.rating)) " 35 | + "from Hotel h left outer join h.reviews r where h.city = ?1 group by h") 36 | Page findByCity(City city, Pageable pageable); 37 | 38 | @Query("select new demo.domain.RatingCount(r.rating, count(r)) " 39 | + "from Review r where r.hotel = ?1 group by r.rating order by r.rating DESC") 40 | List findRatingCounts(Hotel hotel); 41 | } 42 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/HotelService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import org.springframework.data.domain.Page; 19 | import org.springframework.data.domain.Pageable; 20 | 21 | import demo.domain.City; 22 | import demo.domain.Hotel; 23 | import demo.domain.Review; 24 | import demo.domain.ReviewDetails; 25 | 26 | public interface HotelService { 27 | 28 | Hotel getHotel(City city, String name); 29 | 30 | Page getReviews(Hotel hotel, Pageable pageable); 31 | 32 | Review getReview(Hotel hotel, int index); 33 | 34 | Review addReview(Hotel hotel, ReviewDetails details); 35 | 36 | ReviewsSummary getReviewSummary(Hotel hotel); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/ReviewRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import org.springframework.data.domain.Page; 19 | import org.springframework.data.domain.Pageable; 20 | import org.springframework.data.repository.Repository; 21 | 22 | import demo.domain.Hotel; 23 | import demo.domain.Review; 24 | 25 | interface ReviewRepository extends Repository { 26 | 27 | Page findByHotel(Hotel hotel, Pageable pageable); 28 | 29 | Review findByHotelAndIndex(Hotel hotel, int index); 30 | 31 | Review save(Review review); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/java/demo/service/ReviewsSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package demo.service; 18 | import demo.domain.Rating; 19 | 20 | public interface ReviewsSummary { 21 | 22 | long getNumberOfReviewsWithRating(Rating rating); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /demo-data-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | debug=true 2 | 3 | 4 | -------------------------------------------------------------------------------- /demo-data-jpa/src/test/java/demo/DemoDataJpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.SpringApplicationConfiguration; 8 | import org.springframework.test.context.ActiveProfiles; 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 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 13 | import org.springframework.web.context.WebApplicationContext; 14 | 15 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; 16 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; 17 | 18 | 19 | 20 | @RunWith(SpringJUnit4ClassRunner.class) 21 | @SpringApplicationConfiguration(classes = DemoDataJpaApplication.class) 22 | @WebAppConfiguration 23 | @ActiveProfiles("qa") 24 | public class DemoDataJpaApplicationTests { 25 | 26 | @Autowired 27 | private WebApplicationContext context; 28 | 29 | private MockMvc mvc; 30 | 31 | @Before 32 | public void inicio(){ 33 | this.mvc = MockMvcBuilders. 34 | webAppContextSetup(context).build(); 35 | } 36 | 37 | @Test 38 | public void testHome() throws Exception { 39 | 40 | this.mvc.perform(get("/")).andExpect(status().isOk()) 41 | .andExpect(content().string("Bath")); 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /demo-data-jpa/src/test/java/demo/service/CityRepositoryIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package demo.service; 17 | 18 | import static org.hamcrest.Matchers.greaterThan; 19 | import static org.hamcrest.Matchers.is; 20 | import static org.junit.Assert.assertThat; 21 | 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.boot.test.SpringApplicationConfiguration; 26 | import org.springframework.data.domain.Page; 27 | import org.springframework.data.domain.PageRequest; 28 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 29 | 30 | import demo.DemoDataJpaApplication; 31 | import demo.domain.City; 32 | 33 | /** 34 | * Integration tests for {@link CityRepository}. 35 | * 36 | * @author Oliver Gierke 37 | */ 38 | @RunWith(SpringJUnit4ClassRunner.class) 39 | @SpringApplicationConfiguration(classes = DemoDataJpaApplication.class) 40 | public class CityRepositoryIntegrationTests { 41 | 42 | @Autowired 43 | CityRepository repository; 44 | 45 | @Test 46 | public void findsFirstPageOfCities() { 47 | 48 | Page cities = this.repository.findAll(new PageRequest(0, 10)); 49 | assertThat(cities.getTotalElements(), is(greaterThan(20L))); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /demo-data-jpa/src/test/resources/application-qa.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url: jdbc:hsqldb:mem:qadb 2 | spring.jmx.default_domain: jpait .sample -------------------------------------------------------------------------------- /spring-boot-activemq/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /spring-boot-activemq/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /spring-boot-activemq/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /spring-boot-activemq/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-boot-activemq/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-activemq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | pe.joedayz 7 | demoactivemq 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | Demo ActiveMQ 12 | Demo ActiveMQ with Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.2.5.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter 30 | 31 | 32 | 33 | org.springframework 34 | spring-jms 35 | 36 | 37 | 38 | org.apache.activemq 39 | activemq-broker 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-maven-plugin 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/demo/ActiveMQConfig.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import javax.jms.ConnectionFactory; 4 | import javax.jms.Queue; 5 | 6 | import org.apache.activemq.ActiveMQConnectionFactory; 7 | import org.apache.activemq.command.ActiveMQQueue; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.jms.annotation.EnableJms; 11 | import org.springframework.jms.connection.CachingConnectionFactory; 12 | import org.springframework.jms.core.JmsTemplate; 13 | 14 | @Configuration 15 | @EnableJms 16 | public class ActiveMQConfig { 17 | 18 | @Bean 19 | public ConnectionFactory connectionFactory() { 20 | return new CachingConnectionFactory(new ActiveMQConnectionFactory("" 21 | + "tcp://localhost:61616")); 22 | } 23 | 24 | @Bean 25 | JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) { 26 | return new JmsTemplate(connectionFactory); 27 | } 28 | 29 | @Bean 30 | public Queue queue() { 31 | return new ActiveMQQueue("sample.queue"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/demo/Consumer.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.jms.annotation.JmsListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Consumer { 8 | 9 | @JmsListener(destination = "sample.queue") 10 | public void receiveQueue(String text) { 11 | System.out.println(text); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/demo/DemoActiveMqApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoActiveMqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoActiveMqApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/demo/Producer.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import javax.jms.Queue; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.jms.core.JmsTemplate; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class Producer { 12 | 13 | @Autowired 14 | private JmsTemplate jmsTemplate; 15 | 16 | @Autowired 17 | private Queue queue; 18 | 19 | public void send(String msg) { 20 | this.jmsTemplate.convertAndSend(this.queue, msg); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.activemq.in-memory=true 2 | spring.activemq.pooled=false -------------------------------------------------------------------------------- /spring-boot-activemq/src/test/java/demo/DemoActiveMqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import javax.jms.JMSException; 4 | 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.OutputCapture; 10 | import org.springframework.boot.test.SpringApplicationConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | @RunWith(SpringJUnit4ClassRunner.class) 15 | @SpringApplicationConfiguration(classes = DemoActiveMqApplication.class) 16 | public class DemoActiveMqApplicationTests { 17 | 18 | @Rule 19 | public OutputCapture outputCapture = 20 | new OutputCapture(); 21 | 22 | @Autowired 23 | private Producer producer; 24 | 25 | @Test 26 | public void sendSimpleMessage() throws InterruptedException, JMSException{ 27 | this.producer.send("Test message"); 28 | Thread.sleep(3000); 29 | assertTrue(this.outputCapture.toString().contains("Test message")); 30 | } 31 | 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db-1.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db-1.log -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db.data -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db.redo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/spring-boot-jms-javaconfig/activemq-data/embedded/KahaDB/db.redo -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | xpadro.spring 7 | jms-boot-javaconfig 8 | 0.0.1-SNAPSHOT 9 | jar 10 | JMS Spring Boot Javaconfig 11 | 12 | 13 | org.springframework.boot 14 | spring-boot-starter-parent 15 | 1.2.3.RELEASE 16 | 17 | 18 | 19 | 20 | UTF-8 21 | xpadro.spring.jms.JmsJavaconfigApplication 22 | 1.8 23 | 5.4.2 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter 30 | 31 | 32 | org.springframework 33 | spring-jms 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | org.apache.activemq 44 | activemq-core 45 | ${amq.version} 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/JmsJavaconfigApplication.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JmsJavaconfigApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(JmsJavaconfigApplication.class, args); 11 | } 12 | } -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/listener/InListener.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.listener; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.jms.annotation.JmsListener; 5 | import org.springframework.messaging.handler.annotation.SendTo; 6 | import org.springframework.stereotype.Component; 7 | 8 | import xpadro.spring.jms.model.Order; 9 | import xpadro.spring.jms.service.StoreService; 10 | 11 | @Component 12 | public class InListener { 13 | private final StoreService storeService; 14 | 15 | @Autowired 16 | public InListener(StoreService storeService) { 17 | this.storeService = storeService; 18 | } 19 | 20 | @JmsListener(destination = "in.queue") 21 | @SendTo("out.queue") 22 | public String receiveOrder(Order order) { 23 | storeService.registerOrder(order); 24 | return order.getId(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/listener/OutListener.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.listener; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.jms.annotation.JmsListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | import xpadro.spring.jms.service.RegisterService; 8 | 9 | @Component 10 | public class OutListener { 11 | private final RegisterService registerService; 12 | 13 | @Autowired 14 | public OutListener(RegisterService registerService) { 15 | this.registerService = registerService; 16 | } 17 | 18 | @JmsListener(destination = "out.queue") 19 | public void receiveOrder(String orderId) { 20 | registerService.registerOrderId(orderId); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/listener/SimpleListener.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.listener; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.jms.annotation.JmsListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | import xpadro.spring.jms.model.Order; 8 | import xpadro.spring.jms.service.StoreService; 9 | 10 | @Component 11 | public class SimpleListener { 12 | private final StoreService storeService; 13 | 14 | @Autowired 15 | public SimpleListener(StoreService storeService) { 16 | this.storeService = storeService; 17 | } 18 | 19 | @JmsListener(destination = "simple.queue") 20 | public void receiveOrder(Order order) { 21 | storeService.registerOrder(order); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/model/Order.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Order implements Serializable { 6 | private static final long serialVersionUID = -797586847427389162L; 7 | 8 | private final String id; 9 | 10 | public Order(String id) { 11 | this.id = id; 12 | } 13 | 14 | public String getId() { 15 | return id; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/ClientService.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | import xpadro.spring.jms.model.Order; 4 | 5 | public interface ClientService { 6 | 7 | void addOrder(Order order); 8 | 9 | void registerOrder(Order order); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/ClientServiceImpl.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.jms.core.JmsTemplate; 5 | import org.springframework.stereotype.Service; 6 | 7 | import xpadro.spring.jms.model.Order; 8 | 9 | @Service 10 | public class ClientServiceImpl implements ClientService { 11 | private static final String SIMPLE_QUEUE = "simple.queue"; 12 | private static final String IN_QUEUE = "in.queue"; 13 | 14 | private final JmsTemplate jmsTemplate; 15 | 16 | @Autowired 17 | public ClientServiceImpl(JmsTemplate jmsTemplate) { 18 | this.jmsTemplate = jmsTemplate; 19 | } 20 | 21 | @Override 22 | public void addOrder(Order order) { 23 | jmsTemplate.convertAndSend(SIMPLE_QUEUE, order); 24 | } 25 | 26 | @Override 27 | public void registerOrder(Order order) { 28 | jmsTemplate.convertAndSend(IN_QUEUE, order); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/RegisterService.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | public interface RegisterService { 4 | void registerOrderId(String orderId); 5 | 6 | String getLastReceivedOrderId(); 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/RegisterServiceImpl.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class RegisterServiceImpl implements RegisterService { 7 | private String lastReceivedOrder; 8 | 9 | @Override 10 | public void registerOrderId(String orderId) { 11 | this.lastReceivedOrder = orderId; 12 | } 13 | 14 | @Override 15 | public String getLastReceivedOrderId() { 16 | return this.lastReceivedOrder; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/StoreService.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | import java.util.Optional; 4 | 5 | import xpadro.spring.jms.model.Order; 6 | 7 | public interface StoreService { 8 | 9 | void registerOrder(Order order); 10 | 11 | Optional getReceivedOrder(String id); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/main/java/xpadro/spring/jms/service/StoreServiceImpl.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import org.springframework.stereotype.Service; 8 | 9 | import xpadro.spring.jms.model.Order; 10 | 11 | @Service 12 | public class StoreServiceImpl implements StoreService { 13 | private final List receivedOrders = new ArrayList<>(); 14 | 15 | @Override 16 | public void registerOrder(Order order) { 17 | this.receivedOrders.add(order); 18 | } 19 | 20 | @Override 21 | public Optional getReceivedOrder(String id) { 22 | return receivedOrders.stream().filter(o -> o.getId().equals(id)).findFirst(); 23 | } 24 | } -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/test/java/xpadro/spring/jms/InOutListenerTest.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms; 2 | 3 | 4 | import java.util.Optional; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.SpringApplicationConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | 13 | import xpadro.spring.jms.model.Order; 14 | import xpadro.spring.jms.service.ClientService; 15 | import xpadro.spring.jms.service.RegisterService; 16 | import xpadro.spring.jms.service.StoreService; 17 | 18 | @RunWith(SpringJUnit4ClassRunner.class) 19 | @SpringApplicationConfiguration(classes = JmsJavaconfigApplication.class) 20 | public class InOutListenerTest { 21 | 22 | @Autowired 23 | private ClientService clientService; 24 | 25 | @Autowired 26 | private StoreService storeService; 27 | 28 | @Autowired 29 | private RegisterService registerService; 30 | 31 | @Test 32 | public void registerOrder() throws InterruptedException { 33 | clientService.registerOrder(new Order("order1")); 34 | Thread.sleep(1000); 35 | 36 | Optional storedOrder = storeService.getReceivedOrder("order1"); 37 | Assert.assertTrue(storedOrder.isPresent()); 38 | Assert.assertEquals("order1", storedOrder.get().getId()); 39 | Assert.assertEquals("order1", registerService.getLastReceivedOrderId()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-jms-javaconfig/src/test/java/xpadro/spring/jms/SimpleListenerTest.java: -------------------------------------------------------------------------------- 1 | package xpadro.spring.jms; 2 | 3 | 4 | import java.util.Optional; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.SpringApplicationConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | 13 | import xpadro.spring.jms.model.Order; 14 | import xpadro.spring.jms.service.ClientService; 15 | import xpadro.spring.jms.service.StoreService; 16 | 17 | 18 | @RunWith(SpringJUnit4ClassRunner.class) 19 | @SpringApplicationConfiguration(classes = JmsJavaconfigApplication.class) 20 | public class SimpleListenerTest { 21 | 22 | @Autowired 23 | private ClientService clientService; 24 | 25 | @Autowired 26 | private StoreService storeService; 27 | 28 | @Test 29 | public void sendSimpleMessage() throws InterruptedException { 30 | clientService.addOrder(new Order("order1")); 31 | Thread.sleep(500); 32 | 33 | Optional storedOrder = storeService.getReceivedOrder("order1"); 34 | Assert.assertTrue(storedOrder.isPresent()); 35 | Assert.assertEquals("order1", storedOrder.get().getId()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-messaging/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.2.5.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE") 11 | } 12 | } 13 | 14 | apply plugin: 'java' 15 | apply plugin: 'eclipse' 16 | apply plugin: 'idea' 17 | apply plugin: 'spring-boot' 18 | apply plugin: 'io.spring.dependency-management' 19 | 20 | jar { 21 | baseName = 'demo' 22 | version = '0.0.1-SNAPSHOT' 23 | } 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | repositories { 28 | mavenCentral() 29 | } 30 | 31 | 32 | dependencies { 33 | compile("org.springframework.boot:spring-boot-starter-web") 34 | compile("org.springframework.boot:spring-boot-starter-websocket") 35 | compile("org.springframework:spring-messaging") 36 | compile("org.springframework:spring-jms:4.1.5.RELEASE") 37 | compile("org.springframework.security:spring-security-web:3.2.6.RELEASE") 38 | compile("org.springframework.security:spring-security-config:3.2.6.RELEASE") 39 | compile("org.apache.camel:camel-spring-boot:2.15.0") 40 | compile("org.apache.activemq:activemq-camel:5.10.0") 41 | testCompile("junit:junit") 42 | } 43 | 44 | eclipse { 45 | classpath { 46 | containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 47 | containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' 48 | } 49 | } 50 | 51 | task wrapper(type: Wrapper) { 52 | gradleVersion = '2.3' 53 | } 54 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/Application.java: -------------------------------------------------------------------------------- 1 | package messaging; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ConfigurableApplicationContext; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | ConfigurableApplicationContext context = SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/config/CamelConfig.java: -------------------------------------------------------------------------------- 1 | package messaging.config; 2 | 3 | import javax.jms.ConnectionFactory; 4 | 5 | import org.apache.activemq.ActiveMQConnectionFactory; 6 | import org.apache.activemq.pool.PooledConnectionFactory; 7 | import org.apache.camel.builder.RouteBuilder; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class CamelConfig { 13 | 14 | @Bean 15 | ConnectionFactory jmsConnectionFactory() { 16 | // use a pool for ActiveMQ connections 17 | PooledConnectionFactory pool = new PooledConnectionFactory(); 18 | pool.setConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616")); 19 | return pool; 20 | } 21 | 22 | @Bean 23 | RouteBuilder myRouter() { 24 | return new RouteBuilder() { 25 | 26 | @Override 27 | public void configure() throws Exception { 28 | // listen the queue named rt_messages and upon receiving a new entry 29 | // simply redirect it to a bean named queueHandler which will then send it to users over STOMP 30 | from("activemq:rt_messages").to("bean:queueHandler"); 31 | } 32 | }; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package messaging.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.core.session.SessionRegistry; 12 | import org.springframework.security.core.session.SessionRegistryImpl; 13 | import org.springframework.security.web.session.HttpSessionEventPublisher; 14 | 15 | 16 | @Configuration 17 | @EnableWebSecurity 18 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 19 | 20 | @Autowired 21 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 22 | // configure a simple in-memory authentication with three users 23 | auth.inMemoryAuthentication() 24 | .withUser("user1").password("pass1").roles("USER") 25 | .and() 26 | .withUser("user2").password("pass2").roles("USER") 27 | .and() 28 | .withUser("user3").password("pass3").roles("USER"); 29 | } 30 | 31 | @Bean 32 | public SessionRegistry sessionRegistry() { 33 | return new SessionRegistryImpl(); 34 | } 35 | 36 | @Bean 37 | public ServletListenerRegistrationBean httpSessionEventPublisher() { 38 | return new ServletListenerRegistrationBean(new HttpSessionEventPublisher()); 39 | } 40 | 41 | @Override 42 | protected void configure(HttpSecurity http) throws Exception { 43 | super.configure(http); 44 | // disable CSRF for simplicity and configure a session registry which will allow us to fetch a list of users 45 | http.csrf().disable().sessionManagement(). 46 | maximumSessions(-1).sessionRegistry(sessionRegistry()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package messaging.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 5 | import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; 6 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 7 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 8 | 9 | @Configuration 10 | @EnableWebSocketMessageBroker 11 | public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { 12 | 13 | @Override 14 | public void configureMessageBroker(MessageBrokerRegistry config) { 15 | // use the /topic prefix for outgoing WebSocket communication 16 | config.enableSimpleBroker("/topic"); 17 | 18 | // use the /app prefix for others 19 | config.setApplicationDestinationPrefixes("/app"); 20 | } 21 | 22 | @Override 23 | public void registerStompEndpoints(StompEndpointRegistry registry) { 24 | // use the /messaging endpoint (prefixed with /app as configured above) for incoming requests 25 | registry.addEndpoint("/messaging").withSockJS(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/controllers/APIController.java: -------------------------------------------------------------------------------- 1 | package messaging.controllers; 2 | 3 | 4 | import java.security.Principal; 5 | import java.util.Set; 6 | import java.util.stream.Collectors; 7 | 8 | import messaging.dto.MessageDTO; 9 | 10 | import org.apache.camel.CamelContext; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.beans.factory.annotation.Qualifier; 13 | import org.springframework.security.core.session.SessionRegistry; 14 | import org.springframework.security.core.userdetails.User; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | @RestController 21 | public class APIController { 22 | 23 | @Autowired 24 | private CamelContext camelContext; 25 | 26 | @Autowired 27 | @Qualifier("sessionRegistry") 28 | private SessionRegistry sessionRegistry; 29 | 30 | /** 31 | * Receives the messages from clients and sends them to ActiveMQ. 32 | * 33 | * @param message the message to send, encapsulated in a wrapper 34 | */ 35 | @RequestMapping(value = "/send", method = RequestMethod.POST, consumes = "application/json") 36 | public void sendMessage(@RequestBody MessageDTO message, Principal currentUser) { 37 | // send any message sent by clients to a queue called rt_messages 38 | message.from = currentUser.getName(); 39 | camelContext.createProducerTemplate().sendBody("activemq:rt_messages", message); 40 | } 41 | 42 | /** 43 | * Returns the names of the currently logged-in users. 44 | * 45 | * @return set of user names 46 | */ 47 | @RequestMapping(value = "/users", method = RequestMethod.GET, produces = "application/json") 48 | public Set getUsers() { 49 | // get the list of users from Spring Security's session registry 50 | return sessionRegistry.getAllPrincipals().stream().map(u -> ((User) u).getUsername()).collect(Collectors.toSet()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/controllers/WebSocketController.java: -------------------------------------------------------------------------------- 1 | package messaging.controllers; 2 | 3 | 4 | import java.security.Principal; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.messaging.Message; 8 | import org.springframework.messaging.handler.annotation.MessageMapping; 9 | import org.springframework.messaging.simp.SimpMessageHeaderAccessor; 10 | import org.springframework.messaging.simp.SimpMessagingTemplate; 11 | import org.springframework.stereotype.Controller; 12 | 13 | @Controller 14 | public class WebSocketController { 15 | 16 | @Autowired 17 | private SimpMessagingTemplate messageTemplate; 18 | 19 | /** 20 | * Listens the /app/messaging endpoint and when a message is received, gets the user information encapsulated within it, and informs all clients 21 | * listening at the /topic/users endpoint that the user has joined the topic. 22 | * 23 | * @param message the encapsulated STOMP message 24 | */ 25 | @MessageMapping("/messaging") 26 | public void messaging(Message message) { 27 | // get the user associated with the message 28 | Principal user = message.getHeaders().get(SimpMessageHeaderAccessor.USER_HEADER, Principal.class); 29 | // notify all users that a user has joined the topic 30 | messageTemplate.convertAndSend("/topic/users", user.getName()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/dto/MessageDTO.java: -------------------------------------------------------------------------------- 1 | package messaging.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | 7 | /** 8 | * A simple DTO class to encapsulate messages along with their destinations and timestamps. 9 | */ 10 | public class MessageDTO implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | public Date date; 15 | public String content; 16 | public String to; 17 | public String from; 18 | 19 | public MessageDTO() { 20 | this.date = Calendar.getInstance().getTime(); 21 | } 22 | } -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/java/demo/handlers/QueueHandler.java: -------------------------------------------------------------------------------- 1 | package messaging.handlers; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import messaging.dto.MessageDTO; 7 | 8 | import org.apache.camel.Exchange; 9 | import org.apache.camel.Message; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.messaging.MessageHeaders; 12 | import org.springframework.messaging.simp.SimpMessageSendingOperations; 13 | import org.springframework.stereotype.Component; 14 | import org.springframework.util.MimeTypeUtils; 15 | 16 | /** 17 | * Receives messages from ActiveMQ and relays them to appropriate users. 18 | */ 19 | @Component(value = "queueHandler") 20 | public class QueueHandler { 21 | 22 | @Autowired 23 | private SimpMessageSendingOperations msgTemplate; 24 | 25 | private static Map defaultHeaders; 26 | 27 | static { 28 | defaultHeaders = new HashMap(); 29 | // add the Content-Type: application/json header by default 30 | defaultHeaders.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON); 31 | } 32 | 33 | public void handle(Exchange exchange) { 34 | Message camelMessage = exchange.getIn(); 35 | MessageDTO message = camelMessage.getBody(MessageDTO.class); 36 | // send the message specifically to the destination user by using STOMP's user-directed messaging 37 | msgTemplate.convertAndSendToUser(message.to, "/topic/messages", message, defaultHeaders); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration goes here 2 | -------------------------------------------------------------------------------- /spring-boot-messaging/src/test/java/demo/Demowebsocket3ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.SpringApplicationConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | @RunWith(SpringJUnit4ClassRunner.class) 9 | @SpringApplicationConfiguration(classes = Demowebsocket3Application.class) 10 | public class Demowebsocket3ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.6 6 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | com.mycompany 9 | 10 | 11 | 12 | spring-boot-sample-data-mongodb 13 | 1.0 14 | jar 15 | 16 | 17 | Spring Boot Data MongoDB Sample 18 | Spring Boot Data MongoDB Sample 19 | http://projects.spring.io/spring-boot/ 20 | 21 | Pivotal Software, Inc. 22 | http://www.spring.io 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-parent 30 | 1.2.5.RELEASE 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-data-mongodb 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | 50 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-maven-plugin 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sample.data.mongo; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | public class Customer { 22 | 23 | @Id 24 | private String id; 25 | 26 | private String firstName; 27 | private String lastName; 28 | 29 | public Customer() { 30 | } 31 | 32 | public Customer(String firstName, String lastName) { 33 | this.firstName = firstName; 34 | this.lastName = lastName; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return String.format("Customer[id=%s, firstName='%s', lastName='%s']", id, 40 | firstName, lastName); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sample.data.mongo; 18 | 19 | import java.util.List; 20 | 21 | import org.springframework.data.mongodb.repository.MongoRepository; 22 | 23 | public interface CustomerRepository extends MongoRepository { 24 | 25 | public Customer findByFirstName(String firstName); 26 | 27 | public List findByLastName(String lastName); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-websocket/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE") 7 | } 8 | } 9 | 10 | apply plugin: 'java' 11 | apply plugin: 'eclipse' 12 | apply plugin: 'idea' 13 | apply plugin: 'spring-boot' 14 | 15 | jar { 16 | baseName = 'gs-messaging-stomp-websocket' 17 | version = '0.1.0' 18 | } 19 | sourceCompatibility = 1.8 20 | targetCompatibility = 1.8 21 | 22 | repositories { 23 | mavenCentral() 24 | } 25 | 26 | sourceCompatibility = 1.8 27 | targetCompatibility = 1.8 28 | 29 | dependencies { 30 | compile("org.springframework.boot:spring-boot-starter-websocket") 31 | compile("org.springframework:spring-messaging") 32 | testCompile("junit:junit") 33 | } 34 | 35 | task wrapper(type: Wrapper) { 36 | gradleVersion = '2.3' 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-websocket/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/spring-boot-websocket/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-websocket/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 15 13:53:13 EDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip 7 | -------------------------------------------------------------------------------- /spring-boot-websocket/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | gs-messaging-stomp-websocket 8 | 0.1.0 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | 1.2.5.RELEASE 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-websocket 20 | 21 | 22 | org.springframework 23 | spring-messaging 24 | 25 | 26 | 27 | 28 | 1.8 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-maven-plugin 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/hello/Greeting.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class Greeting { 4 | 5 | private String content; 6 | 7 | public Greeting(String content) { 8 | this.content = content; 9 | } 10 | 11 | public String getContent() { 12 | return content; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/hello/GreetingController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.messaging.handler.annotation.MessageMapping; 4 | import org.springframework.messaging.handler.annotation.SendTo; 5 | import org.springframework.stereotype.Controller; 6 | 7 | @Controller 8 | public class GreetingController { 9 | 10 | 11 | @MessageMapping("/hello") 12 | @SendTo("/topic/greetings") 13 | public Greeting greeting(HelloMessage message) throws Exception { 14 | Thread.sleep(3000); // simulated delay 15 | return new Greeting("Hello, " + message.getName() + "!"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/hello/HelloMessage.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | public class HelloMessage { 4 | 5 | private String name; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/hello/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 5 | import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; 6 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 7 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 8 | 9 | @Configuration 10 | @EnableWebSocketMessageBroker 11 | public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { 12 | 13 | @Override 14 | public void configureMessageBroker(MessageBrokerRegistry config) { 15 | config.enableSimpleBroker("/topic"); 16 | config.setApplicationDestinationPrefixes("/app"); 17 | } 18 | 19 | @Override 20 | public void registerStompEndpoints(StompEndpointRegistry registry) { 21 | registry.addEndpoint("/hello").withSockJS(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /spring-boot-ws-holiday/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//target/generated-sources/xjc=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/java/demo/DemoSpringWsApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoSpringWsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoSpringWsApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/java/demo/service/HumanResourceService.java: -------------------------------------------------------------------------------- 1 | package demo.service; 2 | 3 | import java.util.Date; 4 | 5 | public interface HumanResourceService { 6 | 7 | void bookHoliday(Date startDate, Date endDate, String name); 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/java/demo/service/StubHumanResourceService.java: -------------------------------------------------------------------------------- 1 | package demo.service; 2 | 3 | import java.util.Date; 4 | //slf4j es el default 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class StubHumanResourceService implements HumanResourceService { 11 | 12 | private final Logger logger = LoggerFactory.getLogger(StubHumanResourceService.class); 13 | 14 | @Override 15 | public void bookHoliday(Date startDate, Date endDate, String name) { 16 | this.logger.info("Booking holiday for [{} - {}] for [{}] ", startDate, endDate, 17 | name); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/resources/META-INF/schemas/hr.xsd: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/resources/META-INF/schemas/students.xsd: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /spring-boot-ws-holiday/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/spring-boot-ws-holiday/src/main/resources/application.properties -------------------------------------------------------------------------------- /visitas/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /visitas/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /visitas/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /visitas/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/MvcConfig.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 7 | 8 | @Configuration 9 | public class MvcConfig extends WebMvcConfigurerAdapter { 10 | 11 | @Override 12 | public void addViewControllers(ViewControllerRegistry registry) { 13 | registry.addViewController("/home").setViewName("home"); 14 | registry.addViewController("/admin").setViewName("admin"); 15 | registry.addViewController("/login").setViewName("login"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/VisitasApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class VisitasApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(VisitasApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 9 | 10 | 11 | @Configuration 12 | @EnableWebSecurity 13 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 14 | @Override 15 | protected void configure(HttpSecurity http) throws Exception { 16 | http 17 | .authorizeRequests() 18 | .antMatchers("/", "/home").permitAll() 19 | .anyRequest().authenticated() 20 | .and() 21 | .formLogin() 22 | .loginPage("/login") 23 | .permitAll() 24 | .and() 25 | .logout() 26 | .permitAll(); 27 | } 28 | 29 | @Autowired 30 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 31 | auth 32 | .inMemoryAuthentication() 33 | .withUser("user").password("password").roles("USER"); 34 | } 35 | } -------------------------------------------------------------------------------- /visitas/src/main/java/demo/controller/InicioController.java: -------------------------------------------------------------------------------- 1 | package demo.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.transaction.annotation.Transactional; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.*; 10 | import org.springframework.web.servlet.ModelAndView; 11 | 12 | import demo.model.Visita; 13 | import demo.repository.VisitasRepository; 14 | 15 | 16 | 17 | @Controller 18 | public class InicioController { 19 | 20 | @Autowired 21 | private VisitasRepository visitasRepository; 22 | 23 | 24 | @GetMapping("/") 25 | @Transactional(readOnly=true) 26 | public String home(Model model){ 27 | 28 | model.addAttribute("visitas", visitasRepository.findAll()); 29 | model.addAttribute("visita", new Visita()); 30 | return "home"; 31 | } 32 | 33 | 34 | 35 | @PostMapping("/") 36 | public String submit(@ModelAttribute Visita visita) { 37 | 38 | visitasRepository.save(visita); 39 | return "redirect:/"; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/model/Usuario.java: -------------------------------------------------------------------------------- 1 | package demo.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class Usuario implements Serializable{ 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Id 19 | @GeneratedValue(strategy=GenerationType.AUTO) 20 | private long id; 21 | 22 | private String userName; 23 | 24 | private String clave; 25 | 26 | private Boolean estado; 27 | 28 | public long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(long id) { 33 | this.id = id; 34 | } 35 | 36 | public String getUserName() { 37 | return userName; 38 | } 39 | 40 | public void setUserName(String userName) { 41 | this.userName = userName; 42 | } 43 | 44 | public String getClave() { 45 | return clave; 46 | } 47 | 48 | public void setClave(String clave) { 49 | this.clave = clave; 50 | } 51 | 52 | public Boolean getEstado() { 53 | return estado; 54 | } 55 | 56 | public void setEstado(Boolean estado) { 57 | this.estado = estado; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/model/Visita.java: -------------------------------------------------------------------------------- 1 | package demo.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | 11 | @Entity 12 | public class Visita implements Serializable{ 13 | 14 | /** 15 | * 16 | */ 17 | private static final long serialVersionUID = 1L; 18 | 19 | @Id 20 | @GeneratedValue(strategy=GenerationType.AUTO) 21 | private Long id; 22 | 23 | @Column(name="nombres", length=255) 24 | private String nombres; 25 | 26 | @Column(name="correo", length=255) 27 | private String correo; 28 | 29 | @Column(name="comentarios", length=1024) 30 | private String comentarios; 31 | 32 | public Long getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Long id) { 37 | this.id = id; 38 | } 39 | 40 | public String getNombres() { 41 | return nombres; 42 | } 43 | 44 | public void setNombres(String nombres) { 45 | this.nombres = nombres; 46 | } 47 | 48 | public String getCorreo() { 49 | return correo; 50 | } 51 | 52 | public void setCorreo(String correo) { 53 | this.correo = correo; 54 | } 55 | 56 | public String getComentarios() { 57 | return comentarios; 58 | } 59 | 60 | public void setComentarios(String comentarios) { 61 | this.comentarios = comentarios; 62 | } 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /visitas/src/main/java/demo/repository/VisitasRepository.java: -------------------------------------------------------------------------------- 1 | package demo.repository; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import demo.model.Visita; 6 | 7 | public interface VisitasRepository extends CrudRepository{ 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /visitas/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | #spring.datasource.url=jdbc:mysql://localhost/visitas 4 | #spring.datasource.username=root 5 | #spring.datasource.password=joedayz 6 | #spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | #spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect 9 | #spring.jpa.show-sql=true 10 | #spring.jpa.hibernate.ddl-auto=update 11 | 12 | #security.basic.enabled=false -------------------------------------------------------------------------------- /visitas/src/main/resources/templates/admin.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | Hello World! 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Hello [[${#httpServletRequest.remoteUser}]]! 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /visitas/src/main/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Inicio de Visitas 7 | 8 | 9 | Libro de Visitas 10 | 11 | 12 | 13 | 14 | 15 | Nombres 16 | Correo 17 | Comentarios 18 | 19 | 20 | 21 | 22 | 23 | 24 | Ingrese su visita 25 | 26 | 27 | Nombres: 28 | Correo: 29 | Comentarios: 30 | 32 | 33 | 34 | 35 | 36 | 37 | Click Ir a Administración. 38 | 39 | 40 | -------------------------------------------------------------------------------- /visitas/src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | Spring Security Example 6 | 7 | 8 | 9 | Invalid username and password. 10 | 11 | 12 | You have been logged out. 13 | 14 | 15 | User Name : 16 | Password: 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /visitas/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | #spring.datasource.url=jdbc:mysql://localhost/visitas 4 | #spring.datasource.username=root 5 | #spring.datasource.password=joedayz 6 | #spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | #spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect 9 | #spring.jpa.show-sql=true 10 | #spring.jpa.hibernate.ddl-auto=update 11 | 12 | #security.basic.enabled=false -------------------------------------------------------------------------------- /visitas/target/classes/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Inicio de Visitas 7 | 8 | 9 | Libro de Visitas 10 | 11 | 12 | 13 | 14 | 15 | Nombres 16 | Correo 17 | Comentarios 18 | 19 | 20 | 21 | 22 | 23 | 24 | Ingrese su visita 25 | 26 | 27 | Nombres: 28 | Correo: 29 | Comentarios: 30 | 32 | 33 | 34 | 35 | 36 | 37 | Click Ir a Administración. 38 | 39 | 40 | -------------------------------------------------------------------------------- /visitas/target/classes/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | Spring Security Example 6 | 7 | 8 | 9 | Invalid username and password. 10 | 11 | 12 | You have been logged out. 13 | 14 | 15 | User Name : 16 | Password: 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /weather-app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/.DS_Store -------------------------------------------------------------------------------- /weather-app/README.adoc: -------------------------------------------------------------------------------- 1 | = Simple weather app 2 | 3 | == Getting started 4 | 5 | To use this app, you need to register an http://openweathermap.org/appid[API Key] on the 6 | http://openweathermap.org/[OpenWeatherApp] service. 7 | 8 | You can create an `application-secrets.properties` in `src/main/resources` and add your 9 | API key there: 10 | 11 | ``` 12 | app.weather.api.key= 13 | ``` 14 | 15 | TIP: The `application-secrets.properties` file is referenced in the `.gitignore` of the 16 | project so you won't commit it by mistake. The `secrets` profile is enabled by default 17 | via the `spring.profiles.active` in the main configuration. 18 | 19 | If you don't like specifying the key in the project directly, you can set an OS 20 | environment property instead, something like: 21 | 22 | ``` 23 | $ EXPORT APP_WEATHER_API_KEY= 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /weather-app/src/main/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Weather API 2 | Andy Wilkinson; 3 | :doctype: book 4 | :icons: font 5 | :source-highlighter: highlightjs 6 | :toc: left 7 | :toclevels: 4 8 | :sectlinks: 9 | 10 | 11 | 12 | [[introduction]] 13 | = Introduction 14 | 15 | The Weather API provides access to current weather data and a weather forecast. 16 | 17 | 18 | 19 | [[current-weather]] 20 | == Current weather 21 | 22 | Current weather is available from `api/weather/now/{country}/{city}`. 23 | 24 | 25 | 26 | [[current-weather-request]] 27 | === Request 28 | Two path parameters are used to indicate the location for which weather data is required: 29 | 30 | include::{snippets}/weather/path-parameters.adoc[] 31 | 32 | For example, a curl request for the current weather in Barcelona, Spain looks like this: 33 | 34 | include::{snippets}/weather/curl-request.adoc[] 35 | 36 | 37 | 38 | [[current-weather-response]] 39 | === Response 40 | 41 | The following fields are found in the response: 42 | 43 | include::{snippets}/weather/response-fields.adoc[] 44 | 45 | A typical response looks like this: 46 | 47 | include::{snippets}/weather/http-response.adoc[] 48 | 49 | 50 | 51 | [[weather-forecast]] 52 | == Weather forecast 53 | 54 | A weather forecast is available from `api/weather/forecast/{country}/{city}`. 55 | 56 | 57 | 58 | [[weather-forecast-request]] 59 | === Request 60 | Two path parameters are used to indicate the location for which a weather forecast is 61 | required: 62 | 63 | include::{snippets}/weather-forecast/path-parameters.adoc[] 64 | 65 | For example, a curl request for the weather forecast for Barcelona, Spain looks like this: 66 | 67 | include::{snippets}/weather-forecast/curl-request.adoc[] 68 | 69 | 70 | 71 | [[weather-forecast-response]] 72 | === Response 73 | 74 | The following fields are found in the response: 75 | 76 | include::{snippets}/weather-forecast/response-fields.adoc[] 77 | 78 | A typical response looks like this: 79 | 80 | include::{snippets}/weather-forecast/http-response.adoc[] -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/WeatherApp.java: -------------------------------------------------------------------------------- 1 | package com.example.weather; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | 8 | @SpringBootApplication 9 | @EnableConfigurationProperties(WeatherAppProperties.class) 10 | @EnableCaching(proxyTargetClass = true) 11 | public class WeatherApp { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(WeatherApp.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/WeatherAppProperties.java: -------------------------------------------------------------------------------- 1 | package com.example.weather; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import javax.validation.Valid; 6 | import javax.validation.constraints.NotNull; 7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | 10 | @ConfigurationProperties("app.weather") 11 | public class WeatherAppProperties { 12 | 13 | @Valid 14 | private final Api api = new Api(); 15 | 16 | /** 17 | * Comma-separated list of locations to display. Each entry should have the 18 | * form "Country/City". 19 | */ 20 | private List locations = Arrays.asList("UK/London", "Russia/Moscow"); 21 | 22 | public Api getApi() { 23 | return this.api; 24 | } 25 | 26 | public List getLocations() { 27 | return this.locations; 28 | } 29 | 30 | public void setLocations(List locations) { 31 | this.locations = locations; 32 | } 33 | 34 | public static class Api { 35 | 36 | /** 37 | * API key of the OpenWeatherMap service. 38 | */ 39 | @NotNull 40 | private String key; 41 | 42 | public String getKey() { 43 | return this.key; 44 | } 45 | 46 | public void setKey(String key) { 47 | this.key = key; 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/integration/ows/Weather.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.integration.ows; 2 | 3 | public class Weather extends WeatherEntry { 4 | 5 | private String name; 6 | 7 | public String getName() { 8 | return this.name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/integration/ows/WeatherEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.integration.ows; 2 | 3 | import java.io.Serializable; 4 | import java.time.Instant; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.fasterxml.jackson.annotation.JsonProperty; 9 | import com.fasterxml.jackson.annotation.JsonSetter; 10 | 11 | public class WeatherEntry implements Serializable { 12 | 13 | private Instant timestamp; 14 | 15 | private double temperature; 16 | 17 | private Integer weatherId; 18 | 19 | private String weatherIcon; 20 | 21 | @JsonProperty("timestamp") 22 | public Instant getTimestamp() { 23 | return this.timestamp; 24 | } 25 | 26 | @JsonSetter("dt") 27 | public void setTimestamp(long unixTime) { 28 | this.timestamp = Instant.ofEpochMilli(unixTime * 1000); 29 | } 30 | 31 | /** 32 | * Return the temperature in Kelvin (K). 33 | */ 34 | public double getTemperature() { 35 | return this.temperature; 36 | } 37 | 38 | public void setTemperature(double temperature) { 39 | this.temperature = temperature; 40 | } 41 | 42 | @JsonProperty("main") 43 | public void setMain(Map main) { 44 | setTemperature(Double.parseDouble(main.get("temp").toString())); 45 | } 46 | 47 | public Integer getWeatherId() { 48 | return this.weatherId; 49 | } 50 | 51 | public void setWeatherId(Integer weatherId) { 52 | this.weatherId = weatherId; 53 | } 54 | 55 | public String getWeatherIcon() { 56 | return this.weatherIcon; 57 | } 58 | 59 | public void setWeatherIcon(String weatherIcon) { 60 | this.weatherIcon = weatherIcon; 61 | } 62 | 63 | @JsonProperty("weather") 64 | public void setWeather(List> weatherEntries) { 65 | Map weather = weatherEntries.get(0); 66 | setWeatherId((Integer) weather.get("id")); 67 | setWeatherIcon((String) weather.get("icon")); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/integration/ows/WeatherForecast.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.integration.ows; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.fasterxml.jackson.annotation.JsonProperty; 9 | import com.fasterxml.jackson.annotation.JsonSetter; 10 | 11 | public class WeatherForecast implements Serializable { 12 | 13 | private String name; 14 | 15 | private List entries = new ArrayList<>(); 16 | 17 | public String getName() { 18 | return this.name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | @JsonProperty("entries") 26 | public List getEntries() { 27 | return this.entries; 28 | } 29 | 30 | @JsonSetter("list") 31 | public void setEntries(List entries) { 32 | this.entries = entries; 33 | } 34 | 35 | @JsonProperty("city") 36 | public void setCity(Map city) { 37 | setName(city.get("name").toString()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/web/WeatherApiController.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.web; 2 | 3 | import com.example.weather.integration.ows.Weather; 4 | import com.example.weather.integration.ows.WeatherForecast; 5 | import com.example.weather.integration.ows.WeatherService; 6 | 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("/api/weather") 13 | public class WeatherApiController { 14 | 15 | private final WeatherService weatherService; 16 | 17 | public WeatherApiController(WeatherService weatherService) { 18 | this.weatherService = weatherService; 19 | } 20 | 21 | @RequestMapping("/now/{country}/{city}") 22 | public Weather getWeather(@PathVariable String country, 23 | @PathVariable String city) { 24 | return this.weatherService.getWeather(country, city); 25 | } 26 | 27 | @RequestMapping("/weekly/{country}/{city}") 28 | public WeatherForecast getWeatherForecast(@PathVariable String country, 29 | @PathVariable String city) { 30 | return this.weatherService.getWeatherForecast(country, city); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/web/WeatherSummary.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.web; 2 | 3 | import com.example.weather.integration.ows.Weather; 4 | 5 | class WeatherSummary { 6 | 7 | private final String country; 8 | 9 | private final String city; 10 | 11 | private final Integer code; 12 | 13 | private final String icon; 14 | 15 | private final double temperature; 16 | 17 | WeatherSummary(String country, String city, Weather weather) { 18 | this.country = country; 19 | this.city = city; 20 | this.code = weather.getWeatherId(); 21 | this.icon = weather.getWeatherIcon(); 22 | this.temperature = weather.getTemperature(); 23 | } 24 | 25 | public String getCountry() { 26 | return this.country; 27 | } 28 | 29 | public String getCity() { 30 | return this.city; 31 | } 32 | 33 | public Integer getCode() { 34 | return this.code; 35 | } 36 | 37 | public String getIcon() { 38 | return this.icon; 39 | } 40 | 41 | public String getFahrenheitTemperature() { 42 | double fahrenheitTemp = (this.temperature * 1.8) - 459.67; 43 | return String.format("%4.2f", fahrenheitTemp); 44 | } 45 | 46 | public String getCelsiusTemperature() { 47 | double celsiusTemp = this.temperature - 273.15; 48 | return String.format("%4.2f", celsiusTemp); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /weather-app/src/main/java/com/example/weather/web/WeatherSummaryController.java: -------------------------------------------------------------------------------- 1 | package com.example.weather.web; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedHashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import com.example.weather.WeatherAppProperties; 9 | import com.example.weather.integration.ows.Weather; 10 | import com.example.weather.integration.ows.WeatherService; 11 | 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | @Controller 18 | @RequestMapping("/") 19 | public class WeatherSummaryController { 20 | 21 | private final WeatherService weatherService; 22 | 23 | private final WeatherAppProperties properties; 24 | 25 | public WeatherSummaryController(WeatherService weatherService, WeatherAppProperties properties) { 26 | this.weatherService = weatherService; 27 | this.properties = properties; 28 | } 29 | 30 | @RequestMapping(method = RequestMethod.GET) 31 | public ModelAndView conferenceWeather() { 32 | Map model = new LinkedHashMap<>(); 33 | model.put("summary", getSummary()); 34 | return new ModelAndView("summary", model); 35 | } 36 | 37 | private Object getSummary() { 38 | List summary = new ArrayList<>(); 39 | for (String location : this.properties.getLocations()) { 40 | String country = location.split("/")[0]; 41 | String city = location.split("/")[1]; 42 | Weather weather = this.weatherService.getWeather(country, city); 43 | summary.add(createWeatherSummary(country, city, weather)); 44 | } 45 | return summary; 46 | } 47 | 48 | 49 | 50 | private WeatherSummary createWeatherSummary(String country, String city, 51 | Weather weather) { 52 | // cough cough 53 | if ("Las Vegas".equals(city)) { 54 | weather.setWeatherId(666); 55 | } 56 | return new WeatherSummary(country, city, weather); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /weather-app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | info.build.group=@project.groupId@ 2 | info.build.artifact=@project.artifactId@ 3 | info.build.version=@project.version@ 4 | 5 | 6 | spring.profiles.active=secrets 7 | 8 | spring.jackson.serialization.write_dates_as_timestamps=false 9 | 10 | app.weather.locations=Peru/Lima,USA/Las Vegas 11 | 12 | spring.cache.caffeine.spec=recordStats,maximumSize=500,expireAfterWrite=600s 13 | 14 | app.weather.api.key=96c9189b4377490de31ea173a120bbc5 15 | 16 | management.info.git.mode=full 17 | -------------------------------------------------------------------------------- /weather-app/src/main/resources/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/banner.jpg -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/css/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | body { 6 | font-family: arial, sans-serif; 7 | background: url("../img/background.jpg") no-repeat #0e4f79; 8 | background-size: cover; 9 | } 10 | #twitter { 11 | position: fixed; 12 | top: 0px; 13 | right: 0px; 14 | padding: 0.6em 3em; 15 | background: url("../img/twitter-logo.png") no-repeat #929292; 16 | background-size: contain; 17 | } 18 | #twitter a { 19 | color: white; 20 | text-shadow: 2px 2px black; 21 | text-decoration: none; 22 | } 23 | h1 { 24 | font-size: 60px; 25 | padding: 20px 20px 0px 20px; 26 | color: white; 27 | text-shadow: 2px 2px black; 28 | } 29 | h2 { 30 | font-size: 35px; 31 | padding-bottom: 10px; 32 | } 33 | li { 34 | list-style: none; 35 | display: block; 36 | background-color: rgba(255,255,255,.8); 37 | padding: 20px; 38 | margin: 20px; 39 | } 40 | ul li div i { 41 | display: block; 42 | float: left; 43 | padding-right: 20px; 44 | } 45 | div.temp { 46 | font-size: 30px; 47 | float: left; 48 | padding: 10px 100px 0px 0px; 49 | } 50 | div.temp sup { 51 | font-size: 15px; 52 | } 53 | 54 | /* Generated by Glyphter (http://www.glyphter.com) */ 55 | @font-face { 56 | font-family: 'SpringOnePlatform'; 57 | src: url('../fonts/SpringOnePlatform.eot'); 58 | src: url('../fonts/SpringOnePlatform.eot?#iefix') format('embedded-opentype'), 59 | url('../fonts/SpringOnePlatform.woff') format('woff'), 60 | url('../fonts/SpringOnePlatform.ttf') format('truetype'), 61 | url('../fonts/SpringOnePlatform.svg#SpringOnePlatform') format('svg'); 62 | font-weight: normal; 63 | font-style: normal; 64 | } 65 | /* SIZZLING */ 66 | .owf.owf-666:before, 67 | .owf.owf-666-d:before, 68 | .owf.owf-666-n:before { 69 | display: inline-block; 70 | font-family: 'SpringOnePlatform'; 71 | font-style: normal; 72 | font-weight: normal; 73 | line-height: 1; 74 | -webkit-font-smoothing: antialiased; 75 | -moz-osx-font-smoothing: grayscale; 76 | content: "\0041"; 77 | } -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/error/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ooops, page not found 6 | 16 | 17 | 18 | 19 | 20 | ¯\_(ツ)_/¯ 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/SpringOnePlatform.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/SpringOnePlatform.eot -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/SpringOnePlatform.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/SpringOnePlatform.ttf -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/SpringOnePlatform.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/SpringOnePlatform.woff -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/owfont-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/owfont-regular.eot -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/owfont-regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/owfont-regular.otf -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/owfont-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/owfont-regular.ttf -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/fonts/owfont-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/fonts/owfont-regular.woff -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/img/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/img/background.jpg -------------------------------------------------------------------------------- /weather-app/src/main/resources/static/img/twitter-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joedayz/spring-boot-samples/a31f2e8714a013f605f5af679c525461a070d0dc/weather-app/src/main/resources/static/img/twitter-logo.png -------------------------------------------------------------------------------- /weather-app/src/main/resources/templates/summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Weather Summary 8 | 9 | 10 | @spring1platform 11 | Weather Summary 12 | 13 | {{#summary}} 14 | 15 | {{city}}, {{country}} 16 | 17 | 18 | {{fahrenheitTemperature}}°F / {{celsiusTemperature}}°C 19 | 20 | 21 | 22 | {{/summary}} 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /weather-app/src/test/resources/com/example/weather/integration/ows/weather-barcelona.json: -------------------------------------------------------------------------------- 1 | { 2 | "coord": { 3 | "lon": 2.16, 4 | "lat": 41.39 5 | }, 6 | "weather": [ 7 | { 8 | "id": 800, 9 | "main": "Clear", 10 | "description": "clear sky", 11 | "icon": "01d" 12 | } 13 | ], 14 | "base": "cmc stations", 15 | "main": { 16 | "temp": 286.72, 17 | "pressure": 1012, 18 | "humidity": 62, 19 | "temp_min": 282.59, 20 | "temp_max": 290.37 21 | }, 22 | "wind": { 23 | "speed": 5.1, 24 | "deg": 310 25 | }, 26 | "clouds": { 27 | "all": 0 28 | }, 29 | "dt": 1461484642, 30 | "sys": { 31 | "type": 1, 32 | "id": 5470, 33 | "message": 0.0105, 34 | "country": "ES", 35 | "sunrise": 1461473841, 36 | "sunset": 1461523325 37 | }, 38 | "id": 6544100, 39 | "name": "Barcelona", 40 | "cod": 200 41 | } -------------------------------------------------------------------------------- /weather-app/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------
Share your passion
Submit
Committed by [[${latestFrameworkCommit.committer.name}]]
Committed by [[${latestBootCommit.committer.name}]]
since last Polish
Committed by [[${commit.committer.name}]]
Nombres:
Correo:
Comentarios: 30 | 32 |
37 | Click Ir a Administración. 38 |