16.4 Configuring Managed Beans
When a page references a managed bean for the first time, the JavaServer Faces implementation initializes it either based on a @Named annotation and scope annotation in the bean class or according to its configuration in the application configuration resource file. For information on using annotations to initialize beans, see Using Annotations to Configure Managed Beans.
You can use either annotations or the application configuration resource file to instantiate managed beans that are used in a JavaServer Faces application and to store them in scope. The managed bean creation facility is configured in the application configuration resource file using managed-bean XML elements to define each bean. This file is processed at application startup time. For information on using this facility, see Using the managed-bean Element.
Managed beans created in the application configuration resource file are JavaServer Faces managed beans, not CDI managed beans.
With the managed bean creation facility, you can
- Create beans in one centralized file that is available to the entire application, rather than conditionally instantiate beans throughout the application
- Customize a bean's properties without any additional code
- Customize a bean's property values directly from within the configuration file so that it is initialized with these values when it is created
- Using value elements, set a property of one managed bean to be the result of evaluating another value expression
This section shows you how to initialize beans using the managed bean creation facility. See Writing Bean Properties and Writing Managed Bean Methods for information on programming managed beans.
16.4.1 Using the managed-bean Element
A managed bean is initiated in the application configuration resource file using a managed-bean element, which represents an instance of a bean class that must exist in the application. At runtime, the JavaServer Faces implementation processes the managed-bean element. If a page references the bean and no bean instance exists, the JavaServer Faces implementation instantiates the bean as specified by the element configuration.
Here is an example managed bean configuration from the Duke's Bookstore case study:
Book201 dukesbookstore.model.ImageArea application shape rect alt Duke coords 67,23,212,268
The managed-bean-name element defines the key under which the bean will be stored in a scope. For a component's value to map to this bean, the component tag's value attribute must match the managed-bean-name up to the first period.
The managed-bean-class element defines the fully qualified name of the JavaBeans component class used to instantiate the bean.
The managed-bean element can contain zero or more managed-property elements, each corresponding to a property defined in the bean class. These elements are used to initialize the values of the bean properties. If you don't want a particular property initialized with a value when the bean is instantiated, do not include a managed-property definition for it in your application configuration resource file.
If a managed-bean element does not contain other managed-bean elements, it can contain one map-entries element or list-entries element. The map-entries element configures a set of beans that are instances of Map . The list-entries element configures a set of beans that are instances of List .
In the following example, the newsletters managed bean, representing a UISelectItems component, is configured as an ArrayList that represents a set of SelectItem objects. Each SelectItem object is in turn configured as a managed bean with properties:
newsletters java.util.ArrayList application javax.faces.model.SelectItem # # # # newsletter0 javax.faces.model.SelectItem none label Duke's Quarterly value 200 .
This approach may be useful for quick-and-dirty creation of selection item lists before a development team has had time to create such lists from the database. Note that each of the individual newsletter beans has a managed-bean-scope setting of none so that they will not themselves be placed into any scope.
See Initializing Array and List Properties for more information on configuring collections as beans.
To map to a property defined by a managed-property element, you must ensure that the part of a component tag's value expression after the period matches the managed-property element's property-name element. The next section, Initializing Properties Using the managed-property Element, explains in more detail how to use the managed-property element. See Initializing Managed Bean Properties for an example of initializing a managed bean property.
16.4.2 Initializing Properties Using the managed-property Element
A managed-property element must contain a property-name element, which must match the name of the corresponding property in the bean. A managed-property element must also contain one of a set of elements that defines the value of the property. This value must be of the same type as that defined for the property in the corresponding bean. Which element you use to define the value depends on the type of the property defined in the bean. Table 16-1 lists all the elements that are used to initialize a value.
Table 16-1 Subelements of managed-property Elements That Define Property Values
Defines the values in a list
Defines the values of a map
Explicitly sets the property to null
Defines a single value, such as a String , int , or JavaServer Faces EL expression
Using the managed-bean Element includes an example of initializing an int property (a primitive type) using the value subelement. You also use the value subelement to initialize String and other reference types. The rest of this section describes how to use the value subelement and other subelements to initialize properties of Java Enum types, Map , array , and Collection , as well as initialization parameters.
16.4.2.1 Referencing a Java Enum Type
A managed bean property can also be a Java Enum type (see http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html ). In this case, the value element of the managed-property element must be a String that matches one of the String constants of the Enum . In other words, the String must be one of the valid values that can be returned if you were to call valueOf(Class, String) on enum , where Class is the Enum class and String is the contents of the value subelement. For example, suppose the managed bean property is the following:
public enum Suit < Hearts, Spades, Diamonds, Clubs >. public Suit getSuit()
Assuming you want to configure this property in the application configuration resource file, the corresponding managed-property element looks like this:
Suit Hearts
When the system encounters this property, it iterates over each of the members of the enum and calls toString() on each member until it finds one that is exactly equal to the value from the value element.
16.4.2.2 Referencing a Context Initialization Parameter
Another powerful feature of the managed bean creation facility is the ability to reference implicit objects from a managed bean property.
Suppose you have a page that accepts data from a customer, including the customer's address. Suppose also that most of your customers live in a particular area code. You can make the area code component render this area code by saving it in an implicit object and referencing it when the page is rendered.
You can save the area code as an initial default value in the context initParam implicit object by adding a context parameter to your web application and setting its value in the deployment descriptor. For example, to set a context parameter called defaultAreaCode to 650 , add a context-param element to the deployment descriptor and give the parameter the name defaultAreaCode and the value 650 .
Next, write a managed-bean declaration that configures a property that references the parameter:
customer CustomerBean request areaCode # .
To access the area code at the time the page is rendered, refer to the property from the area component tag's value attribute:
Values are retrieved from other implicit objects in a similar way.
16.4.2.3 Initializing Map Properties
The map-entries element is used to initialize the values of a bean property with a type of Map if the map-entries element is used within a managed-property element. A map-entries element contains an optional key-class element, an optional value-class element, and zero or more map-entry elements.
Each of the map-entry elements must contain a key element and either a null-value or value element. Here is an example that uses the map-entries element:
. prices My Early Years: Growing Up on *7 30.75 Web Servers for Fun and Profit 40.75
The map created from this map-entries tag contains two entries. By default, all the keys and values are converted to String . If you want to specify a different type for the keys in the map, embed the key-class element just inside the map-entries element:
java.math.BigDecimal .
This declaration will convert all the keys into java.math.BigDecimal . Of course, you must make sure that the keys can be converted to the type you specify. The key from the example in this section cannot be converted to a BigDecimal , because it is a String .
If you want to specify a different type for all the values in the map, include the value-class element after the key-class element:
int java.math.BigDecimal .
Note that this tag sets only the type of all the value subelements.
Each map-entry in the preceding example includes a value subelement. The value subelement defines a single value, which will be converted to the type specified in the bean.
Instead of using a map-entries element, it is also possible to assign the entire map using a value element that specifies a map-typed expression.
16.4.2.4 Initializing Array and List Properties
The list-entries element is used to initialize the values of an array or List property. Each individual value of the array or List is initialized using a value or null-value element. Here is an example:
. books java.lang.String Web Servers for Fun and Profit #
This example initializes an array or a List . The type of the corresponding property in the bean determines which data structure is created. The list-entries element defines the list of values in the array or List . The value element specifies a single value in the array or List and can reference a property in another bean. The null-value element will cause the setBooks method to be called with an argument of null . A null property cannot be specified for a property whose data type is a Java primitive, such as int or boolean .
16.4.2.5 Initializing Managed Bean Properties
Sometimes you might want to create a bean that also references other managed beans so that you can construct a graph or a tree of beans. For example, suppose you want to create a bean representing a customer's information, including the mailing address and street address, each of which is also a bean. The following managed-bean declarations create a CustomerBean instance that has two AddressBean properties: one representing the mailing address and the other representing the street address. This declaration results in a tree of beans with CustomerBean as its root and the two AddressBean objects as children.
customer com.example.mybeans.CustomerBean request mailingAddress # streetAddress # customerType New addressBean com.example.mybeans.AddressBean none street .
The first CustomerBean declaration (with the managed-bean-name of customer ) creates a CustomerBean in request scope. This bean has two properties, mailingAddress and streetAddress . These properties use the value element to reference a bean named addressBean .
The second managed bean declaration defines an AddressBean but does not create it, because its managed-bean-scope element defines a scope of none . Recall that a scope of none means that the bean is created only when something else references it. Because both the mailingAddress and the streetAddress properties reference addressBean using the value element, two instances of AddressBean are created when CustomerBean is created.
When you create an object that points to other objects, do not try to point to an object with a shorter life span, because it might be impossible to recover that scope's resources when it goes away. A session-scoped object, for example, cannot point to a request-scoped object. And objects with none scope have no effective life span managed by the framework, so they can point only to other none -scoped objects. Table 16-2 outlines all of the allowed connections.
Table 16-2 Allowable Connections between Scoped Objects
none , application , session
none , application , session , request , view
none , application , session , view
Be sure not to allow cyclical references between objects. For example, neither of the AddressBean objects in the preceding example should point back to the CustomerBean object, because CustomerBean already points to the AddressBean objects.
16.4.3 Initializing Maps and Lists
In addition to configuring Map and List properties, you can also configure a Map and a List directly so that you can reference them from a tag rather than referencing a property that wraps a Map or a List .
Table of Contents
Java Platform, Enterprise Edition: The Java EE Tutorial
- Title and Copyright Information
- Preface
- Audience
- Documentation Accessibility
- Before You Read This Book
- Related Documentation
- Conventions
- Default Paths and File Names
- 1 Overview
- 1.1 Java EE 7 Platform Highlights
- 1.2 Java EE Application Model
- 1.3 Distributed Multitiered Applications
- 1.3.1 Security
- 1.3.2 Java EE Components
- 1.3.3 Java EE Clients
- 1.3.3.1 Web Clients
- 1.3.3.2 Application Clients
- 1.3.3.3 Applets
- 1.3.3.4 The JavaBeans Component Architecture
- 1.3.3.5 Java EE Server Communications
- 1.4.1 Container Services
- 1.4.2 Container Types
- 1.5.1 XML
- 1.5.2 SOAP Transport Protocol
- 1.5.3 WSDL Standard Format
- 1.7.1 Enterprise JavaBeans Technology
- 1.7.2 Java Servlet Technology
- 1.7.3 JavaServer Faces Technology
- 1.7.4 JavaServer Pages Technology
- 1.7.5 JavaServer Pages Standard Tag Library
- 1.7.6 Java Persistence API
- 1.7.7 Java Transaction API
- 1.7.8 Java API for RESTful Web Services
- 1.7.9 Managed Beans
- 1.7.10 Contexts and Dependency Injection for Java EE
- 1.7.11 Dependency Injection for Java
- 1.7.12 Bean Validation
- 1.7.13 Java Message Service API
- 1.7.14 Java EE Connector Architecture
- 1.7.15 JavaMail API
- 1.7.16 Java Authorization Contract for Containers
- 1.7.17 Java Authentication Service Provider Interface for Containers
- 1.7.18 Java API for WebSocket
- 1.7.19 Java API for JSON Processing
- 1.7.20 Concurrency Utilities for Java EE
- 1.7.21 Batch Applications for the Java Platform
- 1.8.1 Java Database Connectivity API
- 1.8.2 Java Naming and Directory Interface API
- 1.8.3 JavaBeans Activation Framework
- 1.8.4 Java API for XML Processing
- 1.8.5 Java Architecture for XML Binding
- 1.8.6 Java API for XML Web Services
- 1.8.7 SOAP with Attachments API for Java
- 1.8.8 Java Authentication and Authorization Service
- 1.8.9 Common Annotations for the Java Platform
- 2.1 Required Software
- 2.1.1 Java Platform, Standard Edition
- 2.1.2 Java EE 7 Software Development Kit
- 2.1.2.1 SDK Installation Tips
- 2.1.4.1 To Install NetBeans IDE without GlassFish Server
- 2.1.4.2 To Add GlassFish Server as a Server Using NetBeans IDE
- 2.2.1 To Start GlassFish Server Using NetBeans IDE
- 2.2.2 To Stop GlassFish Server Using NetBeans IDE
- 2.2.3 To Start GlassFish Server Using the Command Line
- 2.2.4 To Stop GlassFish Server Using the Command Line
- 2.3.1 To Start the Administration Console Using NetBeans IDE
- 2.4.1 To Start the Database Server Using NetBeans IDE
- 2.7.1 Installing the Tutorial Archetypes
- 2.7.1.1 Installing the Tutorial Archetypes Using NetBeans IDE
- 2.7.1.2 Installing the Tutorial Archetypes Using Maven
- 2.8.1 To Update the Tutorial Using NetBeans IDE
- 2.8.2 To Update the Tutorial Using the Command Line
- 2.9.1 Using the Server Log
- 2.9.1.1 To Use the Administration Console Log Viewer
- 2.9.2.1 To Debug an Application Using a Debugger
- 3 Resource Creation
- 3.1 Resources and JNDI Naming
- 3.2 DataSource Objects and Connection Pools
- 3.3 Creating Resources Administratively
- 4.1 Resource Injection
- 4.2 Dependency Injection
- 4.3 The Main Differences between Resource Injection and Dependency Injection
- 5.1 Packaging Applications
- 5.2 Packaging Enterprise Beans
- 5.2.1 Packaging Enterprise Beans in EJB JAR Modules
- 5.2.2 Packaging Enterprise Beans in WAR Modules
- 6 Getting Started with Web Applications
- 6.1 Web Applications
- 6.2 Web Application Lifecycle
- 6.3 A Web Module That Uses JavaServer Faces Technology: The hello1 Example
- 6.3.1 To View the hello1 Web Module Using NetBeans IDE
- 6.3.1.1 Introduction to Scopes
- 6.3.2.1 To Build and Package the hello1 Web Module Using NetBeans IDE
- 6.3.2.2 To Build and Package the hello1 Web Module Using Maven
- 6.3.3.1 To View Deployed Web Modules Using the Administration Console
- 6.3.3.2 To View Deployed Web Modules Using the asadmin Command
- 6.3.3.3 To View Deployed Web Modules Using NetBeans IDE
- 6.3.4.1 Dynamic Reloading of Deployed Modules
- 6.3.5.1 To Undeploy the hello1 Web Module Using NetBeans IDE
- 6.3.5.2 To Undeploy the hello1 Web Module Using Maven
- 6.4.1 Mapping URLs to Web Components
- 6.4.2 Examining the hello2 Web Module
- 6.4.2.1 To View the hello2 Web Module Using NetBeans IDE
- 6.4.3.1 To Run the hello2 Example Using NetBeans IDE
- 6.4.3.2 To Run the hello2 Example Using Maven
- 6.5.1 Setting Context Parameters
- 6.5.1.1 To Add a Context Parameter Using NetBeans IDE
- 6.5.1.2 To Create a web.xml File Using NetBeans IDE
- 6.5.3.1 To Set Up Error Mapping Using NetBeans IDE
- 6.5.4.1 Declaring a Reference to a Resource
- 6.5.4.2 Declaring a Reference to a Web Service
- 7.1 What Is a JavaServer Faces Application?
- 7.2 JavaServer Faces Technology Benefits
- 7.3 A Simple JavaServer Faces Application
- 7.4 User Interface Component Model
- 7.4.1 User Interface Component Classes
- 7.4.2 Component Rendering Model
- 7.4.3 Conversion Model
- 7.4.4 Event and Listener Model
- 7.4.5 Validation Model
- 7.6.1 Overview of the JavaServer Faces Lifecycle
- 7.6.2 Restore View Phase
- 7.6.3 Apply Request Values Phase
- 7.6.4 Process Validations Phase
- 7.6.5 Update Model Values Phase
- 7.6.6 Invoke Application Phase
- 7.6.7 Render Response Phase
- 8.1 What Is Facelets?
- 8.2 The Lifecycle of a Facelets Application
- 8.3 Developing a Simple Facelets Application: The guessnumber-jsf Example Application
- 8.3.1 Creating a Facelets Application
- 8.3.1.1 Developing a Managed Bean
- 8.3.1.2 Creating Facelets Views
- 8.3.3.1 To Build, Package, and Deploy the guessnumber-jsf Example Using NetBeans IDE
- 8.3.3.2 To Build, Package, and Deploy the guessnumber-jsf Example Using Maven
- 8.3.3.3 To Run the guessnumber-jsf Example
- 8.8.1 The hello1-rlc Example Application
- 8.8.1.1 Configuring the hello1-rlc Example
- 8.8.1.2 The Facelets Pages for the hello1-rlc Example
- 8.8.1.3 To Build, Package, and Deploy the hello1-rlc Example Using NetBeans IDE
- 8.8.1.4 To Build, Package, and Deploy the hello1-rlc Example Using Maven
- 8.8.1.5 To Run the hello1-rlc Example
- 8.9.1 Using Pass-Through Elements
- 8.9.2 Using Pass-Through Attributes
- 8.9.3 The reservation Example Application
- 8.9.3.1 The Facelets Pages for the reservation Application
- 8.9.3.2 The Managed Bean for the reservation Application
- 8.9.3.3 To Build, Package, and Deploy the reservation Example Using NetBeans IDE
- 8.9.3.4 To Build, Package, and Deploy the reservation Example Using Maven
- 8.9.3.5 To Run the reservation Example
- 9.1 Overview of the EL
- 9.2 Immediate and Deferred Evaluation Syntax
- 9.2.1 Immediate Evaluation
- 9.2.2 Deferred Evaluation
- 9.3.1 Value Expressions
- 9.3.1.1 Referencing Objects
- 9.3.1.2 Referencing Object Properties or Collection Elements
- 9.3.1.3 Referencing Literals
- 9.3.1.4 Parameterized Method Calls
- 9.3.1.5 Where Value Expressions Can Be Used
- 10.1 Setting Up a Page
- 10.2 Adding Components to a Page Using HTML Tag Library Tags
- 10.2.1 Common Component Tag Attributes
- 10.2.1.1 The id Attribute
- 10.2.1.2 The immediate Attribute
- 10.2.1.3 The rendered Attribute
- 10.2.1.4 The style and styleClass Attributes
- 10.2.1.5 The value and binding Attributes
- 10.2.4.1 Rendering a Field with the h:inputText Tag
- 10.2.4.2 Rendering a Password Field with the h:inputSecret Tag
- 10.2.4.3 Rendering a Label with the h:outputLabel Tag
- 10.2.4.4 Rendering a Link with the h:outputLink Tag
- 10.2.4.5 Displaying a Formatted Message with the h:outputFormat Tag
- 10.2.5.1 Rendering a Button with the h:commandButton Tag
- 10.2.5.2 Rendering a Link with the h:commandLink Tag
- 10.2.8.1 Displaying a Check Box Using the h:selectBooleanCheckbox Tag
- 10.2.8.2 Displaying a Menu Using the h:selectOneMenu Tag
- 10.2.10.1 Using the f:selectItems Tag
- 10.2.10.2 Using the f:selectItem Tag
- 10.2.16.1 To Build, Package, and Deploy the bookmarks Example Using NetBeans IDE
- 10.2.16.2 To Build, Package, and Deploy the bookmarks Example Using Maven
- 10.2.16.3 To Run the bookmarks Example
- 11.1 Using the Standard Converters
- 11.1.1 Converting a Component's Value
- 11.1.2 Using DateTimeConverter
- 11.1.3 Using NumberConverter
- 11.2.1 Registering a Value-Change Listener on a Component
- 11.2.2 Registering an Action Listener on a Component
- 11.3.1 Validating a Component's Value
- 11.3.2 Using Validator Tags
- 11.4.1 Referencing a Method That Performs Navigation
- 11.4.2 Referencing a Method That Handles an Action Event
- 11.4.3 Referencing a Method That Performs Validation
- 11.4.4 Referencing a Method That Handles a Value-Change Event
- 12.1 Managed Beans in JavaServer Faces Technology
- 12.1.1 Creating a Managed Bean
- 12.1.2 Using the EL to Reference Managed Beans
- 12.2.1 Writing Properties Bound to Component Values
- 12.2.1.1 UIInput and UIOutput Properties
- 12.2.1.2 UIData Properties
- 12.2.1.3 UISelectBoolean Properties
- 12.2.1.4 UISelectMany Properties
- 12.2.1.5 UISelectOne Properties
- 12.2.1.6 UISelectItem Properties
- 12.2.1.7 UISelectItems Properties
- 12.3.1 Writing a Method to Handle Navigation
- 12.3.2 Writing a Method to Handle an Action Event
- 12.3.3 Writing a Method to Perform Validation
- 12.3.4 Writing a Method to Handle a Value-Change Event
- 13.1 Overview of Ajax
- 13.2 Using Ajax Functionality with JavaServer Faces Technology
- 13.3 Using Ajax with Facelets
- 13.3.1 Using the f:ajax Tag
- 13.4.1 Using the event Attribute
- 13.4.2 Using the execute Attribute
- 13.4.3 Using the immediate Attribute
- 13.4.4 Using the listener Attribute
- 13.10.1 Using JavaScript API in a Facelets Application
- 13.10.2 Using the @ResourceDependency Annotation in a Bean Class
- 13.11.1 The ajaxguessnumber Source Files
- 13.11.1.1 The ajaxgreeting.xhtml Facelets Page
- 13.11.1.2 The UserNumberBean Backing Bean
- 13.11.1.3 The DukesNumberBean CDI Managed Bean
- 13.11.2.1 To Build, Package, and Deploy the ajaxguessnumber Example Using NetBeans IDE
- 13.11.2.2 To Build, Package, and Deploy the ajaxguessnumber Example Using Maven
- 13.11.2.3 To Run the ajaxguessnumber Example
- 14.1 Attributes of a Composite Component
- 14.2 Invoking a Managed Bean
- 14.3 Validating Composite Component Values
- 14.4 The compositecomponentexample Example Application
- 14.4.1 The Composite Component File
- 14.4.2 The Using Page
- 14.4.3 The Managed Bean
- 14.4.4 Running the compositecomponentexample Example
- 14.4.4.1 To Build, Package, and Deploy the compositecomponentexample Example Using NetBeans IDE
- 14.4.4.2 To Build, Package, and Deploy the compositecomponentexample Example Using Maven
- 14.4.4.3 To Run the compositecomponentexample Example
- 15.1 Determining Whether You Need a Custom Component or Renderer
- 15.1.1 When to Use a Custom Component
- 15.1.2 When to Use a Custom Renderer
- 15.1.3 Component, Renderer, and Tag Combinations
- 15.2.1 Why Use JavaServer Faces Technology to Implement an Image Map?
- 15.2.2 Understanding the Rendered HTML
- 15.2.3 Understanding the Facelets Page
- 15.2.4 Configuring Model Data
- 15.2.5 Summary of the Image Map Application Classes
- 15.4.1 Specifying the Component Family
- 15.4.2 Performing Encoding
- 15.4.3 Performing Decoding
- 15.4.4 Enabling Component Properties to Accept Expressions
- 15.4.5 Saving and Restoring State
- 15.5.1 Creating the Renderer Class
- 15.5.2 Identifying the Renderer Type
- 15.6.1 Implementing Value-Change Listeners
- 15.6.2 Implementing Action Listeners
- 15.10.1 Creating a Custom Converter
- 15.10.2 Using a Custom Converter
- 15.11.1 Implementing the Validator Interface
- 15.11.2 Specifying a Custom Tag
- 15.11.3 Using a Custom Validator
- 15.12.1 Binding a Component Value to a Property
- 15.12.2 Binding a Component Value to an Implicit Object
- 15.12.3 Binding a Component Instance to a Bean Property
- 16.1 Using Annotations to Configure Managed Beans
- 16.1.1 Using Managed Bean Scopes
- 16.2.1 Configuring Eager Application-Scoped Managed Beans
- 16.2.2 Ordering of Application Configuration Resource Files
- 16.3.1 Packaging Flows in an Application
- 16.3.2 The Simplest Possible Flow: The simple-flow Example Application
- 16.3.2.1 To Build, Package, and Deploy the simple-flow Example Using NetBeans IDE
- 16.3.2.2 To Build, Package, and Deploy the simple-flow Example Using Maven
- 16.3.2.3 To Run the simple-flow Example
- 16.3.3.1 The Facelets Pages for the checkout-module Example
- 16.3.3.2 Using a Configuration File to Configure a Flow
- 16.3.3.3 Using a Java Class to Configure a Flow
- 16.3.3.4 The Flow-Scoped Managed Beans
- 16.3.3.5 To Build, Package, and Deploy the checkout-module Example Using NetBeans IDE
- 16.3.3.6 To Build, Package, and Deploy the checkout-module Example Using Maven
- 16.3.3.7 To Run the checkout-module Example
- 16.4.1 Using the managed-bean Element
- 16.4.2 Initializing Properties Using the managed-property Element
- 16.4.2.1 Referencing a Java Enum Type
- 16.4.2.2 Referencing a Context Initialization Parameter
- 16.4.2.3 Initializing Map Properties
- 16.4.2.4 Initializing Array and List Properties
- 16.4.2.5 Initializing Managed Bean Properties
- 16.5.1 Using FacesMessage to Create a Message
- 16.5.2 Referencing Error Messages
- 16.12.1 Configuring an Application with a Web Deployment Descriptor
- 16.12.1.1 Identifying the Servlet for Lifecycle Processing
- 16.12.1.2 To Specify a Path to an Application Configuration Resource File
- 16.12.1.3 To Specify Where State Is Saved
- 17.1 What Is a Servlet?
- 17.2 Servlet Lifecycle
- 17.2.1 Handling Servlet Lifecycle Events
- 17.2.1.1 Defining the Listener Class
- 17.3.1 Using Scope Objects
- 17.3.2 Controlling Concurrent Access to Shared Resources
- 17.5.1 Getting Information from Requests
- 17.5.2 Constructing Responses
- 17.6.1 Programming Filters
- 17.6.2 Programming Customized Requests and Responses
- 17.6.3 Specifying Filter Mappings
- 17.6.3.1 To Specify Filter Mappings Using NetBeans IDE
- 17.7.1 Including Other Resources in the Response
- 17.7.2 Transferring Control to Another Web Component
- 17.9.1 Accessing a Session
- 17.9.2 Associating Objects with a Session
- 17.9.3 Session Management
- 17.9.3.1 To Set the Timeout Period Using NetBeans IDE
- 17.10.1 Tracking Service Requests
- 17.10.2 Notifying Methods to Shut Down
- 17.10.3 Creating Polite Long-Running Methods
- 17.11.1 The @MultipartConfig Annotation
- 17.11.2 The getParts and getPart Methods
- 17.12.1 Asynchronous Processing in Servlets
- 17.12.2 Waiting for a Resource
- 17.13.1 Reading a Large HTTP POST Request Using Nonblocking I/O
- 17.15.1 Components of the mood Example Application
- 17.15.2 Running the mood Example
- 17.15.2.1 To Run the mood Example Using NetBeans IDE
- 17.15.2.2 To Run the mood Example Using Maven
- 17.16.1 Architecture of the fileupload Example Application
- 17.16.2 Running the fileupload Example
- 17.16.2.1 To Build, Package, and Deploy the fileupload Example Using NetBeans IDE
- 17.16.2.2 To Build, Package, and Deploy the fileupload Example Using Maven
- 17.16.2.3 To Run the fileupload Example
- 17.17.1 Architecture of the dukeetf Example Application
- 17.17.1.1 The Servlet
- 17.17.1.2 The Enterprise Bean
- 17.17.1.3 The HTML Page
- 17.17.2.1 To Run the dukeetf Example Application Using NetBeans IDE
- 17.17.2.2 To Run the dukeetf Example Application Using Maven
- 18.1 Introduction to WebSocket
- 18.2 Creating WebSocket Applications in the Java EE Platform
- 18.3 Programmatic Endpoints
- 18.4 Annotated Endpoints
- 18.5 Sending and Receiving Messages
- 18.5.1 Sending Messages
- 18.5.1.1 Sending Messages to All Peers Connected to an Endpoint
- 18.7.1 Implementing Encoders to Convert Java Objects into WebSocket Messages
- 18.7.2 Implementing Decoders to Convert WebSocket Messages into Java Objects
- 18.11.1 Architecture of the dukeetf2 Sample Application
- 18.11.1.1 The Endpoint
- 18.11.1.2 The Enterprise Bean
- 18.11.1.3 The HTML Page
- 18.11.2.1 To Run the dukeetf2 Example Application Using NetBeans IDE
- 18.11.2.2 To Run the dukeetf2 Example Application Using Maven
- 18.12.1 Architecture of the websocketbot Example Application
- 18.12.1.1 The CDI Bean
- 18.12.1.2 The WebSocket Endpoint
- 18.12.1.3 The Application Messages
- 18.12.1.4 The Encoder Classes
- 18.12.1.5 The Message Decoder
- 18.12.1.6 The HTML Page
- 18.12.2.1 To Run the websocketbot Example Application Using NetBeans IDE
- 18.12.2.2 To Run the websocketbot Example Application Using Maven
- 18.12.2.3 To Test the websocketbot Example Application
- 19.1 Introduction to JSON
- 19.1.1 JSON Syntax
- 19.1.2 Uses of JSON
- 19.1.3 Generating and Parsing JSON Data
- 19.3.1 Creating an Object Model from JSON Data
- 19.3.2 Creating an Object Model from Application Code
- 19.3.3 Navigating an Object Model
- 19.3.4 Writing an Object Model to a Stream
- 19.4.1 Reading JSON Data Using a Parser
- 19.4.2 Writing JSON Data Using a Generator
- 19.6.1 Components of the jsonpmodel Example Application
- 19.6.2 Running the jsonpmodel Example Application
- 19.6.2.1 To Run the jsonpmodel Example Application Using NetBeans IDE
- 19.6.2.2 To Run the jsonpmodel Example Application Using Maven
- 19.7.1 Components of the jsonpstreaming Example Application
- 19.7.2 Running the jsonpstreaming Example Application
- 19.7.2.1 To Run the jsonpstreaming Example Application Using NetBeans IDE
- 19.7.2.2 To Run the jsonpstreaming Example Application Using Maven
- 20.1 Java Platform Localization Classes
- 20.2 Providing Localized Messages and Labels
- 20.2.1 Establishing the Locale
- 20.2.2 Setting the Resource Bundle
- 20.2.3 Retrieving Localized Messages
- 20.4.1 Character Sets
- 20.4.2 Character Encoding
- 21 Introduction to Bean Validation
- 21.1 Using Bean Validation Constraints
- 21.2 Validating Null and Empty Strings
- 21.3 Validating Constructors and Methods
- 21.3.1 Cross-Parameter Constraints
- 21.3.2 Identifying Parameter Constraint Violations
- 21.3.3 Adding Constraints to Method Return Values
- 22.1 Creating Custom Constraints
- 22.1.1 Using the Built-In Constraints to Make a New Constraint
- 22.1.2 Removing Ambiguity in Constraint Targets
- 22.2.1 The ValidationMessages Resource Bundle
- 22.2.1.1 Localizing Validation Messages
- 22.3.1 Customizing Group Validation Order
- 22.4.1 Rules for Using Method Constraints in Type Hierarchies
- 23 Introduction to Contexts and Dependency Injection for Java EE
- 23.1 Getting Started
- 23.2 Overview of CDI
- 23.3 About Beans
- 23.4 About CDI Managed Beans
- 23.5 Beans as Injectable Objects
- 23.6 Using Qualifiers
- 23.7 Injecting Beans
- 23.8 Using Scopes
- 23.9 Giving Beans EL Names
- 23.10 Adding Setter and Getter Methods
- 23.11 Using a Managed Bean in a Facelets Page
- 23.12 Injecting Objects by Using Producer Methods
- 23.13 Configuring a CDI Application
- 23.14 Using the @PostConstruct and @PreDestroy Annotations with CDI Managed Bean Classes
- 23.14.1 To Initialize a Managed Bean Using the @PostConstruct Annotation
- 23.14.2 To Prepare for the Destruction of a Managed Bean Using the @PreDestroy Annotation
- 24.1 The simplegreeting CDI Example
- 24.1.1 The simplegreeting Source Files
- 24.1.2 The Facelets Template and Page
- 24.1.3 Running the simplegreeting Example
- 24.1.3.1 To Build, Package, and Run the simplegreeting Example Using NetBeans IDE
- 24.1.3.2 To Build, Package, and Deploy the simplegreeting Example Using Maven
- 24.1.3.3 To Run the simplegreeting Example
- 24.2.1 The guessnumber-cdi Source Files
- 24.2.1.1 The @MaxNumber and @Random Qualifier Interfaces
- 24.2.1.2 The Generator Managed Bean
- 24.2.1.3 The UserNumberBean Managed Bean
- 24.2.3.1 To Build, Package, and Deploy the guessnumber-cdi Example Using NetBeans IDE
- 24.2.3.2 To Build, Package, and Deploy the guessnumber-cdi Example Using Maven
- 24.2.3.3 To Run the guessnumber Example
- 25.1 Packaging CDI Applications
- 25.2 Using Alternatives in CDI Applications
- 25.2.1 Using Specialization
- 25.3.1 Using Producer Methods
- 25.3.2 Using Producer Fields to Generate Resources
- 25.3.3 Using a Disposer Method
- 25.5.1 Defining Events
- 25.5.2 Using Observer Methods to Handle Events
- 25.5.3 Firing Events
- 26.1 The encoder Example: Using Alternatives
- 26.1.1 The Coder Interface and Implementations
- 26.1.2 The encoder Facelets Page and Managed Bean
- 26.1.3 Running the encoder Example
- 26.1.3.1 To Build, Package, and Deploy the encoder Example Using NetBeans IDE
- 26.1.3.2 To Run the encoder Example Using NetBeans IDE
- 26.1.3.3 To Build, Package, and Deploy the encoder Example Using Maven
- 26.1.3.4 To Run the encoder Example Using Maven
- 26.2.1 Components of the producermethods Example
- 26.2.2 Running the producermethods Example
- 26.2.2.1 To Build, Package, and Deploy the producermethods Example Using NetBeans IDE
- 26.2.2.2 To Build, Package, and Deploy the producermethods Example Using Maven
- 26.2.2.3 To Run the producermethods Example
- 26.3.1 The Producer Field for the producerfields Example
- 26.3.2 The producerfields Entity and Session Bean
- 26.3.3 The producerfields Facelets Pages and Managed Bean
- 26.3.4 Running the producerfields Example
- 26.3.4.1 To Build, Package, and Deploy the producerfields Example Using NetBeans IDE
- 26.3.4.2 To Build, Package, and Deploy the producerfields Example Using Maven
- 26.3.4.3 To Run the producerfields Example
- 26.4.1 The PaymentEvent Event Class
- 26.4.2 The PaymentHandler Event Listener
- 26.4.3 The billpayment Facelets Pages and Managed Bean
- 26.4.4 The LoggedInterceptor Interceptor Class
- 26.4.5 Running the billpayment Example
- 26.4.5.1 To Build, Package, and Deploy the billpayment Example Using NetBeans IDE
- 26.4.5.2 To Build, Package, and Deploy the billpayment Example Using Maven
- 26.4.5.3 To Run the billpayment Example
- 26.5.1 Components of the decorators Example
- 26.5.2 Running the decorators Example
- 26.5.2.1 To Build, Package, and Deploy the decorators Example Using NetBeans IDE
- 26.5.2.2 To Build, Package, and Deploy the decorators Example Using Maven
- 26.5.2.3 To Run the decorators Example
- 27 Introduction to Web Services
- 27.1 What Are Web Services?
- 27.2 Types of Web Services
- 27.2.1 "Big" Web Services
- 27.2.2 RESTful Web Services
- 28.1 Creating a Simple Web Service and Clients with JAX-WS
- 28.1.1 Requirements of a JAX-WS Endpoint
- 28.1.2 Coding the Service Endpoint Implementation Class
- 28.1.3 Building, Packaging, and Deploying the Service
- 28.1.3.1 To Build, Package, and Deploy the Service Using NetBeans IDE
- 28.1.3.2 To Build, Package, and Deploy the Service Using Maven
- 28.1.4.1 To Test the Service without a Client
- 28.1.5.1 Coding the Application Client
- 28.1.5.2 Running the Application Client
- 28.1.6.1 Coding the Servlet
- 28.1.6.2 Running the Web Client
- 28.2.1 Schema-to-Java Mapping
- 28.2.2 Java-to-Schema Mapping
- 29.1 What Are RESTful Web Services?
- 29.2 Creating a RESTful Root Resource Class
- 29.2.1 Developing RESTful Web Services with JAX-RS
- 29.2.2 Overview of a JAX-RS Application
- 29.2.3 The @Path Annotation and URI Path Templates
- 29.2.4 Responding to HTTP Methods and Requests
- 29.2.4.1 The Request Method Designator Annotations
- 29.2.4.2 Using Entity Providers to Map HTTP Response and Request Entity Bodies
- 29.2.5.1 The @Produces Annotation
- 29.2.5.2 The @Consumes Annotation
- 29.2.7.1 Configuring a JAX-RS Application Using a Subclass of Application
- 29.2.7.2 Configuring the Base URI in web.xml
- 29.3.1 Creating a Simple RESTful Web Service
- 29.3.1.1 To Create a RESTful Web Service Using NetBeans IDE
- 29.3.2.1 Components of the rsvp Example Application
- 29.3.2.2 Running the rsvp Example Application
- 30.1 Overview of the Client API
- 30.1.1 Creating a Basic Client Request Using the Client API
- 30.1.1.1 Obtaining the Client Instance
- 30.1.1.2 Setting the Client Target
- 30.1.1.3 Setting Path Parameters in Targets
- 30.1.1.4 Invoking the Request
- 30.2.1 The Client API in the rsvp Example Application
- 30.2.2 The Client API in the customer Example Application
- 30.3.1 Configuring the Client Request
- 30.3.1.1 Setting Message Headers in the Client Request
- 30.3.1.2 Setting Cookies in the Client Request
- 30.3.1.3 Adding Filters to the Client
- 30.3.2.1 Using Custom Callbacks in Asynchronous Invocations
- 31.1 Annotations for Field and Bean Properties of Resource Classes
- 31.1.1 Extracting Path Parameters
- 31.1.2 Extracting Query Parameters
- 31.1.3 Extracting Form Data
- 31.1.4 Extracting the Java Type of a Request or Response
- 31.2.1 Using Constraint Annotations on Resource Methods
- 31.2.2 Validating Entity Data
- 31.2.3 Validation Exception Handling and Response Codes
- 31.3.1 Subresource Methods
- 31.3.2 Subresource Locators
- 31.7.1 Using Java Objects to Model Your Data
- 31.7.2 Starting from an Existing XML Schema Definition
- 31.7.3 Using JSON with JAX-RS and JAXB
- 31.8.1 Overview of the customer Example Application
- 31.8.2 The Customer and Address Entity Classes
- 31.8.3 The CustomerService Class
- 31.8.4 Using the JAX-RS Client in the CustomerBean Classes
- 31.8.5 Running the customer Example
- 31.8.5.1 To Build, Package, and Deploy the customer Example Using NetBeans IDE
- 31.8.5.2 To Build, Package, and Deploy the customer Example Using Maven
- 32 Enterprise Beans
- 32.1 What Is an Enterprise Bean?
- 32.1.1 Benefits of Enterprise Beans
- 32.1.2 When to Use Enterprise Beans
- 32.1.3 Types of Enterprise Beans
- 32.2.1 Types of Session Beans
- 32.2.1.1 Stateful Session Beans
- 32.2.1.2 Stateless Session Beans
- 32.2.1.3 Singleton Session Beans
- 32.3.1 What Makes Message-Driven Beans Different from Session Beans?
- 32.3.2 When to Use Message-Driven Beans
- 32.4.1 Using Enterprise Beans in Clients
- 32.4.1.1 Portable JNDI Syntax
- 32.4.3.1 Accessing Local Enterprise Beans Using the No-Interface View
- 32.4.3.2 Accessing Local Enterprise Beans That Implement Business Interfaces
- 32.4.6.1 Isolation
- 32.4.6.2 Granularity of Accessed Data
- 32.7.1 The Lifecycle of a Stateful Session Bean
- 32.7.2 The Lifecycle of a Stateless Session Bean
- 32.7.3 The Lifecycle of a Singleton Session Bean
- 32.7.4 The Lifecycle of a Message-Driven Bean
- 33.1 Creating the Enterprise Bean
- 33.1.1 Coding the Enterprise Bean Class
- 33.1.2 Creating the converter Web Client
- 33.1.3 Running the converter Example
- 33.1.3.1 To Run the converter Example Using NetBeans IDE
- 33.1.3.2 To Run the converter Example Using Maven
- 33.2.1 To Modify a Class File
- 34.1 The cart Example
- 34.1.1 The Business Interface
- 34.1.2 Session Bean Class
- 34.1.2.1 Lifecycle Callback Methods
- 34.1.2.2 Business Methods
- 34.1.5.1 To Run the cart Example Using NetBeans IDE
- 34.1.5.2 To Run the cart Example Using Maven
- 34.2.1 Creating a Singleton Session Bean
- 34.2.1.1 Initializing Singleton Session Beans
- 34.2.1.2 Managing Concurrent Access in a Singleton Session Bean
- 34.2.1.3 Handling Errors in a Singleton Session Bean
- 34.2.3.1 To Run the counter Example Using NetBeans IDE
- 34.2.3.2 To Run the counter Example Using Maven
- 34.3.1 The Web Service Endpoint Implementation Class
- 34.3.2 Stateless Session Bean Implementation Class
- 34.3.3 Running the helloservice Example
- 34.3.3.1 To Build, Package, and Deploy the helloservice Example Using NetBeans IDE
- 34.3.3.2 To Build, Package, and Deploy the helloservice Example Using Maven
- 34.3.3.3 To Test the Service without a Client
- 34.4.1 Creating Calendar-Based Timer Expressions
- 34.4.1.1 Specifying Multiple Values in Calendar Expressions
- 34.4.2.1 The @Timeout Method
- 34.4.2.2 Creating Programmatic Timers
- 34.4.8.1 To Run the timersession Example Using NetBeans IDE
- 34.4.8.2 To Build, Package, and Deploy the timersession Example Using Maven
- 34.4.8.3 To Run the Web Client
- 35.1 Overview of the Embedded Enterprise Bean Container
- 35.2 Developing Embeddable Enterprise Bean Applications
- 35.2.1 Running Embedded Applications
- 35.2.2 Creating the Enterprise Bean Container
- 35.2.2.1 Explicitly Specifying Enterprise Bean Modules to Be Initialized
- 35.3.1 To Run the standalone Example Application Using NetBeans IDE
- 35.3.2 To Run the standalone Example Application Using Maven
- 36.1 Asynchronous Method Invocation
- 36.1.1 Creating an Asynchronous Business Method
- 36.1.2 Calling Asynchronous Methods from Enterprise Bean Clients
- 36.1.2.1 Retrieving the Final Result from an Asynchronous Method Invocation
- 36.1.2.2 Cancelling an Asynchronous Method Invocation
- 36.1.2.3 Checking the Status of an Asynchronous Method Invocation
- 36.2.1 Architecture of the async-war Module
- 36.2.2 Running the async Example
- 36.2.2.1 To Run the async Example Application Using NetBeans IDE
- 36.2.2.2 To Run the async Example Application Using Maven
- 37 Introduction to the Java Persistence API
- 37.1 Entities
- 37.1.1 Requirements for Entity Classes
- 37.1.2 Persistent Fields and Properties in Entity Classes
- 37.1.2.1 Persistent Fields
- 37.1.2.2 Persistent Properties
- 37.1.2.3 Using Collections in Entity Fields and Properties
- 37.1.2.4 Validating Persistent Fields and Properties
- 37.1.5.1 Bidirectional Relationships
- 37.1.5.2 Unidirectional Relationships
- 37.1.5.3 Queries and Relationship Direction
- 37.1.5.4 Cascade Operations and Relationships
- 37.1.5.5 Orphan Removal in Relationships
- 37.2.1 Abstract Entities
- 37.2.2 Mapped Superclasses
- 37.2.3 Non-Entity Superclasses
- 37.2.4 Entity Inheritance Mapping Strategies
- 37.2.4.1 The Single Table per Class Hierarchy Strategy
- 37.2.4.2 The Table per Concrete Class Strategy
- 37.2.4.3 The Joined Subclass Strategy
- 37.3.1 The EntityManager Interface
- 37.3.1.1 Container-Managed Entity Managers
- 37.3.1.2 Application-Managed Entity Managers
- 37.3.1.3 Finding Entities Using the EntityManager
- 37.3.1.4 Managing an Entity Instance's Lifecycle
- 37.3.1.5 Persisting Entity Instances
- 37.3.1.6 Removing Entity Instances
- 37.3.1.7 Synchronizing Entity Data to the Database
- 37.5.1 Configuring an Application to Create or Drop Database Tables
- 37.5.2 Loading Data Using SQL Scripts
- 38.1 The order Application
- 38.1.1 Entity Relationships in the order Application
- 38.1.1.1 Self-Referential Relationships
- 38.1.1.2 One-to-One Relationships
- 38.1.1.3 One-to-Many Relationship Mapped to Overlapping Primary and Foreign Keys
- 38.1.1.4 Unidirectional Relationships
- 38.1.2.1 Generated Primary Keys
- 38.1.2.2 Compound Primary Keys
- 38.1.7.1 Creating Entities
- 38.1.7.2 Finding Entities
- 38.1.7.3 Setting Entity Relationships
- 38.1.7.4 Using Queries
- 38.1.7.5 Removing Entities
- 38.1.8.1 To Run the order Example Using NetBeans IDE
- 38.1.8.2 To Run the order Example Using Maven
- 38.2.1 Relationships in the roster Application
- 38.2.1.1 The Many-To-Many Relationship in roster
- 38.2.3.1 Metamodel Classes in the roster Application
- 38.2.3.2 Obtaining a CriteriaBuilder Instance in RequestBean
- 38.2.3.3 Creating Criteria Queries in RequestBean's Business Methods
- 38.2.5.1 To Run the roster Example Using NetBeans IDE
- 38.2.5.2 To Run the roster Example Using Maven
- 38.3.1 Bean Validation Constraints in address-book
- 38.3.2 Specifying Error Messages for Constraints in address-book
- 38.3.3 Validating Contact Input from a JavaServer Faces Application
- 38.3.4 Running the address-book Example
- 38.3.4.1 To Run the address-book Example Using NetBeans IDE
- 38.3.4.2 To Run the address-book Example Using Maven
- 39.1 Query Language Terminology
- 39.2 Creating Queries Using the Java Persistence Query Language
- 39.2.1 Named Parameters in Queries
- 39.2.2 Positional Parameters in Queries
- 39.3.1 Select Statements
- 39.3.2 Update and Delete Statements
- 39.4.1 Simple Queries
- 39.4.1.1 A Basic Select Query
- 39.4.1.2 Eliminating Duplicate Values
- 39.4.1.3 Using Named Parameters
- 39.4.2.1 A Simple Query with Relationships
- 39.4.2.2 Navigating to Single-Valued Relationship Fields
- 39.4.2.3 Traversing Relationships with an Input Parameter
- 39.4.2.4 Traversing Multiple Relationships
- 39.4.2.5 Navigating According to Related Fields
- 39.4.3.1 The LIKE Expression
- 39.4.3.2 The IS NULL Expression
- 39.4.3.3 The IS EMPTY Expression
- 39.4.3.4 The BETWEEN Expression
- 39.4.3.5 Comparison Operators
- 39.4.4.1 Update Queries
- 39.4.4.2 Delete Queries
- 39.5.1 BNF Symbols
- 39.5.2 BNF Grammar of the Java Persistence Query Language
- 39.5.3 FROM Clause
- 39.5.3.1 Identifiers
- 39.5.3.2 Identification Variables
- 39.5.3.3 Range Variable Declarations
- 39.5.3.4 Collection Member Declarations
- 39.5.3.5 Joins
- 39.5.4.1 Examples of Path Expressions
- 39.5.4.2 Expression Types
- 39.5.4.3 Navigation
- 39.5.5.1 Literals
- 39.5.5.2 Input Parameters
- 39.5.5.3 Conditional Expressions
- 39.5.5.4 Operators and Their Precedence
- 39.5.5.5 BETWEEN Expressions
- 39.5.5.6 IN Expressions
- 39.5.5.7 LIKE Expressions
- 39.5.5.8 NULL Comparison Expressions
- 39.5.5.9 Empty Collection Comparison Expressions
- 39.5.5.10 Collection Member Expressions
- 39.5.5.11 Subqueries
- 39.5.5.12 Functional Expressions
- 39.5.5.13 Case Expressions
- 39.5.5.14 NULL Values
- 39.5.5.15 Equality Semantics
- 39.5.6.1 Return Types
- 39.5.6.2 The DISTINCT Keyword
- 39.5.6.3 Constructor Expressions
- 40.1 Overview of the Criteria and Metamodel APIs
- 40.2 Using the Metamodel API to Model Entity Classes
- 40.2.1 Using Metamodel Classes
- 40.3.1 Creating a Criteria Query
- 40.3.2 Query Roots
- 40.3.3 Querying Relationships Using Joins
- 40.3.4 Path Navigation in Criteria Queries
- 40.3.5 Restricting Criteria Query Results
- 40.3.5.1 The Expression Interface Methods
- 40.3.5.2 Expression Methods in the CriteriaBuilder Interface
- 40.3.6.1 Ordering Results
- 40.3.6.2 Grouping Results
- 40.3.7.1 Single-Valued Query Results
- 40.3.7.2 Collection-Valued Query Results
- 41.1 Overview of String-Based Criteria API Queries
- 41.2 Creating String-Based Queries
- 41.3 Executing String-Based Queries
- 42.1 Overview of Entity Locking and Concurrency
- 42.1.1 Using Optimistic Locking
- 42.2.1 Setting the Lock Mode
- 42.2.2 Using Pessimistic Locking
- 42.2.2.1 Pessimistic Locking Timeouts
- 43.1 Entity Graph Basics
- 43.1.1 The Default Entity Graph
- 43.1.2 Using Entity Graphs in Persistence Operations
- 43.1.2.1 Fetch Graphs
- 43.1.2.2 Load Graphs
- 43.2.1 Applying Named Entity Graph Annotations to Entity Classes
- 43.2.2 Obtaining EntityGraph Instances from Named Entity Graphs
- 44.1 Overview of the Second-Level Cache
- 44.1.1 Controlling whether Entities May Be Cached
- 44.2.1 Setting the Cache Retrieval and Store Modes
- 44.2.1.1 Cache Retrieval Mode
- 44.2.1.2 Cache Store Mode
- 44.2.1.3 Setting the Cache Retrieval or Store Mode
- 44.2.2.1 Checking whether an Entity's Data Is Cached
- 44.2.2.2 Removing an Entity from the Cache
- 44.2.2.3 Removing All Data from the Cache
- 45 Java Message Service Concepts
- 45.1 Overview of the JMS API
- 45.1.1 What Is Messaging?
- 45.1.2 What Is the JMS API?
- 45.1.3 When Can You Use the JMS API?
- 45.1.4 How Does the JMS API Work with the Java EE Platform?
- 45.2.1 JMS API Architecture
- 45.2.2 Messaging Styles
- 45.2.2.1 Point-to-Point Messaging Style
- 45.2.2.2 Publish/Subscribe Messaging Style
- 45.3.1 JMS Administered Objects
- 45.3.1.1 JMS Connection Factories
- 45.3.1.2 JMS Destinations
- 45.3.6.1 JMS Message Listeners
- 45.3.6.2 JMS Message Selectors
- 45.3.6.3 Consuming Messages from Topics
- 45.3.6.4 Creating Durable Subscriptions
- 45.3.6.5 Creating Shared Subscriptions
- 45.3.7.1 Message Headers
- 45.3.7.2 Message Properties
- 45.3.7.3 Message Bodies
- 45.4.1 Controlling Message Acknowledgment
- 45.4.2 Specifying Options for Sending Messages
- 45.4.2.1 Specifying Message Persistence
- 45.4.2.2 Setting Message Priority Levels
- 45.4.2.3 Allowing Messages to Expire
- 45.4.2.4 Specifying a Delivery Delay
- 45.4.2.5 Using JMSProducer Method Chaining
- 45.5.1 Creating Resources for Java EE Applications
- 45.5.2 Using Resource Injection in Enterprise Bean or Web Components
- 45.5.2.1 Injecting a ConnectionFactory, Queue, or Topic
- 45.5.2.2 Injecting a JMSContext Object
- 45.5.3.1 Managing JMS Resources in Web and EJB Components
- 45.5.3.2 Managing Transactions in Session Beans
- 46.1 Overview of the JMS Examples
- 46.2 Writing Simple JMS Applications
- 46.2.1 Starting the JMS Provider
- 46.2.2 Creating JMS Administered Objects
- 46.2.2.1 To Create Resources for the Simple Examples
- 46.2.3.1 To Build All the Simple Examples Using NetBeans IDE
- 46.2.3.2 To Build All the Simple Examples Using Maven
- 46.2.4.1 The Producer.java Client
- 46.2.4.2 To Run the Producer Client
- 46.2.5.1 The SynchConsumer.java Client
- 46.2.5.2 To Run the SynchConsumer and Producer Clients
- 46.2.6.1 Writing the AsynchConsumer.java and TextListener.java Clients
- 46.2.6.2 To Run the AsynchConsumer and Producer Clients
- 46.2.7.1 The MessageBrowser.java Client
- 46.2.7.2 To Run the QueueBrowser Client
- 46.2.9.1 To Run the ClientAckConsumer Client
- 46.3.1 Using Durable Subscriptions
- 46.3.1.1 To Create Resources for the Durable Subscription Example
- 46.3.1.2 To Run the Durable Subscription Example
- 46.3.1.3 To Run the unsubscriber Example
- 46.3.2.1 To Create Resources for the transactedexample Example
- 46.3.2.2 To Run the transactedexample Clients
- 46.4.1 Using Shared Nondurable Subscriptions
- 46.4.1.1 Writing the Clients for the Shared Consumer Example
- 46.4.1.2 To Run the SharedConsumer and Producer Clients
- 46.4.2.1 To Run the SharedDurableConsumer and Producer Clients
- 46.5.1 The websimplemessage Facelets Pages
- 46.5.2 The websimplemessage Managed Beans
- 46.5.3 Running the websimplemessage Example
- 46.5.3.1 Creating Resources for the websimplemessage Example
- 46.5.3.2 To Package and Deploy websimplemessage Using NetBeans IDE
- 46.5.3.3 To Package and Deploy websimplemessage Using Maven
- 46.5.3.4 To Run the websimplemessage Example
- 46.6.1 Overview of the simplemessage Example
- 46.6.2 The simplemessage Application Client
- 46.6.3 The simplemessage Message-Driven Bean Class