Real-World Java
Helping You Navigate the Java Ecosystem
Häftad, Engelska, 2025
Av Victor Grazi, Jeanne Boyarsky, Victor (Java Community Process Executive Committee) Grazi, Jeanne (NYJavaSIG) Boyarsky
649 kr
Produktinformation
- Utgivningsdatum2025-01-22
- Mått231 x 25 x 188 mm
- Vikt635 g
- FormatHäftad
- SpråkEngelska
- SerieTech Today
- Antal sidor464
- FörlagJohn Wiley & Sons Inc
- ISBN9781394275724
Tillhör följande kategorier
VICTOR GRAZI is an Oracle Java Champion and a veteran Java engineer in the USA, and has built serious Java applications at some of the world's leading banks. He is a Pluralsight author, has served as infoQ Java lead editor, and serves on the Java community process executive committee. Victor is a frequent presenter at technical conferences and hosts the “Java Concurrent Animated” and “Bytecode Explorer” open-source projects. JEANNE BOYARSKY is an Oracle Java Champion and has worked as a Java developer for a major bank for more than 20 years. She is a senior moderator at CodeRanch, and trains and mentors students of all levels, including the programming department of a FIRST robotics team.
- Introduction xxixChapter 1: How We Got Here: History of Java in a Nutshell 1Introduction 1Understanding the Stewardship of Java 2Differentiating Key Java Versions 4Coding Generics in Java 5 4Coding with Functional Programming from Java 8 4Coding Modules from Java 11 5Coding Text Blocks and Records from Java 17 6Learning About Virtual Threads from Java 21 7Working with Deprecation and Retirement 7Identifying Renames 8Changing to Jakarta EE 8Renaming Certifications 8Understanding the Principles of Change 8Further References 9Summary 9Chapter 2: Getting to Know Your Ide: the Secret to Success 11Understanding IDE History 12Starting a New Project 13Creating a Project from Scratch 13Creating a Project from Existing Sources 14Creating a Project from Version Control 15Adding a Project to Version Control 15Adding a Module to an Existing Project 16Creating a Run Configuration 16Getting to Know Your Keyboard Shortcuts 18Navigating Your Codebase 19Copying and Pasting Shortcuts 20Reordering Code 20Using Other Helpful Shortcuts 21Debugging Your Code 22Debugging a Program 22Speeding Up Debugger Performance 24Remote Debugging 25Debugging with Hot Swap 26Refactoring Your Code 26Avoiding Duplicate Code 26Renaming Members 31Inlining 31Changing Signatures: Adding and Removing Parameters 32Exploiting the Editor 32Automated Reformatting of Code 32Organizing Imports 32Reformatting Code 32Unwrapping 33Comparing Code 34Using Column Mode 34Extending the IDE 35Peeking at Eclipse 36Peeking at VS Code 37Comparing IDEs 39Further References 40Summary 40Chapter 3: Collaborating Across the Enterprise with Git, Jira, and Confluence 41Collaborating with Git 42Introducing Git Basics 42Learning Key Concepts 42Differentiating Commits 43Displaying Git Status 43Branching 43Tagging 43Merging 44Reading Git Logs 44Staging Your Changes 44Installing Git 45Understanding Git Workflow by Example 45Fetching, Merging, and Pulling 51Playing with Branches 53Resolving Merge Conflicts 54Using Pull/Merge Requests 55Using the Git Log 56Rebasing 57Cherry-Picking 60Reverting and Resetting 60Optimizing with IDE Support 61Looking at the Commit Window 63Using the Diff-Viewer Window 64Creating README Files with Markdown Language 69Using Gitflow for Collaboration 70Using Jira for Enterprise Process Collaboration 72Getting Started with Jira 72Creating a Project 73Creating an Issue 74Linking to an Epic 75Working with Boards 76Creating a Sprint 76Adding Users 78Adding Columns 78Using Filters 80Seeing My Issues 80Querying with JQL 80Making Bulk Changes 82Connecting to Git 83Working with Confluence, the Enterprise Knowledge Management System 83Further References 86Summary 86Chapter 4: Automating Your Ci/cd Builds with Maven, Gradle, and Jenkins 87Building with Maven 88Building a Basic Maven Project 89Understanding the Maven Repository and Dependencies 90Differentiating Life-Cycle Phases 92Exploring the POM 93Working with Properties 93Specifying Project Information 93Understanding Version Numbers 94Using Common Plugins 94Configuring a Plugin 94Recognizing Common Plugins 97Working with a Parent POM 98Creating Your Own Parent POM 98Inheriting from the Parent 98Working with a Multimodule Project 100Using Other Maven Features 102Setting System Properties 102Using a Bill of Materials 102Releasing Your Project 103Getting to Know Maven in the IDE 103Using IntelliJ 103Using Eclipse 104Using VS Code 104Configuring Maven Settings for the Enterprise 106Building with Gradle 106Building a Basic Gradle Project 107Understanding the Gradle Local Repository and Dependencies 109Specifying Variables 110Using the Java Plugin 110Getting to Know Gradle in the IDE 111Finding a Dependency 112Integrating with Jenkins 114Installing Jenkins 114Learning Jenkins Terminology 116Creating Jobs 116Creating a Simple Freestyle Job 117Creating a Maven Freestyle Job 119Creating a Gradle Freestyle Job 122Creating a Maven Pipeline 122Creating a Gradle Pipeline 124Learning About Common Plugins 125Understanding Other Jenkins Capabilities 126Organizing Jobs 126Notifying Users 126Reading Changes 126Scanning with Sonar 127Explaining CI/CD Practices 127Further References 128Summary 128Chapter 5: Capturing Application State with Logging Frameworks 129Needing to Move Beyond Print 130Using Java Util Logging 130Comparing Logging Levels 131Formatting Values 132Passing Basic Configuration 133Setting Logging Destinations 134Logging Lazily 135Inheriting Loggers 136Using Log4j 138Comparing Logging Levels 139Formatting Values 140Passing Basic Configuration 141Comparing Configuration File Formats 142Setting Logging Destinations 145Choosing Logging Output Formats 148Logging Lazily 148Using SLF4J 149Omitting a Logging Framework 149Specifying SLF4J Simple 150Comparing Logging Levels 150Formatting Values 151Logging Lazily 151Passing Basic Configuration 152Using SLF4J with Other Logging Frameworks 152Using Logback 155Comparing Logging Levels 156Passing Basic Configuration 156Setting Logging Destinations 157Choosing Logging Output Formats 158Learning More About Logging 159Deciding on Coding Standards 159Designing for Performance 159Choosing a Language for the Logs 159Preventing Log Tampering 159Aggregating and Forwarding Logs 160Comparing Logging Frameworks 160Further References 161Summary 161Chapter 6: Getting to Know the Spring Framework 163Configuring Spring 164Using XML Configuration Files 165Using Java Configuration Classes 167Using Component Scanning 169Customizing Spring Applications with Properties 170Injecting Properties 170Configuring Environment-Specific Properties with Spring Profiles 171Turbocharging Development with Spring Boot 173Initializing Spring Boot Projects with Spring Initializr 173Using IntelliJ Initializr Integration 174Working with Spring MVC 178Handling Errors in Spring 183Inspecting Your Application with Actuator 185Securing Your Application with Spring Security 187Learning Security Terminology 187Understanding Spring Security Processing 188Exploring the Spring Projects 192Further References 193Summary 193Chapter 7: Testing Your Code with Automated Testing Tools 195Understanding Testing Basics 196Staging Your Test Directory 196Configuring JUnit in a Maven Build 197Configuring JUnit in a Gradle Build 200Using Test-Driven Development to Explore Tests 202Learning JUnit 205Looking at Test Flow 205Skipping a Test 207Asserting Logic 207Using Common Assertions 208Asserting Exceptions 208Failing Programmatically 209Verifying Conditions Using Assume Logic 209Parameterizing Tests 210Working with Common Testing Libraries 211Coding Using AssertJ 211Coding with JUnit Pioneer Features 212Disabling Until a Date 213Retrying a Test 213Working with System Properties 214Using Cartesian Test 214Learning About Other Features 214Mocking Objects 215Mocking with Mockito 215Configuring When/Then 218Verifying Calls 219Mocking Concrete Classes 220Mocking Statics 221Mocking with EasyMock 221Mocking with Spring MockMvc 222Measuring Test Coverage 225Calculating Code Coverage 225Seeing Code Coverage in the IDE 226Running Coverage in the Build 227Optimizing Your Testing with IntelliJ 228Looking at Assert Messages 228Exploring Test Runs 229Navigating to the Test 229Generating Test Boilerplate with TestMe 230Learning Other Testing Concepts 231Using Behavior-Driven Development 231Testing Contracts 231Understanding the Golden Master Pattern 231Testing Mutations 232Deciding Between DRY vs. DAMP 232Further References 233Summary 234Chapter 8: Annotation Driven Code with Project Lombok 235Preparing Your Environment for Lombok 236Installing in IntelliJ 236Installing in Eclipse 237Installing in VS Code 237Including in Maven or Gradle 238Compiling from javac 239Implementing Lombok 239Converting to the Lombok Way 240Using @Data: the include-all Annotation 240Autogenerating Your @Getter and @Setter Methods 241Using @ToString 243Using @EqualsAndHashCode 244Generating Constructors with @AllArgsConstructor, @RequiredArgsConstructor, and @NoArgsConstructor Annotations 244Weaving Loggers into Your Codebase with @Log and More 245Delomboking Your Codebase 247Further References 247Summary 247Chapter 9: Parallelizing Your Application Using Java Concurrency 249Understanding Concurrency Basics 250Dealing with Thread Contention 252Coding Atomic Operations 254Using the volatile Keyword 255Transitioning Thread States 256New 256Runnable 256Blocked 257Waiting 257Timed_waiting 257Terminated 257Summarizing Thread States 257Synchronizing 257Exploring Heap, Stack, and Metaspace 259Introducing Concurrent Collections 259Using Built‐In Concurrency Support in Java Streams 260Using Concurrency Components to Reduce Complexity 261Locking with ReentrantLock 261Controlling Thread Access with Phaser 262Using Runnable, Callable, and Future 262Coordinating with ExecutorService 263Using Fixed‐Count Thread Pools 263Scheduling with ExecutorService 264Building Reactive Code with CompletableFuture 265Functional Interfaces Used by CompletableFuture 265CompletionStage 268Putting It All Together with CompletableFuture 269Introducing Virtual Threads 271Interthread Communication 276Learning Concurrency Support in the Spring Framework 278Using @Async/@EnableAsync 278Scheduling with @Scheduled/@EnableScheduling 280Launching Threads with ThreadPoolTaskExecutor 280Understanding @Transactional 281Further References 281Summary 281Chapter 10: Pattern Matching with Regular Expressions 283Introducing Regular Expressions 284Learning Basic Regular Expression Syntax 285Specifying Common Quantifiers 286Matching Basic Boundaries 287Working with Common Character Classes 288Choosing Options 290Escaping Characters 290Using Regular Expressions with Java APIs 291Calling String Methods 291Finding Matches 291Replacing Values 292Splitting 293Working with Patterns 294Finding Matches 295Replacing Values 296Splitting as a Stream 298Controlling Behavior with Flags 298Exploring Advanced Regular Expression Syntax 300Looking at Neighboring Text 300Differentiating Quantifiers 301Identifying Common Mistakes 304Coding with Regular Expressions 304Using with Frameworks and Tools 306Coding Regular Expressions for Apache Commons Validator 306Coding Regular Expressions for JUnit 306Coding Regular Expressions for Log4j 307Coding Regular Expressions for Bean Validation 307Coding Regular Expressions for Spring 308Further References 308Summary 309Chapter 11: Coding the Aspect-oriented Way 311Understanding the Need for Aspects 311Creating Our First Example 312Exploring the Pointcut Expression Language 315* Wildcards 315.. Wildcards 316Using @AfterReturning 316Using @AfterThrowing 317Using @After 317Using @Around 317Using @Pointcut 319Combining Pointcuts 320Annotation-Based Pointcuts 321Further References 323Summary 323Chapter 12: Monitoring Your Applications: Observability in the Java Ecosystem 325Introducing Observability 326Getting Started with Prometheus 326Starting the Test Application 326Installing the Exporter 327Installing Prometheus 327Configuring a Scrape 328Introducing PromQL: The Prometheus Query Language 330Using Prometheus HTTP APIs 336Micrometer and Actuator 336Dependencies for Micrometer and Actuator 337Creating Custom Metrics 337Counting Results with Micrometer Counter 337Capturing Fluctuating Values 338Bucketing Values with Histograms and Summaries 339Adding Alert Manager 341Dashboarding with Grafana 344Logging and Tracing 347Introducing Logging 347Key Concepts in Tracing 349Tooling 349Implementing Tracing in Spring Boot Applications 349Further References 349Prometheus 349Other Tools 350Summary 350Chapter 13: Performance Tuning Your Services 351Learning the Concepts and Terminology 352Benchmarking 352Benchmarking with Built-In Java APIs 353Microbenchmarking 354Tuning JVM Settings 357Configuring Memory Settings 357Collecting the Garbage 358Setting Sizes for Garbage Collection 359Using Serial Garbage Collection 359Using Parallel Garbage Collection 359Using G1GC 360Testing with JMeter 360Creating a Test Plan 360Running the Load Test 363Analyzing the Results 364Using JDK Tools 365Using Java Flight Recorder 366Visualizing in Java Mission Control 368Monitoring with JConsole 369Using VisualVM 370Reporting with JStat 371Optimizing Your Application 372Exploring a Case Study 372Using SonarQube 374Considering Performance 375Further References 375Summary 376Chapter 14: Getting to Know More of the Ecosystem 377Writing Javadoc 378Comparing JVM Languages 379Sampling Kotlin 379Sampling Groovy 380Sampling Scala 381Exploring Jakarta EE 381Comparing Database Types 382Understanding Relational Databases 382Understanding NoSQL Databases 384Learning About Integrations 384Deploying Java 384Differentiating Web and Application Servers 385Using Containers 385Launching to the Cloud 386Building REST APIs 387Creating Web Services 388Documenting APIs 389Picking a Virtual Machine 390Exploring Libraries 390Securing Your Applications 391Exploring the OWASP Top 10 391Comparing Types of Security Tools 393Staying Informed About Changes 393Further References 393Summary 394Appendix: Reading and Writing Xml, Json, and Yaml 395Working with XML 396Learning the XML Format 396Reading XML with Jackson 397Writing XML with Jackson 399Reading and Writing XML with DOM 401Reading XML with SAX 402Comparing XML Libraries 403Working with JSON 404Learning the JSON Format 404Reading JSON with Jackson 405Writing JSON with Jackson 406Reading and Writing JSON with Gson 407Comparing JSON Libraries 408Working with YAML 408Learning the YAML Format 408Reading YAML with Jackson 409Writing YAML with Jackson 410Reading and Writing with SnakeYAML 410Comparing YAML Libraries 412Further References 412Summary 413Index 415