Java Fundamentals: The Java Reflection API Method Handles

Java Fundamentals: The Java Reflection API Method Handles
Java Fundamentals: The Java Reflection API Method Handles
English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 3h 10m | 507 MB

The Reflection API brings class and object introspection to Java, on top of which Spring and Hibernate are built. This course covers object creation, field modification, and method invocation, as well as Method and Var handles for improved performances.

As a Java developer, mastering the reflection API allows you to build powerful frameworks that will bring advanced functionalities to your application. In this course, Java Fundamentals: The Java Reflection API Method Handles, you will learn how you can use reflection API efficiently. This API is very technical, so this course is organized around the study of two real-life use cases: the building of an Object Relational Mapper, on the model of Hibernate, and the creation of a dependency injection framework, on the model of Spring. First, you will understand how to introspect classes and objects and how to discover their structure. Next, you will learn how to build objects without knowing their class at compile time, to set values to their fields and to invoke their methods. Finally, you will understand the performance issues of this API, and be able to use method handles and var handles to fix these issues. By the end of this course, you will be able to master the reflection API that will help you in creating performant and versatile Java applications.

Table of Contents

1 Course Overview
2 Introduction to the Course, What Are You Going to Learn
3 Who Are You What Should You Know to Follow This Course
4 Agenda of the Course
5 Agenda of This Module
6 Introducing the Java Reflection API – Class, Field, and Method
7 Introducing the Class Named Class, Getting an Instance of Class
8 Getting a Class Instance Using the Object.getClass() Method
9 Getting a Class Instance from the Name of the Class
10 Wrapping up the Three Patterns to Get a Class Object
11 Getting the Super Class and the Implemented Interfaces of a Class
12 Getting the Declared and Non Declared Fields of a Class
13 Getting the Methods and the Constructors of a Class
14 Reading the Modifier to Tell if a Class Member Is Public
15 Demo – Using the Reflection API to Read Fields and Methods
16 Module Wrap Up
17 Introduction to the Module and Agenda
18 Introducing the Mapping of Objects to Databases, XML, and JSON
19 Creating a Metamodel by Adding Annotations to Fields
20 Using the Reflection API to Read and Write a Field of an Object
21 Making a Field Accessible to Reading from Outside its Class
22 Designing an EntityManager for Reading and Writing to a Database
23 Demo – Designing a Generic Metamodel
24 Demo – Adding Application Specific Annotations to a Bean
25 Demo – Setting the Retention Policy of an Annotation
26 Demo – Implementing the Generic Metamodel
27 Demo – Running the Generic Metamodel
28 Module Wrap Up
29 Introduction to the Module and Agenda
30 Introducing the Database Server and the Person Bean
31 Demo – Setting up the Project and Its Dependencies
32 Demo – Runnning the H2 Server and Launching SQL Requests
33 Demo – Writing the Pattern to Create and Persist Person Instances
34 Demo – Creating and Implementing the EntityManager Interface
35 Demo – Building the SQL Query to Insert a Person Bean
36 Demo – Preparing the Statement to Execute the Query
37 Demo – Setting the Primary Key Value to the Insert Statement
38 Demo – Setting the Field Values to the Statement
39 Demo – Running the EntityManager to Persist Person Instances
40 Demo – Creating the Find Pattern and the Select Query
41 Demo – Setting the Primary Key Value to the Select Statement
42 Demo – Creating an Instance of the Object Read from the Database
43 Demo – Setting the Primary Key Value to the Object
44 Demo – Setting the Column Values and Reading the Objects
45 Demo – Creating an EntityManager Specific to a Database
46 Demo – Closing Properly the PreparedStatement and ResultSet
47 Demo – Specifying the Mapping through the Annotations
48 Module Wrap Up
49 Introduction to the Module and Agenda
50 Applying Dependency Inversion Using Dependency Injection
51 Designing an EntityManager Independent of the Database
52 Designing a BeanManager to Perform Dependency Injection
53 Getting and Invoking Methods Using the Reflection API
54 Demo – Preparing the Project for Dependency Injection
55 Demo – Updating the EntityManager with Dependency Injection
56 Demo – Creating the BeanManager to Create the EntityManager
57 Demo – Associating Types to Creation Recipes in the BeanManager
58 Demo – Injecting the Connection Value to Provide the EntityManager
59 Module Wrap Up
60 Introduction to the Module and Agenda
61 Spotting Security Checks While Calling Reflection Code
62 Introducing MethodHandles VarHandle and the Lookup Object
63 Getting a Private Trusted Lookup Object
64 Using a Method Handle to Get a Reference on a Class
65 Creating MethodType Object to Get a Reference on a Method
66 Getting a Method Handle on a Method or a Constructor
67 Getting a Method Handle to Read and Write a Field
68 Using a Method Handle to Invoke a Method of a Class
69 Accessing Public and Private Fields Using Method Handles
70 Adding Concurrent Field Access Using the VarHandle API
71 Using VarHandle to Gain Concurrent Access to Fields
72 Demo – Creating Person Beans Using Method Handles on Constructors
73 Demo – Invoking Methods Using Method Handles
74 Demo – Reading and Writing Private Fields Using Method Handles
75 Course Wrap Up