E-Book, Englisch, 197 Seiten
Soni Full Stack AngularJS for Java Developers
1. ed
ISBN: 978-1-4842-3198-2
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Build a Full-Featured Web Application from Scratch Using AngularJS with Spring RESTful
E-Book, Englisch, 197 Seiten
ISBN: 978-1-4842-3198-2
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Get introduced to full stack enterprise development. Whether you are new to AngularJS and Spring RESTful web services, or you are a seasoned expert, you will be able to build a full-featured web application from scratch using AngularJS and Spring RESTful web services.
Full stack web development is in demand because you can explore the best of different tools and frameworks and yet make your apps solid and reliable in design, scalability, robustness, and security. This book assists you in creating your own full stack development environment that includes the powerful and revamped AngularJS, and Spring REST. The architecture of modern applications is covered to prevent the development of isolated desktop and mobile applications.
By the time you reach the end of this book you will have built a full-featured dynamic app. You will start your journey by setting up a Spring Boot development environment and creating your RESTful services to perform CRUD operations. Then you will migrate the front-end tools-AngularJS and Bootstrap-into your Spring Boot application to consume RESTful services. You will secure your REST API using Spring Security and consume your secured REST API using AngularJS.
What You'll Learn
Build a REST application with Spring Boot
Expose CRUD operations using RESTful endpoints
Create a single page application by integrating Angular JS and Bootstrap in Spring Boot
Secure REST APIs using Spring Security
Consume secured RESTful Services using Angular JS
Build a REST client using a REST template to consume RESTful services
Test RESTful services using the Spring MVC Test FrameworkWho This Book Is For
Web application developers with previous Java programming experience who want to create enterprise-grade, scalable Java apps using powerful front tools such as AngularJS and Bootstrap along with popular back-end frameworks such as Spring Boot
Ravi Kant Soni is a Full Stack Java Application Developer and published author of two books, Learning Spring Application Development and Spring: Developing Java Applications for the Enterprise. He completed his bachelor degree (B.E) in information science and engineering from Reva University, Bangalore (India), and schooling from Bal Vikash Vidyalaya, Sasaram, Bihar (India). He is from Lashkariganj (near 'Sher Shah Suri' Tomb), Sasaram, Bihar (India).
Currently, Ravi is working as a Technical Manager. He has worn many hats throughout his tenure, ranging from software development to multi-tenant application design to integration of new technology into an existing system to writing books. He has focused on full stack web application development for most of his career and has been extensively involved in application design and implementation. He has developed applications for banking systems, HR and payroll systems, and e-commerce systems, and also has gained recognition from management for his designing abilities for a premium program. He is well-versed in all aspects of software engineering, including software design, systems architecture, application programming, and automation testing.
Ravi loves problem statements and enjoys brainstorming unique solutions.
Autoren/Hrsg.
Weitere Infos & Material
1;Contents;6
2;About the Author;11
3;About the Technical Reviewer;12
4;Acknowledgments;13
5;Chapter 1: The Big Picture of Full Stack Web Development;14
5.1;What Is a Full Stack Developer?;14
5.2;Full Stack Web Development;16
5.3;Architecture of Modern Web Applications;17
5.4;Front End vs. Back End;19
5.5;Front-End Framework;20
5.5.1;AngularJS as a Front-End Framework;20
5.5.1.1;AngularJS Version;20
5.5.1.2;AngularJS Architecture Concepts;21
5.5.1.2.1;MVC Architecture;22
5.5.2;Twitter Bootstrap;23
5.6;Back-End Framework;23
5.6.1;Spring Boot as a Back-End Framework;23
5.6.1.1;Spring Framework Problems and Spring Boot Advantages;24
5.6.1.2;Primary Goals of Spring Boot;24
5.6.1.3;Develop Your First Spring Boot Application;25
5.6.1.3.1;System Requirements;25
5.6.1.3.2;Using the Spring Boot CLI;25
5.6.1.3.3;Using Spring Initializr;25
5.6.1.3.4;Using Spring Tool Suite;28
5.6.1.4;A Walk-Through of the Code;31
5.6.1.4.1;Looking at pom.xml;31
5.6.1.4.2;Writing the Code;35
5.6.1.4.2.1;@SpringBootApplication Annotation;35
5.6.1.4.2.2;@RestController and @RequestMapping Annotations;36
5.6.1.4.2.3;The main Method;36
5.6.1.4.3;Running a Spring Boot Application in STS;36
5.6.1.5;Starters;38
5.6.1.6;Spring Boot Actuator: Production-Ready Features;38
5.6.1.6.1;Enabling Actuator;38
5.6.1.6.2;Running the Application;39
5.6.1.6.3;Using Actuator Endpoints;39
5.6.1.6.4;Customizing the Management Server Port;39
5.6.1.6.5;Getting Health Information;40
5.7;Summary;40
6;Chapter 2: Creating the RESTful Layer for Your Application;41
6.1;Introduction to REST;41
6.1.1;HTTP Methods and CRUD Operations;41
6.1.2;HTTP Status Codes;42
6.2;Build a RESTful Service: UserRegistrationSystem;42
6.2.1;Introducing UserRegistrationSystem;42
6.2.2;Identifying REST Endpoints;43
6.2.3;JSON Format;43
6.2.4;Creating the UserRegistrationSystem Application;44
6.2.5;Embedded Database: H2;45
6.2.6;Domain Implementation: Users;45
6.2.7;Repository Implementation: UserJpaRepository;46
6.2.8;Build a RESTful API;47
6.2.8.1;Create a RESTful Controller: UserRegistrationRestController;49
6.2.8.2;@GetMapping: Retrieve All Users;50
6.2.8.3;@PostMapping: Create a New User;51
6.2.8.4;@GetMapping ("/ {id}"): Retrieve an Individual User;52
6.2.8.5;@PutMapping: Update a User;53
6.2.8.6;@DeleteMapping: Delete a User;54
6.3;Handle Errors in a RESTful API;55
6.3.1;UserRegistrationSystem Error Handling;55
6.3.1.1;Custom Error Response;57
6.3.2;Validating Request Body;59
6.3.2.1;Adding the Bean Validation Annotations;59
6.3.2.2;@Valid on @RequestBody in UserRegistrationRestController Method Arguments;61
6.3.2.3;ValidationError and Updated ErrorDetail Classes;63
6.3.2.4;Handling Exceptions Using the @ControllerAdvice Annotation;65
6.3.2.5;Externalizing Error Messages;67
6.3.2.5.1;Create ReloadableResourceBundleMessageSource Bean: messageSource;67
6.3.2.5.2;Create a Properties File;68
6.3.2.5.3;Bean Validation Annotation with the message Attribute;69
6.3.2.5.4;Reading Messages from the Properties File;70
6.4;Summary;72
7;Chapter 3: Setting Up AngularJS: Creating Your Single-Page Application;73
7.1;Introducing AngularJS as a Front-End Framework;73
7.1.1;AngularJS Basic Components;74
7.1.2;AngularJS Life Cycle;74
7.1.2.1;Bootstrap Phase;75
7.1.2.2;Compilation Phase;75
7.1.2.3;Runtime Data Binding Phase;75
7.1.3;AngularJS Architecture Concepts;75
7.1.3.1;MVC Architecture;76
7.2;Setting Up Your Development Environment;78
7.2.1;Adding AngularJS to Spring Boot;78
7.2.1.1;Including Angular Scripts from the Google CDN;78
7.2.1.2;Downloading and Hosting Angular Files Locally;79
7.2.1.3;Providing Dependency Information in pom.xml;80
7.2.2;Adding Twitter Bootstrap to Spring Boot;81
7.2.3;Developing Your Single-Page Application;81
7.2.4;Bootstrapping the Application;82
7.2.5;Dependency Injection;82
7.2.6;AngularJS Routes;83
7.2.7;AngularJS Templates;83
7.2.8;Implementing the Model, View, and Controller in Your Single-Page Application;84
7.2.8.1;Create the Home/Application Page;85
7.2.8.2;Create the View Pages;87
7.2.8.2.1;Home Page;87
7.2.8.2.2;Register New User Page;88
7.2.8.2.3;List of Users;91
7.2.8.2.4;Update Existing User;93
7.2.8.3;Create an AngularJS Application;95
7.2.8.4;Create an AngularJS Controller;96
7.2.9;Running a Spring Boot Application in STS;98
7.3;Summary;104
8;Chapter 4: Securing Your RESTful API Using Spring Security;105
8.1;Introducing Spring Security;105
8.1.1;Authentication and Authorization;105
8.1.2;Introducing Basic Authentication;106
8.1.3;BasicAuthenticationFilter;106
8.2;Enabling Spring Security on RESTful Services;106
8.2.1;What Is the Spring Boot Security Starter?;107
8.2.2;Updating the pom.xml File with the Spring Security Dependency;107
8.2.3;Overriding the Spring Security Defaults;110
8.3;Customizing User Authentication;112
8.3.1;Authentication Customization with an In-Memory Definition;113
8.3.1.1;Running the UserRegistrationSystem Application;114
8.3.2;Authentication Customization Against a Relational Database;119
8.3.2.1;UserDetailsService Implementation;121
8.3.2.2;Customizing Spring Security and Securing the URI;122
8.3.2.3;Method-Level Security;124
8.4;Summary;125
9;Chapter 5: Consuming Secured RESTful Services Using AngularJS;126
9.1;Enabling Basic Authentication in Spring Security;126
9.2;Sending an Authorization Header with Each Request in AngularJS;128
9.2.1;Adding the HTTP Interceptor in AngularJS;128
9.2.1.1;authInterceptor.js;129
9.2.2;Updating app.js;130
9.2.3;Updating index.html;130
9.2.4;Running the Application;131
9.2.4.1;HTTP Request with Basic Authentication Header: Verify in Developer Tools;132
9.3;The Login Page;133
9.3.1;Updating index.html: Adding Navigation to the Welcome Page;134
9.3.2;Updating app.js: Adding Navigation to the Angular Application;135
9.3.3;Creating login.html: The Login Form;136
9.3.4;Updating controller.js for the Login and Logout Authentication Process;138
9.3.5;Updating the Back-End Code;140
9.3.5.1;Creating a New RESTful Endpoint to Get the Currently Authenticated User;140
9.3.5.2;Updating the Spring Security Configuration to Handle Login Requests;141
9.3.6;Running the Application;142
9.4;Summary;144
10;Chapter 6: Building a RESTful Client and Testing RESTful Services;145
10.1;Building a REST Client Using RestTemplate;145
10.1.1;RestTemplate;145
10.1.1.1;RestTemplate Method;146
10.1.2;RestTemplate Operation;146
10.1.2.1;HTTP GET Request with Parameter to Retrieve User;146
10.1.2.2;HTTP POST Request with JSON Data to Create an User;149
10.1.2.3;HTTP PUT Request with Parameter to Update User;150
10.1.2.4;HTTP DELETE with Parameter to Delete User;152
10.1.3;The RestTemplate Exchange API;153
10.1.4;Basic Authentication with RestTemplate;154
10.2;Testing RESTful Services Using the Spring Test Framework;155
10.2.1;What Is Testing?;155
10.2.2;Testing Using JUnit4;156
10.2.2.1;JUnit 4 Annotations;156
10.2.2.2;JUnit 4 Assert Methods;156
10.2.2.3;Example: Implementing JUnit 4;157
10.3;Agile Software Testing;159
10.3.1;Unit Testing;160
10.3.1.1;Unit Testing for the Dependent Class with a Mocking Object;160
10.3.1.1.1;The Mockito Framework;161
10.3.2;Integration Testing;161
10.4;Testing the Spring Boot Application;162
10.4.1;Maven Dependency;162
10.4.2;Annotations in Spring Testing;162
10.4.3;Unit Testing REST Controller;164
10.4.4;Testing the Web Layer Using the Spring MVC Test Framework;166
10.4.4.1;MockMvc;166
10.5;Summary;170
11;Chapter 7: Application Monitoring Using Spring Boot Actuator;171
11.1;Introducing Spring Boot Actuator;172
11.1.1;Enabling the Actuator Module;172
11.2;Actuator Endpoints;173
11.2.1;/info;174
11.2.2;/env;175
11.2.3;/metrics;175
11.2.4;/trace;177
11.2.5;/health;178
11.3;Customizing an Actuator Endpoint;178
11.3.1;Properties to Customize;179
11.3.2;Custom Health Indicator;180
11.4;Defining New Endpoints;182
11.5;Management Over HTTP;183
11.5.1;Customizing the Server Port;183
11.5.2;Accessing a Sensitive Endpoint;184
11.6;Summary;184
12;Appendix A:Tools for Accessing REST APIs;185
12.1;API Testing;185
12.2;API Testing Tools;185
12.2.1;Postman;185
12.2.1.1;Functions in Postman;188
12.2.1.1.1;Request URL;188
12.2.1.1.2;HTTP Method;188
12.2.1.1.3;Parameters;189
12.2.1.1.4;Authorization;190
12.2.1.1.5;Headers;190
12.2.1.1.6;Body;191
12.2.1.1.7;Send;191
12.2.1.2;Response Message;191
12.2.1.2.1;Body;192
12.2.1.2.2;Cookies;192
12.2.1.2.3;Headers;192
12.2.1.2.4;Tests;192
12.2.1.3;Other Features;193
13;Index;194




