Enterprise JavaBeans 3.0, 5th Edition

Book description

If you're up on the latest Java technologies, then you know that Enterprise JavaBeans (EJB) 3.0 is the hottest news in Java this year. In fact, EJB 3.0 is being hailed as the new standard of server-side business logic programming. And O'Reilly's award-winning book on EJB has been refreshed just in time to capitalize on the technology's latest rise in popularity.

This fifth edition, written by Bill Burke and Richard Monson-Haefel, has been updated to capture the very latest need-to-know Java technologies in the same award-winning fashion that drove the success of the previous four strong-selling editions. Bill Burke, Chief Architect at JBoss, Inc., represents the company on the EJB 3.0 and Java EE 5 specification committees. Richard Monson-Haefel is one of the world's leading experts on Enterprise Java.

Enterprise JavaBeans 3.0, 5th Edition is organized into two parts: the technical manuscript followed by the JBoss workbook. The technical manuscript explains what EJB is, how it works, and when to use it. The JBoss workbook provides step-by-step instructions for installing, configuring, and running the examples from the manuscript on the JBoss 4.0 Application Server.

Although EJB makes application development much simpler, it's still a complex and ambitious technology that requires a great deal of time to study and master. But now, thanks to Enterprise JavaBeans 3.0, 5th Edition, you can overcome the complexities of EJBs and learn from hundreds of practical examples that are largeenough to test key concepts but small enough to be taken apart and explained in the detail that you need. Now you can harness the complexity of EJB with just a single resource by your side.

Publisher resources

View/Submit Errata

