Java EE 7 Development with WildFly

Book description

Leverage the power of the WildFly application server from JBoss to develop modern Java EE 7 applications

In Detail

Java Enterprise Edition is a well-known platform for application development. Its seventh release brings many new features and API improvements. WildFly is a successor of the JBoss Application Server family and fully implements the Java EE 7 standards.

Java EE 7 Development with WildFly shows you how to use the latest version of the Java EE 7 platform, including its most advanced features. Every topic is presented using working examples that are prepared to work out of the box with the new WildFly application server. This book will give you an insight into JBoss' message-oriented middleware, which allows you to loosely couple heterogeneous systems together, while typically providing reliability and many other features.

By the end of the book, you will have covered important topics such as learning the most important info about Java EE technologies, what changes the Java EE 7 brought, and how to use JBoss Forge scaffolding mechanisms (for example AngularJS) and perform endpoint generation, including JAX-RS.

What You Will Learn

  • Design reliable and efficient applications based on Enterprise Java Beans and Context and Dependency Injection
  • Set up and manage your own WildFly application server for different development scenarios
  • Store your data without binding yourself to a specific database provider using the Java Persistence API
  • Create message-based applications using Java Messaging System and integrate third-party systems into them using Java Connector Architecture
  • Distribute and secure your enterprise applications by using built-in mechanisms from WildFly and Java EE 7
  • Decide between using SOAP and JAX-RS web services to create your external API
  • Discover the new side of web applications by exploring WebSockets and their usage scenarios
  • Test your application using a real environment with Arquillian

