Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Mastering Java EE Development with WildFly
Mastering Java EE Development with WildFly

Mastering Java EE Development with WildFly: Create Enterprise-grade Java applications with WildFly

eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Mastering Java EE Development with WildFly

Working with Dependency Injection

Dependency injection is a very important design principle for working simply and at the same time with major security. It lets us write a very simple code to test. Java uses this principle since Java EE 5 through the CDI specifications.

The first Java frameworks to host this technology were the following:

  • Seam: Firstly, it was a set of utilities to work better with web applications. Next, it was discontinued and integrated in the Java EE 5 specifications; now it represents the main standard that a developer must use.
  • Spring: This was the first Java dependency injection framework born exclusively for complex Java applications. Now it is an evolved set of plugins where you can build anything through dependency injection. It remains an alternative to Java EE.

Contexts and Dependency Injection (CDI) is a set of annotations and services that make...

Dependency injection 1.0 for Java

This specification is provided by the javax.inject API. This is a set of packages specifying a means of getting objects in such a way as to achieve major reusability, testability, and maintainability compared to traditional approaches such as constructors, factories, and service locators. This process, known as dependency injection, is beneficial to most non-trivial applications.

With CDI, you don't instantiate the classes. CDI takes care of it. An internal management of the instances lets the developer create better features for the application. Instances are a point of work where we resolve performance problems. All this becomes simpler using a CDI engine.

Take, for example, a book service:

class BookService {
final List<Book> books;
BookService () {
books = new ArrayList(...);
}
}

Using the new construct, we are adding...

Context and dependency injection 1.1 for Java

This includes advanced SPI interfaces and annotations for CDI development.

Injection and contexts

When we inject a bean, we participate in a context. The context is declared in the CDI specifications as an environment based on the scope. The scope represents how the instances are registered and the type of visibility. If a bean is part of a context representing a session, it will work only in the session. If the same bean is called outside of its context, that bean excluding memory errors could become a part of another context. All instances inside a context are called contextual instances. A bean and a resource are contextual instances.

...

Interceptors 1.2

This contains annotations and interfaces for defining interceptor methods and interceptor classes and for binding interceptor classes to target classes.

Interceptor classes

An interceptor class is a class that establishes a set of operations to carry out when a bean is invoked. It is marked with @Interceptor:

@Interceptor
public class AuditInterceptor {
...}

Or through the beans.xml file:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="none">
<interceptors>
<class...

Common annotations for the Java platform 1.2

In common annotations, there are three feature sets.

Common annotation

Provided by the javax.annotation package, it is the basis of dependency injection. ManagedBean is the base used to make a POJO an injected object. By default, we don’t need to use it because the CDI engine 1.2 automatically makes this annotation to the POJO. So, automatically each bean is injectable. The @priority annotation was added in this new specification. The @Generated annotation is very useful to mark autogenerated codes, so you can treat them in a different manner. Here is a sample of PostConstruct:

@PostConstruct
public void reset() {
this.minimum = 0;
}

It will be executed after the creation...

Web console for monitoring beans

WildFly 10 provides a tool to monitor CDI instances as interceptors, decorators, beans, and observer methods. This console is provided by Weld probe 2.3.5.

Weld probe provides the option for to any application to use an additional web console to monitor all CDI components of the web app.

Our example offers a complete web application where you can monitor all the components seen in this chapter.

Web applications will be seen in detail in Chapter 14, Writing a JSF Application. At the moment, just remember that in any web application, if you want to activate the weld console, add this script in your web.xml file:

 <context-param>
<param-name>org.jboss.weld.development</param-name>
<param-value>true</param-value>
</context-param>

Always remember that you usually need a beans.xml to start the CDI container.

To use...

Summary

Now we know, in some depth, about the injections of the Java components and how to use them in WildFly. All Java enterprise components work with CDI to be injected or built. CDI Implementations are a good standalone framework, but they also provide a base to work with the other Java enterprise components. This chapter has introduced you to components that we will see in all of the following chapters. We are now ready for the next chapter, where we will see the Java persistence.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Master Java EE development with the latest WildFly 10 application server.
  • Integrate with JSF and JMS and use efficient load balancing techniques to create real-time apps
  • Integrate your backend JavaScript code seamlessly into Java applications