Table of contents

  1. Dedication
  2. A Note Regarding Supplemental Files
  3. Foreword
  4. Preface
    1. Author’s Note
    2. Who Should Read This Book
    3. How This Book Is Organized
      1. Part I: The EJB 3.0 Standard
      2. Part II: The JBoss Workbook
    4. Software and Versions
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Enabled
    8. Comments and Questions
    9. Acknowledgments
  5. I. The EJB 3.0 Standard
    1. 1. Introduction
      1. 1.1. Server-Side Components
        1. 1.1.1. Enterprise JavaBeans Defined
      2. 1.2. Persistence and Entity Beans
      3. 1.3. Asynchronous Messaging
        1. 1.3.1. Java Message Service
        2. 1.3.2. Message-Driven Beans and JCA 1.5
      4. 1.4. Web Services
      5. 1.5. Titan Cruises: An Imaginary Business
      6. 1.6. What’s Next?
    2. 2. Architectural Overview
      1. 2.1. The Entity Bean
        1. 2.1.1. The Entity Bean Class
        2. 2.1.2. XML Deployment Descriptors and JAR Files
      2. 2.2. The Enterprise Bean Component
        1. 2.2.1. Classes and Interfaces
          1. 2.2.1.1. Naming conventions
          2. 2.2.1.2. The remote interface
          3. 2.2.1.3. The bean class
          4. 2.2.1.4. What about message-driven beans?
        2. 2.2.2. Annotations, Deployment Descriptors, and JAR Files
        3. 2.2.3. The EJB Container
          1. 2.2.3.1. The proxy stub, EJB container, and bean instance
      3. 2.3. Using Enterprise and Entity Beans
        1. 2.3.1. Modeling Taskflow with Session Beans
          1. 2.3.1.1. Stateful and statelessl session beans
        2. 2.3.2. Message-Driven Beans
      4. 2.4. The Bean-Container Contract
      5. 2.5. Summary
    3. 3. Resource Management and Primary Services
      1. 3.1. Resource Management
        1. 3.1.1. Instance Pooling
          1. 3.1.1.1. The stateless session bean life cycle
          2. 3.1.1.2. Message-driven beans and instance pooling
        2. 3.1.2. The Activation Mechanism
        3. 3.1.3. Java EE Connector Architecture
          1. 3.1.3.1. Java EE Connectors 1.5
      2. 3.2. Primary Services
        1. 3.2.1. Concurrency
          1. 3.2.1.1. Concurrency with session and entity beans
          2. 3.2.1.2. Concurrency with message-driven beans
        2. 3.2.2. Transactions
        3. 3.2.3. Persistence
          1. 3.2.3.1. Java Persistence
          2. 3.2.3.2. Object-to-relational persistence
        4. 3.2.4. Distributed Objects
        5. 3.2.5. Asynchronous Enterprise Messaging
        6. 3.2.6. EJB Timer Service
        7. 3.2.7. Naming
        8. 3.2.8. Security
        9. 3.2.9. Primary Services and Interoperability
          1. 3.2.9.1. IIOP
          2. 3.2.9.2. SOAP and WSDL
      3. 3.3. What’s Next?
    4. 4. Developing Your First Beans
      1. 4.1. Developing an Entity Bean
        1. 4.1.1. Cabin: The Bean Class
        2. 4.1.2. The persistence.xml File
      2. 4.2. Developing a Session Bean
        1. 4.2.1. TravelAgentRemote: The Remote Interface
        2. 4.2.2. TravelAgentBean: The Bean Class
        3. 4.2.3. titan.jar: The JAR File
        4. 4.2.4. Creating a CABIN Table in the Database
        5. 4.2.5. Deploying the EJB JAR
        6. 4.2.6. Creating a Client Application
          1. 4.2.6.1. Creating a new Cabin entity
    5. 5. Persistence: EntityManager
      1. 5.1. Entities Are POJOs
      2. 5.2. Managed Versus Unmanaged Entities
        1. 5.2.1. Persistence Context
          1. 5.2.1.1. Transaction-scoped persistence context
          2. 5.2.1.2. Extended persistence context
          3. 5.2.1.3. Detached entities
      3. 5.3. Packaging a Persistence Unit
        1. 5.3.1. The Persistence Unit Class Set
      4. 5.4. Obtaining an EntityManager
        1. 5.4.1. EntityManagerFactory
          1. 5.4.1.1. Getting an EntityManagerFactory in Java SE
          2. 5.4.1.2. Getting an EntityManagerFactory in Java EE
        2. 5.4.2. Obtaining a Persistence Context
      5. 5.5. Interacting with an EntityManager
        1. 5.5.1. Persisting Entities
        2. 5.5.2. Finding Entities
          1. 5.5.2.1. find( ) and getReference( )
          2. 5.5.2.2. Queries
        3. 5.5.3. Updating Entities
        4. 5.5.4. Merging Entities
        5. 5.5.5. Removing Entities
        6. 5.5.6. refresh( )
        7. 5.5.7. contains( ) and clear( )
        8. 5.5.8. flush( ) and FlushModeType
        9. 5.5.9. Locking
        10. 5.5.10. getDelegate( )
      6. 5.6. Resource Local Transactions
    6. 6. Mapping Persistent Objects
      1. 6.1. The Programming Model
        1. 6.1.1. The Customer Bean
        2. 6.1.2. The Bean Class
        3. 6.1.3. XML Mapping File
      2. 6.2. Basic Relational Mapping
        1. 6.2.1. Elementary Schema Mappings
          1. 6.2.1.1. @Table
          2. 6.2.1.2. @Column
          3. 6.2.1.3. XML
      3. 6.3. Primary Keys
        1. 6.3.1. @Id
        2. 6.3.2. Table Generators
        3. 6.3.3. Sequence Generators
        4. 6.3.4. Primary-Key Classes and Composite Keys
          1. 6.3.4.1. @IdClass
          2. 6.3.4.2. @EmbeddedId
      4. 6.4. Property Mappings
        1. 6.4.1. @Transient
        2. 6.4.2. @Basic and FetchType
        3. 6.4.3. @Temporal
        4. 6.4.4. @Lob
        5. 6.4.5. @Enumerated
      5. 6.5. Multitable Mappings with @SecondaryTable
      6. 6.6. @Embedded Objects
    7. 7. Entity Relationships
      1. 7.1. The Seven Relationship Types
        1. 7.1.1. One-to-One Unidirectional Relationship
          1. 7.1.1.1. Relational database schema
          2. 7.1.1.2. Programming model
          3. 7.1.1.3. Primary-key join columns
          4. 7.1.1.4. One-to-one unidirectional XML mapping
          5. 7.1.1.5. Default relationship mapping
        2. 7.1.2. One-to-One Bidirectional Relationship
          1. 7.1.2.1. Relational database schema
          2. 7.1.2.2. One-to-one bidirectional XML mapping
          3. 7.1.2.3. Default relationship mapping
        3. 7.1.3. One-to-Many Unidirectional Relationship
          1. 7.1.3.1. Relational database schema
          2. 7.1.3.2. Programming model
          3. 7.1.3.3. One-to-many unidirectional XML mapping
          4. 7.1.3.4. Join table mapping
          5. 7.1.3.5. One-to-many unidirectional join table XML mapping
          6. 7.1.3.6. Default relationship mapping
        4. 7.1.4. The Cruise, Ship, and Reservation Entities
        5. 7.1.5. Many-to-One Unidirectional Relationship
          1. 7.1.5.1. Relational database schema
          2. 7.1.5.2. Programming model
          3. 7.1.5.3. Many-to-one unidirectional XML mapping
          4. 7.1.5.4. Default relationship mapping
        6. 7.1.6. One-to-Many Bidirectional Relationship
          1. 7.1.6.1. Relational database schema
          2. 7.1.6.2. Programming model
          3. 7.1.6.3. One-to-many bidirectional XML mapping
          4. 7.1.6.4. Default relationship mapping
        7. 7.1.7. Many-to-Many Bidirectional Relationship
          1. 7.1.7.1. Relational database schema
          2. 7.1.7.2. Programming model
          3. 7.1.7.3. Many-to-many bidirectional XML mapping
          4. 7.1.7.4. Default Rrelationship mapping
        8. 7.1.8. Many-to-Many Unidirectional Relationship
          1. 7.1.8.1. Relational database schema
          2. 7.1.8.2. Programming model
          3. 7.1.8.3. Many-to-many unidirectional XML mapping
          4. 7.1.8.4. Default relationship mapping
      2. 7.2. Mapping Collection-Based Relationships
        1. 7.2.1. Ordered List-Based Relationship
          1. 7.2.1.1. List XML mapping
        2. 7.2.2. Map-Based Relationship
          1. 7.2.2.1. Map XML mapping
      3. 7.3. Detached Entities and FetchType
      4. 7.4. Cascading
        1. 7.4.1. PERSIST
        2. 7.4.2. MERGE
        3. 7.4.3. REMOVE
        4. 7.4.4. REFRESH
        5. 7.4.5. ALL
        6. 7.4.6. When to Use Cascading
    8. 8. Entity Inheritance
      1. 8.1. Single Table per Class Hierarchy
        1. 8.1.1. Advantages
        2. 8.1.2. Disadvantages
      2. 8.2. Table per Concrete Class
        1. 8.2.1. Advantages
        2. 8.2.2. Disadvantages
      3. 8.3. Table per Subclass
        1. 8.3.1. Advantages
        2. 8.3.2. Disadvantages
      4. 8.4. Mixing Strategies
      5. 8.5. Nonentity Base Classes
    9. 9. Queries and EJB QL
      1. 9.1. Query API
        1. 9.1.1. Parameters
        2. 9.1.2. Date Parameters
        3. 9.1.3. Paging Results
        4. 9.1.4. Hints
        5. 9.1.5. FlushMode
      2. 9.2. EJB QL
        1. 9.2.1. Abstract Schema Names
        2. 9.2.2. Simple Queries
        3. 9.2.3. Selecting Entity and Relationship Properties
        4. 9.2.4. Constructor Expressions
        5. 9.2.5. The IN Operator and INNER JOIN
        6. 9.2.6. LEFT JOIN
        7. 9.2.7. Fetch Joins
        8. 9.2.8. Using DISTINCT
        9. 9.2.9. The WHERE Clause and Literals
        10. 9.2.10. The WHERE Clause and Operator Precedence
        11. 9.2.11. The WHERE Clause and Arithmetic Operators
        12. 9.2.12. The WHERE Clause and Logical Operators
        13. 9.2.13. The WHERE Clause and Comparison Symbols
        14. 9.2.14. The WHERE Clause and Equality Semantics
        15. 9.2.15. The WHERE Clause and BETWEEN
        16. 9.2.16. The WHERE Clause and IN
        17. 9.2.17. The WHERE Clause and IS NULL
        18. 9.2.18. The WHERE Clause and IS EMPTY
        19. 9.2.19. The WHERE Clause and MEMBER OF
        20. 9.2.20. The WHERE Clause and LIKE
        21. 9.2.21. Functional Expressions
          1. 9.2.21.1. Functional expressions in the WHERE clause
          2. 9.2.21.2. Functions returning dates and times
          3. 9.2.21.3. Aggregate functions in the SELECT clause
            1. 9.2.21.3.1. COUNT (identifier or path expression)
            2. 9.2.21.3.2. MAX( path expression), MIN( path expression)
            3. 9.2.21.3.3. AVG( numeric ), SUM( numeric)
            4. 9.2.21.3.4. DISTINCT, nulls, and empty arguments
        22. 9.2.22. The ORDER BY Clause
        23. 9.2.23. GROUP BY and HAVING
        24. 9.2.24. Subqueries
          1. 9.2.24.1. ALL, ANY, SOME
          2. 9.2.24.2. EXISTS
        25. 9.2.25. Bulk UPDATE and DELETE
      3. 9.3. Native Queries
        1. 9.3.1. Scalar Native Queries
        2. 9.3.2. Simple Entity Native Queries
        3. 9.3.3. Complex Native Queries
          1. 9.3.3.1. Native queries with multiple entities
          2. 9.3.3.2. Mixed scalar and entity results
      4. 9.4. Named Queries
        1. 9.4.1. Named Native Queries
    10. 10. Entity Callbacks and Listeners
      1. 10.1. Callback Events
      2. 10.2. Callbacks on Entity Classes
      3. 10.3. Entity Listeners
        1. 10.3.1. Default Entity Listeners
        2. 10.3.2. Inheritance and Listeners
    11. 11. Session Beans
      1. 11.1. The Stateless Session Bean
        1. 11.1.1. The ProcessPayment EJB
          1. 11.1.1.1. The database table: PAYMENT
          2. 11.1.1.2. The business interface: ProcessPayment
          3. 11.1.1.3. Entities as parameters
          4. 11.1.1.4. Domain objects: the CreditCardDO and CheckDO classes
          5. 11.1.1.5. An application exception: PaymentException
          6. 11.1.1.6. The bean class: ProcessPaymentBean
          7. 11.1.1.7. Accessing environment properties (injection)
        2. 11.1.2. The XML Deployment Descriptor
      2. 11.2. SessionContext
        1. 11.2.1. EJBContext
      3. 11.3. The Life Cycle of a Stateless Session Bean
        1. 11.3.1. The Does Not Exist State
        2. 11.3.2. The Method-Ready Pool
          1. 11.3.2.1. Transitioning to the Method-Ready Pool
          2. 11.3.2.2. Life in the Method-Ready Pool
          3. 11.3.2.3. Transitioning out of the Method-Ready Pool: the death of a stateless bean instance
      4. 11.4. The Stateful Session Bean
        1. 11.4.1. Getting Set Up for the TravelAgent EJB
        2. 11.4.2. The TravelAgent EJB
          1. 11.4.2.1. The remote interface: TravelAgent
          2. 11.4.2.2. Domain objects: the TicketDO class
          3. 11.4.2.3. Taking a peek at the client view
          4. 11.4.2.4. The bean class: TravelAgentBean
          5. 11.4.2.5. The bookPassage( ) method
          6. 11.4.2.6. The XML Deployment Descriptor
      5. 11.5. The Life Cycle of a Stateful Session Bean
        1. 11.5.1. The Does Not Exist State
        2. 11.5.2. The Method-Ready State
          1. 11.5.2.1. Transitioning into the Method-Ready state
          2. 11.5.2.2. Life in the Method-Ready state
          3. 11.5.2.3. Transitioning out of the Method-Ready state
        3. 11.5.3. The Passivated State
          1. 11.5.3.1. System exceptions
      6. 11.6. Stateful Session Beans and Extended Persistence Contexts
      7. 11.7. Nested Stateful Session Beans
    12. 12. Message-Driven Beans
      1. 12.1. JMS and Message-Driven Beans
        1. 12.1.1. JMS as a Resource
          1. 12.1.1.1. Reimplementing the TravelAgent EJB with JMS
          2. 12.1.1.2. ConnectionFactory and Topic
          3. 12.1.1.3. Connection and Session
          4. 12.1.1.4. MessageProducer
          5. 12.1.1.5. Message types
        2. 12.1.2. JMS Application Client
        3. 12.1.3. JMS Is Asynchronous
        4. 12.1.4. JMS Messaging Models
          1. 12.1.4.1. Publish-and-subscribe
          2. 12.1.4.2. Point-to-point
          3. 12.1.4.3. Which messaging model should you use?
        5. 12.1.5. Session Beans Should Not Receive Messages
        6. 12.1.6. Learning More About JMS
      2. 12.2. JMS-Based Message-Driven Beans
        1. 12.2.1. The ReservationProcessor EJB
        2. 12.2.2. The ReservationProcessorBean Class
          1. 12.2.2.1. MessageDrivenContext
          2. 12.2.2.2. MessageListener interface
          3. 12.2.2.3. Taskflow and integration for B2B: onMessage( )
          4. 12.2.2.4. Sending messages from a message-driven bean
        3. 12.2.3. @MessageDriven
          1. 12.2.3.1. @ActivationConfigProperty
          2. 12.2.3.2. Message selector
          3. 12.2.3.3. Acknowledge mode
          4. 12.2.3.4. Subscription durability
        4. 12.2.4. The XML Deployment Descriptor
        5. 12.2.5. The ReservationProcessor Clients
          1. 12.2.5.1. The reservation message producer
          2. 12.2.5.2. The ticket message consumer
      3. 12.3. The Life Cycle of a Message-Driven Bean
        1. 12.3.1. The Does Not Exist State
        2. 12.3.2. The Method-Ready Pool
          1. 12.3.2.1. Transitioning to the Method-Ready Pool
          2. 12.3.2.2. Life in the Method-Ready Pool
          3. 12.3.2.3. Transitioning out of the Method-Ready Pool: the death of an MDB instance
      4. 12.4. Connector-Based Message-Driven Beans
      5. 12.5. Message Linking
    13. 13. Timer Service
      1. 13.1. Titan’s Maintenance Timer
      2. 13.2. Timer Service API
        1. 13.2.1. The TimerService Interface
          1. 13.2.1.1. Exceptions
        2. 13.2.2. The Timer
          1. 13.2.2.1. Canceling timers
          2. 13.2.2.2. Identifying timers
          3. 13.2.2.3. Retrieving other information from timers
          4. 13.2.2.4. The TimerHandle object
          5. 13.2.2.5. Exceptions
      3. 13.3. Transactions
      4. 13.4. Stateless Session Bean Timers
      5. 13.5. Message-Driven Bean Timers
        1. 13.5.1. Problems with the Timer Service
          1. 13.5.1.1. A very little bit about cron
          2. 13.5.1.2. Improving the Timer Service
          3. 13.5.1.3. Message-driven beans: standard configuration properties
          4. 13.5.1.4. Other problems with the Timer API
      6. 13.6. Final Words
    14. 14. The JNDI ENC and Injection
      1. 14.1. The JNDI ENC
        1. 14.1.1. What Can Be Registered in the JNDI ENC?
        2. 14.1.2. How Is the JNDI ENC Populated?
        3. 14.1.3. XML Population
        4. 14.1.4. Annotation Population
        5. 14.1.5. How Are Things Referenced from the ENC?
          1. 14.1.5.1. Using EJBContext
          2. 14.1.5.2. Annotation injection
          3. 14.1.5.3. Default ENC name
          4. 14.1.5.4. XML injection
          5. 14.1.5.5. XML overrides
          6. 14.1.5.6. Injection and inheritance
      2. 14.2. Reference and Injection Types
        1. 14.2.1. EJB References
          1. 14.2.1.1. @javax.ejb.EJB
          2. 14.2.1.2. XML-based remote EJB references
          3. 14.2.1.3. XML-based local EJB references
          4. 14.2.1.4. Ambiguous and overloaded EJB names
          5. 14.2.1.5. Resolving EJB references
        2. 14.2.2. EntityManagerFactory References
          1. 14.2.2.1. @javax.persistence.PersistenceUnit
          2. 14.2.2.2. XML-based EntityManagerFactory references
          3. 14.2.2.3. Scoped and overloaded unit names
        3. 14.2.3. EntityManager References
          1. 14.2.3.1. @javax.persistence.PersistenceContext
          2. 14.2.3.2. XML-based EntityManager references
          3. 14.2.3.3. Scoped and overloaded unit names
        4. 14.2.4. Resource References
          1. 14.2.4.1. @javax.annotation.Resource
          2. 14.2.4.2. Shareable resources
          3. 14.2.4.3. XML-based resource references
        5. 14.2.5. Resource Environment and Administered Objects
        6. 14.2.6. Environment Entries
        7. 14.2.7. Message Destination References
          1. 14.2.7.1. XML-based resource references
          2. 14.2.7.2. Using @Resource
        8. 14.2.8. Web Service References
          1. 14.2.8.1. XML-based resource references
          2. 14.2.8.2. Using @javax.xml.ws.WebServiceRef
    15. 15. Interceptors
      1. 15.1. Intercepting Methods
        1. 15.1.1. Interceptor Class
        2. 15.1.2. Applying Interceptors
          1. 15.1.2.1. Annotated methods and classes
          2. 15.1.2.2. Applying interceptors through XML
          3. 15.1.2.3. Default interceptors
          4. 15.1.2.4. Disabling interceptors
      2. 15.2. Interceptors and Injection
        1. 15.2.1. XML Injection
      3. 15.3. Intercepting Life Cycle Events
        1. 15.3.1. Custom Injection Annotations
      4. 15.4. Exception Handling
        1. 15.4.1. Aborting a Method Invocation
        2. 15.4.2. Catch and Rethrow Exceptions
      5. 15.5. Interceptor Life Cycle
      6. 15.6. Bean Class @AroundInvoke Methods
      7. 15.7. Future Interceptor Improvements
        1. 15.7.1. Annotations with Behavior
        2. 15.7.2. Feedback Welcome
    16. 16. Transactions
      1. 16.1. ACID Transactions
        1. 16.1.1. Is the TravelAgent EJB Atomic?
        2. 16.1.2. Is the TravelAgent EJB Consistent?
        3. 16.1.3. Is the TravelAgent EJB Isolated?
        4. 16.1.4. Is the TravelAgent EJB Durable?
      2. 16.2. Declarative Transaction Management
        1. 16.2.1. Transaction Scope
        2. 16.2.2. Transaction Attributes
          1. 16.2.2.1. Using the @TransactionAttribute annotation
          2. 16.2.2.2. Setting a transaction attribute within XML
          3. 16.2.2.3. Transaction attributes defined
          4. 16.2.2.4. EJB 3.0 persistence and transaction attributes
          5. 16.2.2.5. Message-driven beans and transaction attributes
          6. 16.2.2.6. EJB endpoints and transaction attributes
        3. 16.2.3. Transaction Propagation
          1. 16.2.3.1. Transactions and persistence context propagation
      3. 16.3. Isolation and Database Locking
        1. 16.3.1. Dirty, Repeatable, and Phantom Reads
          1. 16.3.1.1. Dirty reads
          2. 16.3.1.2. Repeatable reads
          3. 16.3.1.3. Phantom reads
        2. 16.3.2. Database Locks
        3. 16.3.3. Transaction Isolation Levels
        4. 16.3.4. Balancing Performance Against Consistency
          1. 16.3.4.1. Controlling isolation levels
        5. 16.3.5. Optimistic Locking
        6. 16.3.6. Programmatic Locking
      4. 16.4. Nontransactional EJBs
      5. 16.5. Explicit Transaction Management
        1. 16.5.1. Transaction Propagation in Bean-Managed Transactions
          1. 16.5.1.1. Message-driven beans and bean-managed transactions
        2. 16.5.2. Heuristic Decisions
        3. 16.5.3. UserTransaction
        4. 16.5.4. Status
        5. 16.5.5. EJBContext Rollback Methods
      6. 16.6. Exceptions and Transactions
        1. 16.6.1. Application Exceptions Versus System Exceptions
          1. 16.6.1.1. System exceptions
          2. 16.6.1.2. Application exceptions
      7. 16.7. Transactional Stateful Session Beans
        1. 16.7.1. The Transactional Method-Ready State
          1. 16.7.1.1. Transitioning into the Transactional Method-Ready state
          2. 16.7.1.2. Life in the Transactional Method-Ready state
      8. 16.8. Conversational Persistence Contexts
    17. 17. Security
      1. 17.1. Authentication and Identity
      2. 17.2. Authorization
        1. 17.2.1. Assigning Method Permissions
        2. 17.2.2. Identifying Specific Methods in XML
          1. 17.2.2.1. Wildcard declarations
          2. 17.2.2.2. Named method declarations
          3. 17.2.2.3. Specific method declarations
          4. 17.2.2.4. Remote/home/local differentiation
        3. 17.2.3. Excluded Methods
      3. 17.3. The RunAs Security Identity
      4. 17.4. Programmatic Security
    18. 18. EJB 3.0: Web Services Standards
      1. 18.1. Web Services Overview
      2. 18.2. XML Schema and XML Namespaces
        1. 18.2.1. XML Schema
        2. 18.2.2. XML Namespaces
      3. 18.3. SOAP 1.1
        1. 18.3.1. Web Services Styles
        2. 18.3.2. Exchanging SOAP Messages with HTTP
        3. 18.3.3. Now You See It, Now You Don’t
      4. 18.4. WSDL 1.1
        1. 18.4.1. The <definitions> Element
        2. 18.4.2. The <portType> and <message> Elements
        3. 18.4.3. The <types> Element
        4. 18.4.4. The <binding> and <service> Elements
      5. 18.5. UDDI 2.0
      6. 18.6. From Standards to Implementation
    19. 19. EJB 3.0 and Web Services
      1. 19.1. Accessing Web Services with JAX-RPC
        1. 19.1.1. Generating JAX-RPC Artifacts from WSDL
        2. 19.1.2. Calling a Service from an EJB
        3. 19.1.3. The <service-ref> Deployment Element
        4. 19.1.4. The JAX-RPC Mapping File
      2. 19.2. Defining a Web Service with JAX-RPC
        1. 19.2.1. The WSDL Document
        2. 19.2.2. The Service Endpoint Interface
        3. 19.2.3. The Stateless Bean Class
        4. 19.2.4. The Deployment Files
          1. 19.2.4.1. The WSDL file
          2. 19.2.4.2. The JAX-RPC mapping file
          3. 19.2.4.3. The webservices.xml file
      3. 19.3. Using JAX-WS
        1. 19.3.1. The @WebService Annotation
        2. 19.3.2. The @WebMethod Annotation
        3. 19.3.3. The @SOAPBinding Annotation
        4. 19.3.4. The @WebParam Annotation
        5. 19.3.5. The @WebResult Annotation
        6. 19.3.6. The @OneWay Annotation
        7. 19.3.7. Separating the Web Services Contract
        8. 19.3.8. The Service Class
        9. 19.3.9. The Service Endpoint Interface
        10. 19.3.10. The @WebServiceRef Annotation
      4. 19.4. Other Annotations and APIs
    20. 20. Java EE
      1. 20.1. Servlets
      2. 20.2. JavaServer Pages
      3. 20.3. Web Components and EJB
      4. 20.4. Filling in the Gaps
        1. 20.4.1. Persistence Unit Scope
        2. 20.4.2. Java EE Application Client Components
        3. 20.4.3. Guaranteed Services
      5. 20.5. Fitting the Pieces Together
    21. 21. EJB Design in the Real World
      1. 21.1. Predesign: Containers and Databases
        1. 21.1.1. Container Capabilities
        2. 21.1.2. Database Capabilities
      2. 21.2. Design
        1. 21.2.1. Business Entity Identification
        2. 21.2.2. Technical Architecture
        3. 21.2.3. EJB and Entity Bean Identification
          1. 21.2.3.1. Identifying entity beans
          2. 21.2.3.2. Identifying session beans
          3. 21.2.3.3. Identifying message-driven beans
        4. 21.2.4. EJB Details
          1. 21.2.4.1. Stateless versus stateful session beans
          2. 21.2.4.2. Local versus remote interfaces
        5. 21.2.5. Entity Details
          1. 21.2.5.1. Returning entity data from EJBs
          2. 21.2.5.2. Minimizing database access
          3. 21.2.5.3. Caching
          4. 21.2.5.4. Combining queries
          5. 21.2.5.5. Minimizing updates
        6. 21.2.6. Fleshing Out the Design
          1. 21.2.6.1. Don’t confuse EJB types
          2. 21.2.6.2. Minimize transaction scope
        7. 21.2.7. Exceptions
          1. 21.2.7.1. Identifying business exceptions
          2. 21.2.7.2. Designing the exception hierarchy
          3. 21.2.7.3. Deciding on rollback exceptions
          4. 21.2.7.4. Checked versus unchecked exceptions
          5. 21.2.7.5. Wrap subsystem exceptions
        8. 21.2.8. Utility Classes
      3. 21.3. Should You Use EJBs?
        1. 21.3.1. When to Use EJBs
        2. 21.3.2. When Not to Use EJBs
        3. 21.3.3. Alternatives to EJBs
        4. 21.3.4. Alternatives to Java Persistence
          1. 21.3.4.1. JDBC
          2. 21.3.4.2. Others
      4. 21.4. Wrapping Up
  6. II. The JBoss Workbook
    1. 22. Introduction
      1. 22.1. Contents of the JBoss Workbook
        1. 22.1.1. Online Resources
    2. WORKBOOK 1. JBoss Installation and Configuration
      1. 23.1. About JBoss
      2. 23.2. Installing the JBoss Application Server
        1. 23.2.1. Discovering the JBoss Directory Structure
        2. 23.2.2. JBoss Configuration Files
        3. 23.2.3. Deployment in JBoss
      3. 23.3. A Quick Look at JBoss Internals
        1. 23.3.1. Microkernel Architecture
        2. 23.3.2. Hot Deployment
        3. 23.3.3. Net Boot
        4. 23.3.4. Detached Invokers
      4. 23.4. Exercise Code Setup and Configuration
        1. 23.4.1. Exercise Directory Structure
        2. 23.4.2. Environment Setup
    3. WORKBOOK 2. Exercises for Chapter 4
      1. 24.1. Exercise 4.1: Your First Beans with JBoss
        1. 24.1.1. Start Up JBoss
        2. 24.1.2. Initialize the Database
        3. 24.1.3. Build and Deploy the Example Programs
        4. 24.1.4. Deconstructing build.xml
        5. 24.1.5. JBoss Specifics
          1. 24.1.5.1. Remote JNDI binding
          2. 24.1.5.2. persistence.xml
        6. 24.1.6. Examine and Run the Client Applications
          1. 24.1.6.1. Client.java
        7. 24.1.7. Viewing the Database
      2. 24.2. Exercise 4.2: JNDI Binding with Annotations
        1. 24.2.1. Start Up JBoss
        2. 24.2.2. Initialize the Database
        3. 24.2.3. Build and Deploy the Example Programs
        4. 24.2.4. Using @RemoteBinding
          1. 24.2.4.1. TravelAgentBean.java
          2. 24.2.4.2. Client.java
        5. 24.2.5. Run the client
      3. 24.3. Exercise 4.3: JNDI Binding with XML
        1. 24.3.1. Start Up JBoss
        2. 24.3.2. Initialize the Database
        3. 24.3.3. Build and Deploy the Example Programs
        4. 24.3.4. The jboss.xml Deployment Descriptor
          1. 24.3.4.1. jboss.xml
          2. 24.3.4.2. Client.java
        5. 24.3.5. Run the Client
    4. WORKBOOK 3. Exercises for Chapter 5
      1. 25.1. Exercise 5.1: Interacting with EntityManager
        1. 25.1.1. Start Up JBoss
        2. 25.1.2. Initialize the Database
        3. 25.1.3. Build and Deploy the Example Programs
        4. 25.1.4. Using find( ) and merge( )
          1. 25.1.4.1. TravelAgentBean.java
          2. 25.1.4.2. Run the client
        5. 25.1.5. Transaction Versus Extended Persistence Contexts
          1. 25.1.5.1. TransactionPersistenceContextBean.java
          2. 25.1.5.2. Client_2.java
          3. 25.1.5.3. Run the client
        6. 25.1.6. FlushModeType Behavior
          1. 25.1.6.1. TravelAgentBean.java
          2. 25.1.6.2. Run the client
      2. 25.2. Exercise 5.2: Standalone Persistence
        1. 25.2.1. build.xml
        2. 25.2.2. Initialize the Database
        3. 25.2.3. Build the Example Program
        4. 25.2.4. Examine the JAR
          1. 25.2.4.1. persistence.xml
        5. 25.2.5. Examine the Standalone Application
    5. WORKBOOK 4. Exercises for Chapter 6
      1. 26.1. Exercise 6.1: Basic Property Mappings
        1. 26.1.1. Start Up JBoss
        2. 26.1.2. Initialize the Database
        3. 26.1.3. Build and Deploy the Example Programs
        4. 26.1.4. Examine the Customer Entity
          1. 26.1.4.1. Customer.java
        5. 26.1.5. Examine TravelAgentBean
          1. 26.1.5.1. TravelAgentBean.java
        6. 26.1.6. Examine the Client
        7. 26.1.7. Run the Client
      2. 26.2. Exercise 6.2: @IdClass
        1. 26.2.1. Start Up JBoss
        2. 26.2.2. Initialize the Database
        3. 26.2.3. Build and Deploy the Example Programs
        4. 26.2.4. Examine the Example Files
        5. 26.2.5. Run the Client
      3. 26.3. Exercise 6.3: @EmbeddedId
        1. 26.3.1. Start Up JBoss
        2. 26.3.2. Initialize the Database
        3. 26.3.3. Build and Deploy the Example Programs
        4. 26.3.4. Examine the Customer Entity
          1. 26.3.4.1. Customer.java
        5. 26.3.5. Examine Other Files
        6. 26.3.6. Run the Client
      4. 26.4. Exercise 6.4: Multitable Mappings
        1. 26.4.1. Start Up JBoss
        2. 26.4.2. Initialize the Database
        3. 26.4.3. Build and Deploy the Example Programs
        4. 26.4.4. Examine the Customer Entity
          1. 26.4.4.1. Customer.java
        5. 26.4.5. Examine Other Files
        6. 26.4.6. Run the Client
      5. 26.5. Exercise 6.5: Embeddable Classes
        1. 26.5.1. Start Up JBoss
        2. 26.5.2. Initialize the Database
        3. 26.5.3. Build and Deploy the Example Programs
        4. 26.5.4. Examine the Customer Entity
        5. 26.5.5. Examine Other Files
        6. 26.5.6. Run the Client
    6. WORKBOOK 5. Exercises for Chapter 7
      1. 27.1. Exercise 7.1: Cascading
        1. 27.1.1. Start Up JBoss
        2. 27.1.2. Initialize the Database
        3. 27.1.3. Build the Example Programs
        4. 27.1.4. Examine the Entities
        5. 27.1.5. Examine Client1
          1. 27.1.5.1. Client1.java
          2. 27.1.5.2. createCustomerAddress( )
          3. 27.1.5.3. cascadeMergeAddress( )
          4. 27.1.5.4. cascadeRemoveAddress( )
        6. 27.1.6. Run Client1
        7. 27.1.7. Examine Client2
          1. 27.1.7.1. Client2.java
        8. 27.1.8. Run Client2
      2. 27.2. Exercise 7.2: Inverse Relationships
        1. 27.2.1. Start Up JBoss
        2. 27.2.2. Initialize the Database
        3. 27.2.3. Build the Example Programs
        4. 27.2.4. Examine the Entities
        5. 27.2.5. Examine Client1
          1. 27.2.5.1. Client1.java
        6. 27.2.6. Run Client1
      3. 27.3. Exercise 7.3: Lazy Initialization
        1. 27.3.1. Start Up JBoss
        2. 27.3.2. Build and Deploy the Example Programs
        3. 27.3.3. Initialize the Database
        4. 27.3.4. Examine the DataAccess EJB
          1. 27.3.4.1. DataAccessBean.java
        5. 27.3.5. Examine the Client
          1. 27.3.5.1. Client.java
        6. 27.3.6. Run the Client
    7. WORKBOOK 6. Exercises for Chapter 8
      1. 28.1. Exercise 8.1: Single Table per Hierarchy
        1. 28.1.1. Start Up JBoss
        2. 28.1.2. Initialize the Database
        3. 28.1.3. Build and Deploy the Example Programs
        4. 28.1.4. Examine the Database Schema
        5. 28.1.5. Examine the Code
          1. 28.1.5.1. DataAccessBean.java
          2. 28.1.5.2. Client.java
        6. 28.1.6. Run the Client
      2. 28.2. Exercise 8.2: Single Table per Hierarchy
        1. 28.2.1. Start Up JBoss
        2. 28.2.2. Initialize the Database
        3. 28.2.3. Build and Deploy the Example Programs
        4. 28.2.4. Examine the Database Schema
        5. 28.2.5. Examine the Code
        6. 28.2.6. Run the Client
      3. 28.3. Exercise 8.3: JOINED Inheritance Strategy
        1. 28.3.1. Start Up JBoss
        2. 28.3.2. Initialize the Database
        3. 28.3.3. Build and Deploy the Example Programs
        4. 28.3.4. Examine the Database Schema
        5. 28.3.5. Examine the Code
        6. 28.3.6. Run the Client
    8. WORKBOOK 7. Exercises for Chapter 9
      1. 29.1. Exercise 9.1: Query and EJB QL Basics
        1. 29.1.1. Initialize the Database
        2. 29.1.2. Build the Example Programs
        3. 29.1.3. Example Basics
        4. 29.1.4. Parameters and Paging
          1. 29.1.4.1. Run the example
        5. 29.1.5. The SELECT Clause
          1. 29.1.5.1. columnResultSet( )
          2. 29.1.5.2. nestedRelationshipPropertyResultSet( )
          3. 29.1.5.3. constructorExpression( )
          4. 29.1.5.4. Run the example
        6. 29.1.6. The IN Operator and INNER JOIN
          1. 29.1.6.1. Run the example
        7. 29.1.7. LEFT JOIN
          1. 29.1.7.1. Run the example
        8. 29.1.8. Fetch Joins
          1. 29.1.8.1. noJoin( )
          2. 29.1.8.2. joinFetch( )
          3. 29.1.8.3. Run the example
        9. 29.1.9. Using DISTINCT
          1. 29.1.9.1. Run the example
        10. 29.1.10. The WHERE Clause and Literals
          1. 29.1.10.1. Run the example
        11. 29.1.11. The WHERE Clause and BETWEEN
          1. 29.1.11.1. Run the example
        12. 29.1.12. The WHERE Clause and IN
          1. 29.1.12.1. Run the example
        13. 29.1.13. The WHERE Clause and IS NULL
          1. 29.1.13.1. Run the example
        14. 29.1.14. The WHERE Clause and IS EMPTY
          1. 29.1.14.1. Run the example
        15. 29.1.15. The WHERE Clause and MEMBER OF
          1. 29.1.15.1. Run the example
        16. 29.1.16. The WHERE Clause and LIKE
          1. 29.1.16.1. Run the example
          2. 29.1.16.2. Run the example
        17. 29.1.17. Aggregate Functions
          1. 29.1.17.1. Run the example
        18. 29.1.18. The ORDER BY Clause
          1. 29.1.18.1. Run the example
        19. 29.1.19. GROUP BY and HAVING
          1. 29.1.19.1. Run the example
        20. 29.1.20. Subqueries
          1. 29.1.20.1. Run the example
        21. 29.1.21. Exercise 9.2: Native SQL Queries
        22. 29.1.22. Initialize the Database
        23. 29.1.23. Build the Example Program
        24. 29.1.24. Examine the Example
          1. 29.1.24.1. nativeSql( )
          2. 29.1.24.2. nativeWithMultipleEntities( )
          3. 29.1.24.3. mixedNative( )
        25. 29.1.25. Run the Example
    9. WORKBOOK 8. Exercises for Chapter 10
      1. 30.1. Exercise 10.1: Entity Callbacks
        1. 30.1.1. Start Up JBoss
        2. 30.1.2. Initialize the Database
        3. 30.1.3. Build and Deploy the Example Programs
        4. 30.1.4. Examine the Customer Entity
          1. 30.1.4.1. Customer.java
        5. 30.1.5. Examine TravelAgentBean
          1. 30.1.5.1. TravelAgentBean.java
        6. 30.1.6. Examine the Client
        7. 30.1.7. Run the Client
      2. 30.2. Exercise 10.2: Entity Listeners
        1. 30.2.1. Start Up JBoss
        2. 30.2.2. Initialize the Database
        3. 30.2.3. Build and Deploy the Example Programs
        4. 30.2.4. Examine the Entity Listener
        5. 30.2.5. Examine the JMX MBean
          1. 30.2.5.1. EntityStats.java
          2. 30.2.5.2. EntityStatsMBean.java
          3. 30.2.5.3. jboss-service.xml
        6. 30.2.6. Examine the Customer Entity
        7. 30.2.7. Run the Client
        8. 30.2.8. Examine the JMX Management Console
    10. WORKBOOK 9. Exercises for Chapter 11
      1. 31.1. Exercise 11.1: Stateless Session Bean
        1. 31.1.1. Start Up JBoss
        2. 31.1.2. Initialize the Database
        3. 31.1.3. Build and Deploy the Example Programs
        4. 31.1.4. Examine ProcessPaymentBean
        5. 31.1.5. Examine DataAccessBean
        6. 31.1.6. Examine the Client
        7. 31.1.7. Run the Client Application
      2. 31.2. Exercise 11.2: XML Override
        1. 31.2.1. Start Up JBoss
        2. 31.2.2. Initialize the Database
        3. 31.2.3. Build and Deploy the Example Programs
        4. 31.2.4. Examine ProcessPaymentBean
          1. 31.2.4.1. ejb-jar.xml
        5. 31.2.5. Examine the Client
        6. 31.2.6. Run the Client Application
      3. 31.3. Exercise 11.3: Annotationless Stateless Session Bean
        1. 31.3.1. Start Up JBoss
        2. 31.3.2. Initialize the Database
        3. 31.3.3. Build and Deploy the Example Programs
        4. 31.3.4. Run the Client
      4. 31.4. Exercise 11.4: Stateful Session Bean
        1. 31.4.1. Start Up JBoss
        2. 31.4.2. Initialize the Database
        3. 31.4.3. Build and Deploy the Example Programs
        4. 31.4.4. Examine ProcessPaymentBean and TravelAgentBean
        5. 31.4.5. Examine DataAccessBean
        6. 31.4.6. Examine the Client
        7. 31.4.7. Run the Application
      5. 31.5. Exercise 11.5: Annotationless Stateful Session Bean
        1. 31.5.1. Start Up JBoss
        2. 31.5.2. Initialize the Database
        3. 31.5.3. Build and Deploy the Example Programs
        4. 31.5.4. Run the Application
    11. WORKBOOK 10. Exercises for Chapter 12
      1. 32.1. Exercise 12.1: The Message-Driven Bean
        1. 32.1.1. Start Up JBoss
        2. 32.1.2. Initialize the Database
        3. 32.1.3. Create a New JMS Queue
          1. 32.1.3.1. Adding a JMS queue through a configuration file
          2. 32.1.3.2. jbossmq-titanqueues-service.xml
        4. 32.1.4. Build and Deploy the Example Programs
        5. 32.1.5. Examine ProcessPaymentBean and DataAccessBean
        6. 32.1.6. Examine the Client Applications
          1. 32.1.6.1. JmsClient_ReservationProducer.java
          2. 32.1.6.2. JmsClient_TicketConsumer.java
        7. 32.1.7. Examine ReservationProcessorBean
        8. 32.1.8. Run the Client Applications
    12. WORKBOOK 11. Exercises for Chapter 13
      1. 33.1. Exercise 13.1: EJB Timer Service
        1. 33.1.1. Start Up JBoss
          1. 33.1.1.1. Initialize the Database
          2. 33.1.1.2. Build and Deploy the Example Programs
          3. 33.1.1.3. Examine ShipMaintenanceBean
          4. 33.1.1.4. Examine the Client
          5. 33.1.1.5. Run the Application
    13. WORKBOOK 12. Exercises for Chapter 15
      1. 34.1. Exercise 15.1: EJB Interceptors
        1. 34.1.1. Start Up JBoss
          1. 34.1.1.1. Initialize the Database
          2. 34.1.1.2. Build and Deploy the Example Programs
          3. 34.1.1.3. Examine the Code
          4. 34.1.1.4. Run the Application
      2. 34.2. Exercise 15.2: Intercepting EJB Callbacks
        1. 34.2.1. Start Up JBoss
          1. 34.2.1.1. Initialize the Database
          2. 34.2.1.2. Build and Deploy the Example Programs
          3. 34.2.1.3. Examine the Code
          4. 34.2.1.4. Run the Client
    14. WORKBOOK 13. Exercises for Chapter 16
      1. 35.1. Exercise 16.1: Conversational Persistence Contexts
        1. 35.1.1. Start Up JBoss
        2. 35.1.2. Initialize the Database
        3. 35.1.3. Build and Deploy the Example Programs
        4. 35.1.4. Examine the Server Code
        5. 35.1.5. Examine the Client
        6. 35.1.6. Run the Application
    15. WORKBOOK 14. Exercises for Chapter 17
      1. 36.1. Exercise 17.1: Security
        1. 36.1.1. Configure JBoss Security
          1. 36.1.1.1. users-titan.properties
          2. 36.1.1.2. roles-titan.properties
        2. 36.1.2. Start Up JBoss
        3. 36.1.3. Initialize the Database
        4. 36.1.4. Build and Deploy the Example Programs
        5. 36.1.5. Examine the ProcessPaymentBean Class
        6. 36.1.6. Examine the Client
        7. 36.1.7. Run the Application
      2. 36.2. Exercise 17.2: Securing Through XML
        1. 36.2.1. Configure JBoss Security
        2. 36.2.2. Start Up JBoss
        3. 36.2.3. Initialize the Database
        4. 36.2.4. Build and Deploy the Example Programs
        5. 36.2.5. Examine the JBoss Configuration Files
        6. 36.2.6. Run the Application
    16. WORKBOOK 15. Exercises for Chapter 19
      1. 37.1. Exercise 19.1: Exposing a Stateless Bean
        1. 37.1.1. Start Up JBoss
        2. 37.1.2. Initialize the Database
        3. 37.1.3. Build and Deploy the Example Programs
        4. 37.1.4. Examining TravelAgentBean
        5. 37.1.5. Examining the Generated WSDL
        6. 37.1.6. Examining the Client
        7. 37.1.7. The Java EE Application Client Deployment Descriptor
        8. 37.1.8. The JBoss Application Client Deployment Descriptor
        9. 37.1.9. Examining the Service Endpoint Interface
        10. 37.1.10. Examining the JAX-RPC Mapping File
        11. 37.1.11. Running the Client
        12. 37.1.12. Viewing the Database
      2. 37.2. Exercise 19.2: Using a .NET Client
        1. 37.2.1. Installing the Necessary Software
          1. 37.2.1.1. Windows
          2. 37.2.1.2. Unix
        2. 37.2.2. Start Up JBoss
        3. 37.2.3. Initialize the Database
        4. 37.2.4. Build and Deploy the Titan JAR
        5. 37.2.5. Examine the Client
        6. 37.2.6. Compile the Client
          1. 37.2.6.1. Windows
          2. 37.2.6.2. Unix
        7. 37.2.7. Run the Client
  7. III. Appendix
    1. A. JBoss Database Configuration
      1. A.1. Set Up the Database
        1. A.1.1. Basic Setup
        2. A.1.2. titandb-ds.xml
      2. A.2. Examine the persistence.xml File
        1. A.2.1. persistence.xml
      3. A.3. Start Up JBoss
      4. A.4. Build and Deploy the Example Programs
      5. A.5. Examine and Run the Client Applications
  8. About the Authors
  9. Colophon
  10. Copyright

Product information

  • Title: Enterprise JavaBeans 3.0, 5th Edition
  • Author(s): Richard Monson-Haefel, Bill Burke
  • Release date: May 2006
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596009786