Table of contents

  1. Java EE 7 Development with WildFly
    1. Table of Contents
    2. Java EE 7 Development with WildFly
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
        3. Instant updates on new Packt books
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
        1. Customer support
        2. Downloading the example code
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Getting Started with WildFly
      1. An overview of Java EE and WildFly
        1. WildFly and Enterprise Application Platform
        2. Welcome to Java EE 7
          1. JavaServer Faces 2.2 – JSR 344
          2. Enterprise JavaBeans 3.2 – JSR 345
          3. Java Persistence API 2.1 – JSR 338
          4. Contexts and Dependency Injection for Java EE 1.1 – JSR 346
          5. Java Servlet API 3.1 – JSR 340
          6. JAX-RS, the Java API for RESTful Web Services 2.0 – JSR 339
          7. Java Message Service 2.0 – JSR 343
          8. Bean Validation 1.1 – JSR 349
          9. Concurrency utilities for Java EE 1.0 – JSR 236
          10. Batch applications for the Java Platform 1.0 – JSR 352
          11. Java API for JSON Processing 1.0 – JSR 353
          12. Java API for WebSocket 1.0 – JSR 356
      2. New features in WildFly
      3. Installing the server and client components
        1. Installing Java SE
          1. Testing the installation
          2. Installing WildFly
          3. Starting WildFly
          4. Connecting to the server with the command-line interface
          5. Stopping WildFly
            1. Locating the shutdown script
            2. Stopping WildFly on a remote machine
          6. Restarting WildFly
        2. Installing the Eclipse environment
          1. Installing JBoss Tools
        3. Alternative development environments
        4. Installing Maven
          1. Testing the installation
      4. Summary
    9. 2. Your First Java EE Application on WildFly
      1. WildFly 8 core concepts
      2. The WildFly 8 directory layout
      3. Managing the application server
        1. Managing WildFly 8 with the web interface
      4. Launching the web console
      5. Deploying your first application to WildFly 8
        1. Advanced Eclipse deployment options
          1. Managing deployments with the web console
            1. Changing the deployment scanner properties
        2. Deploying applications using the command-line interface
          1. Deploying applications to a domain
      6. Summary
    10. 3. Introducing Java EE 7 – EJBs
      1. EJB 3.2 – an overview
      2. Developing singleton EJBs
        1. Configuring the EJB project object module (pom.xml)
        2. Coding our EJB application
        3. Controlling bean concurrency
          1. Using bean-managed concurrency
        4. Cooking session beans
        5. Adding a stateless bean
        6. Adding a stateful bean
      3. Deploying the EJB application
      4. Creating a remote EJB client
        1. Configuring the client's project object module
        2. Coding the EJB client
          1. Adding the EJB client configuration
        3. Running the client application
          1. Adding user authentication
        4. Using the EJB timer service
          1. Programmatic timer creation
          2. Scheduling timer events
        5. Adding asynchronous methods to our EJBs
          1. Using fire-and-forget asynchronous calls
          2. Returning a Future object to the client
      5. Summary
    11. 4. Learning Context and Dependency Injection
      1. Introducing Contexts and Dependency Injection
        1. Named beans
        2. CDI scopes
        3. WildFly CDI implementation
        4. Rethinking your ticketing system
          1. Adding the required dependencies
        5. Creating the beans
          1. Building the view
            1. JSF 2 facet suggestions
          2. Getting ready to run the application
          3. Combining the scheduler into our application
            1. Installing RichFaces
            2. Making your application rich
            3. Running the application
            4. Creating interceptors
        6. Are EJBs and JSF Managed Beans obsolete?
      2. Summary
    12. 5. Combining Persistence with CDI
      1. Data persistence meets the standard
        1. Working with JPA
      2. Adding persistence to our application
        1. Setting up the database
        2. Installing the JDBC driver in WildFly
          1. Using the command-line interface to create a new data source
      3. Creating the Maven project
        1. Adding the Maven configuration
        2. Cooking entities
        3. Adding Bean Validation
      4. Configuring persistence
        1. Adding producer classes
        2. Coding queries for your application
        3. Adding services to your application
        4. Adding a controller to drive user requests
        5. Coding the JSF view
        6. Running the example
      5. Summary
    13. 6. Developing Applications with JBoss JMS Provider
      1. A short introduction to JMS
      2. The building blocks of JMS
        1. The JBoss messaging subsystem
        2. Creating and using connection factories
        3. Using JMS destinations
        4. Adding message-driven beans to your application
          1. Cooking message-driven beans
          2. Adding the JMS producer
          3. Compiling and deploying the application
          4. Specifying which message to receive using selectors
        5. Transaction and acknowledgment modes
        6. Using JMS to integrate with external systems
        7. A real-world example – HornetQ and ActiveMQ integration
          1. Installing the ActiveMQ resource adapter
          2. Consuming ActiveMQ messages
      3. Summary
    14. 7. Adding Web Services to Your Applications
      1. Developing SOAP-based web services
        1. Strategies to build SOAP-based web services
        2. JBoss SOAP-based web services stack
        3. A brief look at the JAX WS architecture
        4. Coding SOAP web services with WildFly
          1. Developing a POJO web service
          2. Inspecting the web service from the console
          3. Testing our simple web service
          4. EJB3 Stateless Session Bean (SLSB) web services
          5. Developing a web service consumer
      2. Developing REST-based web services
        1. Accessing REST resources
        2. JBoss REST web services
          1. Activating JAX-RS
          2. Adding REST to our ticket example
          3. Adding filters
          4. Consuming our REST service
          5. Compiling our ticket example
          6. Adding AngularJS
      3. Choosing between SOAP and REST services
      4. Summary
    15. 8. Adding WebSockets
      1. An overview of WebSockets
      2. How do WebSockets work
      3. Creating our first endpoint
      4. Expanding our client application
        1. Transforming POJOs to JSON
      5. An alternative to WebSockets
      6. Summary
    16. 9. Managing the Application Server
      1. Entering the WildFly CLI
        1. Launching the CLI
          1. Connecting from remote hosts
          2. Using a CLI in the graphical mode
        2. Constructing CLI commands
          1. Determining the resource address
          2. Performing operations on resources
            1. Using the tab completion helper
        3. Deploying applications using the CLI
          1. Deploying applications to a WildFly domain
          2. Deploying to all server groups
          3. Deploying to a single server group
        4. Creating CLI scripts
          1. Deploying an application to several WildFly nodes
          2. Restarting servers in a domain
          3. Installing a data source as a module
          4. Adding JMS resources
      2. Using advanced languages to create powerful CLI scripts
        1. Using scripting languages to wrap CLI execution
      3. Using the raw management API to manage the application server
        1. Reading management model descriptions via the raw management API
          1. Creating your resource watches using the detyped API
      4. Role-based security
        1. Auditing administrative operations
      5. Patching a running instance
      6. Summary
    17. 10. Securing WildFly Applications
      1. Approaching the Java security API
        1. The WildFly security subsystem
        2. Setting up your first login module
        3. Using the login module in the Ticket web application
        4. Switching to FORM-based security
        5. Creating a Database login module
          1. Encrypting passwords
          2. Using the Database login module in your application
        6. Securing EJBs
          1. Securing web services
      2. Securing the transport layer
        1. Enabling the Secure Socket Layer on WildFly
          1. Certificate management tools
          2. Securing the HTTP communication with a self-signed certificate
          3. Generating the server and client certificates
          4. Creating an SSL-aware security realm
          5. Securing HTTP communication with a certificate signed by a CA
          6. Securing EJB communication
          7. Connecting to an SSL-aware security realm
      3. Summary
    18. 11. Clustering WildFly Applications
      1. Clustering basics
      2. WildFly clustering
        1. Starting a cluster of standalone nodes
        2. Starting a cluster of domain nodes
          1. The domain controller configuration
          2. Host configurations
      3. Deploying clustered applications
        1. Creating HA Stateful Session Beans
          1. Clustering the Ticket example
          2. Turning your cache into a distributed cache
          3. Coding the cluster-aware remote client
          4. Deploying and testing high availability
      4. Web application clustering
        1. Load balancing your web applications
          1. Installing mod_cluster
          2. Clustering your web applications
            1. Programming considerations to achieve HA
            2. Achieving HA in JSF applications
      5. Summary
    19. 12. Long-term Tasks' Execution
      1. The overview of the batching framework
        1. Our first batch job
          1. Creating a chunk-based batch step
          2. Creating a job-based batch step
        2. Using concurrency utilities in Java EE
          1. Introducing threads to enterprise beans
      2. Summary
    20. 13. Testing Your Applications
      1. Test types
        1. Instruments used for testing
      2. Getting started with Arquillian
        1. Writing an Arquillian test
        2. Configuring the pom.xml file
        3. Writing your first Arquillian test
        4. Running Arquillian TicketTest
        5. Running Arquillian tests using Spock
        6. ShrinkWrap Resolver
        7. ShrinkWrap Descriptors
        8. Persistence testing
        9. Arquillian Warp
        10. WebSockets testing
        11. Enhancing your Arquillian test
        12. Additional information
      3. Summary
    21. A. Rapid Development Using JBoss Forge
      1. Installing Forge
      2. Starting Forge
      3. Creating your first Java EE 7 application with JBoss Forge
        1. Building and deploying the application
      4. Your Forge-demo application in action
    22. Index

Product information

  • Title: Java EE 7 Development with WildFly
  • Author(s): Michal Cmil, Michal Matloka, Francesco Marchioni
  • Release date: December 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781782171980