Description

Packed with rich assets and APIs, Wildfly 10 allows you to create state-of-the-art Java applications. This book will help you take your understanding of Java EE to the next level by creating distributed Java applications using Wildfly. The book begins by showing how to get started with a native installation of WildFly and it ends with a cloud installation. After setting up the development environment, you will implement and work with different WildFly features, such as implementing JavaServer Pages. You will also learn how you can use clustering so that your apps can handle a high volume of data traffic. You will also work with enterprise JavaBeans, solve issues related to failover, and implement Java Message Service integration. Moving ahead, you will be working with Java Naming and Directory Interface, Java Transaction API, and use ActiveMQ for message relay and message querying. This book will also show you how you can use your existing backend JavaScript code in your application. By the end of the book, you’ll have gained the knowledge to implement the latest Wildfly features in your Java applications.

Who is this book for?

If you are a Java developer with at least basic knowledge of Java EE, then this book is for you. No previous knowledge of WildFly is required.

What you will learn

  • Configure the development environment along with native and cloud installation of WildFly
  • Write a DB schema and the relative entities and how to use the relationships between the entities
  • Analyze with examples all the java annotations to manage the EJB and the configuration to get better performances
  • Write different REST services through the EJB
  • Implement Web sockets 1.0 and know why and when use the web sockets
  • Work with Active MQ and write JMS clients to manage the authentication and authorization in the clients
  • Configure the mail server through the wildfly console
  • Learn how and when to use a new feature JAX-RS 2.0, which is the asynchronous call through REST
  • Use the new JSF features of Wildfly 10 such as Mojarra 2.2, JSF 2.2, Richfaces 4.5

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 20, 2017
Length: 468 pages
Edition : 1st
Language : English
ISBN-13 : 9781787289079
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jun 20, 2017
Length: 468 pages
Edition : 1st
Language : English
ISBN-13 : 9781787289079
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 164.97
Java EE 8 Application Development
$54.99
Architecting Modern Java EE Applications
$54.99
Mastering Java EE Development with WildFly
$54.99
Total $ 164.97 Stars icon

Table of Contents

19 Chapters
Introducing Java EE and Configuring the Development Environment Chevron down icon Chevron up icon
Working with Dependency Injection Chevron down icon Chevron up icon
Persistence Chevron down icon Chevron up icon
Implementing Business Logic Chevron down icon Chevron up icon
Working with Distributed Transactions Chevron down icon Chevron up icon
Creating REST Services Chevron down icon Chevron up icon
Implementing WebSockets Chevron down icon Chevron up icon
Working with Messaging Chevron down icon Chevron up icon
Implementing a Mail Client Chevron down icon Chevron up icon
Asynchronous REST Chevron down icon Chevron up icon
Asynchronous EJB Chevron down icon Chevron up icon
Batches and Workflows Chevron down icon Chevron up icon
Working with Servlets and JSP Chevron down icon Chevron up icon
Writing a JSF Application Chevron down icon Chevron up icon
Sharing the Web Sessions Chevron down icon Chevron up icon
WildFly in Cloud Chevron down icon Chevron up icon
Share your Data Chevron down icon Chevron up icon
Deployment Chevron down icon Chevron up icon
Working with OSGi Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.3
(3 Ratings)
5 star 33.3%
4 star 0%
3 star 0%
2 star 0%
1 star 66.7%
Salvatore Apr 08, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Devo dire che non mi è piaciuto per niente.E' scritto male (a livello semantico molte frasi non si capiscono), e gli argomenti vengono trattati in maniera molto superficiale e blanda.Altra cosa negativa è che gli esempi di codice non hanno un minimo senso, non sono esempi di utlizzo reale. Questa cosa è veramente negativa perchè non ti fa capire il perchè devo usare una determinata feature.Bocciato.
Amazon Verified review Amazon
Gaurav Srivastva Oct 14, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
This book is a joke if you bought it to learn. It briefly touches on topics with no depth.
Amazon Verified review Amazon
David Sep 28, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a very good source of informations on the the most recent JavaEE and Web technologies.The author, using a clear and effective language, starts with the basics and then gradually moves to the advanced topics, covering most of the technologies included in Wildfly.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.