Turn a blank page into a web application! In this course, Java EE: Getting Started, you'll learn how to develop a distributed web application based on two complementary technologies: Java EE and Angular. First, you'll begin by covering how to setup your development environment, design your domain model, map it to a relational database, bring transaction management, and then expose the business domain through a REST API. Along the way, you'll make sure the integration tests always pass. Finally, once the REST API is tested, documented, and up-and-running, you'll build an Angular front-end to interact with it through HTTP and JSon. By the end of this course, you'll have the fundamental knowledge to start building REST API's with Java EE and consuming them with Angular.
Course Overview Hi everyone, my name is Antonio Goncalves. Welcome to my course Java EE: Getting Started. I am independent developer, a book author, and a recognized Java champion, living in beautiful Paris. But I also travel the world speaking at various conferences. So you want to get started with Java EE, sounds like the right course. In this course you will build a Java EE back-end and then add an Angular front-end to it. And when I say build, I mean that you will spend most of your time in front of your IDE typing code. Some of the major topics that I will cover include setting up your development environment, which IDE to choose, which building tools or database to install, which server to run your code, or which testing frameworks to use. Then you will build a Java EE back-end. This means that you will map domain objects to a database and access them in a transactional manner, validate data and use dependency injection. Once all this is in place, you will expose the business model through a documented REST API. Along the way you will focus on testing all these components to make sure they answer the business requirements and are reliable. Finally, you will create an Angular front-end to interact through HTTP and JSON with the Java EE back-end. By the end of this course you will know the basis to get started building REST APIs with Java EE and consuming them with Angular. The reward is that you'll know how to develop an entire web application where you'll be able to visualize, create, and delete books from an online bookstore. Before beginning the course, you should be familiar with the Java programming language, how the web and HTTP protocol work and a bit of HTML and CSS wouldn't hurt. Java EE, Angular, REST, sounds like a lot to learn. But don't be scared, this course will guide you step by step through all these topics. I hope you'll join me on this journey to learn Java EE with the Java EE Getting Started course at Pluralsight.
Bootstrapping the Java EE Application Our Java EE environment is ready with all the needed tools installed. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves, and in this module we will bootstrap our Java EE application, compile, package, deploy, and execute it. In the previous module, we've set up our Java EE environment and selected a code editor, a building tool, an application server, a database, and two testing frameworks. We will have all the codes to dive into all these tools. In this module we will use a Maven archetype to bootstrap an empty Java EE application. Finally, to make sure our entire process works, we will compile and package the application with Maven, deploy to Wildfly, and execute it.
Defining the Domain Model Our Java EE environment is set up now and the minimal Java EE application has been bootstrapped. Time to start coding the bookstore application. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we will create the domain model that will map books to a relational database thanks to Java Persistence API. In the previous module we checked our development environment was all set up. With the JDK in Maven installed, we used the Maven archetype to bootstrap an empty Java EE application. We then had a look at the directory structure and at some configuration files. Time to add some business code to this empty Java EE application. In this module we will only concentrate on our domain model. So first we need to understand what our model is. Then, for this model to get stored, we need to map our object into a relational database. For that we will use Java Persistence API, which deals with object relational mapping in Java EE.
Adding a Transactional Repository Our domain model represents the books that are managed by our application. Time to add a transactional layer. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we will create a repository that will allow to persist, find, and remove books from a relational database in a transactional way. In the previous module we defined the domain model of our BookStore application. This application is quite simple, so is its model. In fact, we will only deal with the Book entity throughout the course. Thanks to JPA we were able to turn an object into an entity just by using annotation and the deployment descriptor, persistence. xml, so now the Book entity is mapped to a table. Our domain model is defined, time to manipulate it. In this module we will develop a transactional repository, so we need to understand what a repository is and now return it into being transactional, thanks to Java Transaction API. We will manipulate our Book entity in two different ways, first basic CRUD operations to persist, remove, and find a book by its identifier. Second, using a query language for more complex selection. CRUD operations and query language are defined in Java Persistence API.
Testing the Java EE Application We have a Book entity and a transactional repository. Let's test them to see if they work. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we will create an integration test using Arquillian. In the previous module we've implemented the Book Repository using Java Persistence API for CRUD operation and Java Persistence Query Language for querying entities. Thanks to Java Transaction API we've also handled transaction demarcation with a single annotation. Now it's time to test our book repository. This module wills start by explaining testing. There are several kinds of tests. We will see the difference between unit testing and integration testing. In terms of testing frameworks, we've already introduced JUnit and Arquillian in the first module, so here we will explain and see how they work.
Validating Data We now know that our transactional repository works because we tested it. Let's make sure it can handle invalid data. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we use bean validation to make sure the data we process is valid. In the previous module we tested our application, making sure the code we've produced so far is working. First I explained the difference between unit tests and integration tests and gave an example using JUnit and then Arquillian. Our code lives in a managed environment because it needs an application server to run. In Java EE we use mostly integration tests and therefore deal with Arquillian quite often. When we process data we first need to make sure it's valid. In this module we will see what we mean by validation and by constraining data. Thanks to bean validation, we can add built-in annotations to our model and repository to ensure the data is correct. This will allow us to enrich our integration tests to make sure our code can deal with both valid and invalid data.
Injecting Beans Our transactional repository can handle invalid data. It now needs external components to correctly proceed books in the database. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we use context and dependency injection to inject components into each other. In the previous module we've added constraints to the Book entity attributes and the BookRepository method parameters using bean validation. This to make sure that our code can now deal with incorrect data. We've also improved our integration tests to reflect those changes. Our book repository manipulates a Book entity and handles incorrect data. Time to add a bit more business logic. In this module we will see what we mean by beans and dependency. Thanks to context and dependency injection, or CDI, we can use a single annotation to get a reference on a bean. This will allow us to rely on external components on a loosely coupled way.
Exposing a REST Service Our back end is now complete and works as expected. Time to expose it by REST so the Angular application can interact with it. Welcome back to the Java EE Getting Started course. My name is Antonio Goncalves and in this module we'll use JAX-RS to expose our transactional repository through HTTP. In the previous we used context and dependency injection to inject beans into others. CDI helps us to loosely couple our beans in a type safe way. Indeed CDI can inject one single implementation, like the TextUtil bean, as well as one interface with one or several implementations, like NumberGenerator. With injection in place, all our business logic is ready to be used. In this module we will expose a REST API of our backend. We will first learn about REST services and their implementation in Java EE called JAX-RS. In fact, JAX-RS can be used to expose REST service as well as consume it. This will help us when testing our service with Arquillian. In this module we will also add data to the database with a simple JPA trick.
Documenting the REST Service Our REST endpoint is up and running and tested. We still need one more step to consume it with an Angular frontend. Welcome back to the Java EE Getting Started course. My name is Antonio Goncalves and in this module we'll document our REST endpoint with open API so we can then generate Angular client code. In the previous module we've used JAX-RS to expose a JSON representation of our business model, which basically is how to create, read, and delete books from the database. REST APIs allow external components to interact with our backend using HTTP. HTTP is the perfect protocol for a mobile device to connect to this backend, but also for web application, for example written in Angular. In this module we will discuss rest API documentation. It's one thing to expose a system through HTTP, but we have to document it so external systems can consume these APIs. We call that a contract. Thanks to open API, we now have a standard way to describe REST web services.
Setting up the Angular Environment Before we start coding our Angular front end we need a few extra tools for our development environment. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we'll pick up the missing tools to work with Angular. In the previous module we've ended the Java EE back-end development by documenting our REST API. We've annotated our BookEndpoint with Swagger annotations so we could generate a contract in JSON format. We will leave the contract for now and come back to it later, but basically we will use this contract to generate TypeScript code that will interact in HTTP with our backend. But that's for a later module. In this module we will evaluate several tools to help us in developer our Angular front end. I'll keep using IntelliJ IDEA as the code editor because it also has an amazing Angular support, so we won't be installing a separate IDE. We will first see a quick introduction of Node JS, then we will pick up a building tool to allow us to compile and package our application. To bootstrap it we need to install Angular CLI, a command line interface to generate several Angular artifacts. Same for Swagger CodeGen to generate TypeScript code from our Swagger documentation. To make our web application pretty we will evaluate several graphical components and pick up one as well as a web browser. Let's get started.
Designing the User Interface Our Angular application is bootstrapped, time to add some graphical components. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we will create graphical components which will finally represent the books of the bookstore application. In the previous module we bootstrapped the Angular application thanks to Angular CLI. It is a nice way to scaffold an entire application following a standard directory structure and setup configuration files. We then added the Twitter Bootstrap component libraries to beautify our application, and finally executed it thanks to the in-memory web server Express. We also got a feel of the feedback loop in development. We changed the code and we can see it's running right away. Our final web application will be composed of three graphical components. So in this module we'll first see what an Angular component is. Basically it's a bundle of an HTML file that represents the visual aspect and a TypeScript file for the behavior of this component. The glue between HTML and the TypeScript is done through component binding that we already saw, but we will dive into it in this module. And of course, we will use Angular CLI to generate these components.
Navigating Through Components Our Angular application is made of several graphical components. We now need to navigate between them. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we use the Angular router to navigate between our components. In the previous module we designed our Angular components. One component to list all the books from the database, one component to visualize and delete an existing book, and another one allowing us to create a new book. We've used the Angular CLI to quickly create the skeleton of our components and then added some HTML and Twitter Bootstrap to beautify them. We've aggregated all our components into a single main app component. Time to navigate between them. In this module we will see what navigation means and how it is implemented in Angular using a router. We will see how to navigate through components, how to execute an action and then navigate, and how to pass parameters when navigating.
Invoking the REST Service Our Java EE REST endpoint is up and running and our Angular components are all set up with navigation. Time for the front-end to communicate with the back-end. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this module we'll use Angular services and model to communicate through HTTP with our Java EE back-end. In the previous module we managed to navigate between our components instead of just aggregating them into a single one. Thanks to the Angular router we achieved simple navigation, meaning going from one component to another one just by clicking a button. We also passed some parameters to the router, such as the book Id, and we executed some actions before routing. To display some data we've mocked our component with fake book information. Time to get rid of these mocks and invoke our back-end REST API. In this module we'll first learn what is a service in Angular. When dealing with services, we often manipulate models and observables with their reactive APIs. It is important to understand this basis because the code generated by Swagger CodeGen will be made of services, model, and reactive APIs. With all this in place, we will finally invoke the Java EE back-end and see our BookStore application running from front to back.
Revisiting the Application Our application is finally ready with the Angular front-end talking to the Java EE back-end. But you can feel there is more to it. Welcome back to Java EE Getting Started course. My name is Antonio Goncalves and in this last module we will go through the entire application architecture so you'll get a higher view of what we achieved. I will also give you extra pointers if you want to dig into Java EE in Angular. In the previous module we finished the Angular application by adding a book service that talks to our back-end using HTTP and the reactive programming model. Thanks to the Swagger CodeGen tool, it was just a matter of passing the JSON contract of our book endpoint and generate the needed code. We finally achieved what we were looking for, an Angular front-end application invoking our Java EE back-end. I'll wrap up this course with this last module by revisiting the entire application. I'll focus on the changes we made on each and every module, starting with Java EE back-end and finishing with Angular front-end. I'll end this course giving you a few external references so you can dive into both Java EE and Angular.