`
leslin123
  • 浏览: 3241 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Reading Notes:Enterprise JavaBeans, 3.0 Chapter 2. Architectural Overview

阅读更多

Enterprise JavaBeans, 3.0 Chapter 2. Architectural Overview

 

 

Section 2.1.  The Entity Bean

A good rule of thumb is that entity beans model business concepts that can be expressed as nouns . For example, an entity bean might represent a customer, a piece of equipment, an item in inventory, or even a place. In other words, entity beans model real-world objects; these objects are usually persistent records in some kind of database.

 

 

A good way to understand the design of entity beans is to look at how you'd go about implementing one. To implement an entity bean, you need to define a bean class and decide what field you will use as the identifier (primary key) of that bean class:


Primary key

The primary key is something that provides a pointer into the database. It gives the entity bean class's identity both in memory as an object and in the database as a row in a table. The primary key can be a class or a primitive type.


Bean class

The entity bean class may contain business logic but is usually just the object representation of persistence storage . In general, only business logic like validation should be placed in the entity bean class. The bean class is a POJO that does not have to implement any interface or even be serializable. It must be tagged with the @javax.persistence.Entity annotation and have at least one field or getter method that is designated as the primary key of the entity bean class in the database. This is usually done with the @javax.persistence.Id annotation. Entities have other annotations available to define a full object-relational database mapping as well.

 

2.1.1. The Entity Bean Class

 

Entity beans are different from EJB session beans in that they are POJOs. They do not have a remote or local interface and can be accessed only as POJOs. Later on, we'll see how to interact with an entity bean using the EntityManager service, but for now, we'll just take a peek at how to implement this bean type.

 

 

 

2.1.2. XML Deployment Descriptors and JAR Files

 

Many feel that database mappings are configuration metadata that should be defined separate from the entity bean class. To facilitate this requirement, the Java Persistence specification allows you to define the bean to database mappings in an additional XML deployment descriptor called a mapping file. This XML mapping file can be used instead of bean class annotations.

 

Once you have defined your XML deployment descriptors and entity bean classes, you must package them all in a Java Archive (JAR) file. The JAR file is used as both a library at runtime and a holder for deployment information. Whether you are using persistence in an application server or within a standalone Java application, the persistence provider will examine the JAR file to determine how to deploy one or more persistence units into your environment.

 

2.2. The Enterprise Bean Component

 

Enterprise JavaBeans server-side components come in two fundamentally different types: session beans and message-driven beans . Session beans are server-side components that can be accessed using a variety of distributed object protocols. Message-driven beans process messages asynchronously from systems like the JMS, legacy systems, and web services. All EJB servers must at least support a JMS-based message-driven bean, but they may also support other types of message-driven beans.

 

Session beans are extensions of the client application that manage processes or tasks.

Similarly, message-driven beans coordinate tasks involving other session and entity beans. Message-driven beans and session beans differ primarily in how they are accessed . While a session bean provides a remote interface that defines which methods can be invoked, a message-driven bean subscribes to or listens for messages. It responds by processing the message and managing the actions that other beans take.

 

 

The relevant distinction for Enterprise JavaBeans and Java Persistence is that an entity bean has persistent state; session and message-driven beans model interactions but do not have a persistent state.

 

2.2.1. Classes and Interfaces

 

Remote interface

Local interface

Endpoint interface

Message interface

Bean class

 

The term taskflow was coined specifically for this book. It's derived from the term workflow , which is frequently used to describe the management of business processes that may span several days with lots of human intervention. In contrast to workflow, taskflow is used in this book to describe the interactions of beans within a single transaction that takes only a few seconds to execute.

 

Entity beans represent the behavior and data of a business object, and session beans model the taskflow. The client application uses the TravelAgent EJB to perform a task using other beans.


Clients of session beans interact with the beans through the remote and local interfaces implemented by EJB objects.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    Enterprise JavaBeans 3.0 5ed.

    Enterprise.JavaBeans.3.0.5th.Edition-OReilly.rar CHM VERSION! SMALL AND FAST. I HAVE TRIED DOWNLOAD THIS BOOK IN CSDN, BUT HAVE NOT FOUND A FULL VERSION(SOME CHINESE VERSION NOT COMPLETE) TO THOSE ...

    Enterprise JavaBeans 3.0

    由于提供的文件内容中并没有实际的关于"Enterprise JavaBeans 3.0"的具体知识点,而只是提到了一本书的标题、描述和标签,并且重复了大量访问网站的信息。为了满足您的要求,我将从标题和描述中提到的《Enterprise ...

    Mastering Enterprise Javabeans 3.0.pdf

    《精通企业JavaBeans 3.0》一书深入探讨了JavaBeans规范的最新版本,即3.0版,这是Java企业级开发中的一个重要里程碑。JavaBeans是Java平台的一部分,主要用于构建可重用的组件,这些组件可以被集成到各种应用程序中...

    Enterprise JavaBeans 3.0 Documentation

    Enterprise JavaBeans(EJB)是Java平台上用于构建可扩展、安全和事务处理的企业级应用程序的框架。EJB 3.0是该技术的一个重大更新,它引入了许多改进,旨在简化开发过程并提高开发者效率。本文档集合是EJB 3.0规范...

    Enterprise JavaBeans 3.0(第5版) chm

    本书主要介绍EJB3.0标准,是获奖权威参考书Enterprise JavaBeans的最新第5版。全书内容主要分为两大部分,第一部分是EJB 3.0的标准技术手册,主要介绍EJB概念、EJB工作原理及使用方法;第二部分是JBoss实践指南,...

    Enterprise JavaBeans 3.0中文版(第5版)

    ### Enterprise JavaBeans 3.0概述 #### 一、企业级应用开发背景 在现代企业级应用开发领域,Java技术一直扮演着至关重要的角色。随着业务需求的不断增长和技术的快速发展,开发人员需要构建出更加灵活、高效且可...

    Enterprise JavaBeans 3.0 中文版

    《企业JavaBeans 3.0 中文版》是Java企业级开发的重要参考资料,它详细介绍了EJB 3.0规范,这是一个里程碑式的版本,极大地简化了EJB的使用,提升了开发效率。本教程旨在帮助开发者深入理解和熟练运用EJB 3.0技术。 ...

    Reilly.Enterprise.JavaBeans.3.1.6th.Edition.2010

    《Reilly.Enterprise.JavaBeans.3.1.6th.Edition.2010》是针对JEE6(Java Enterprise Edition 6)平台的一本权威指南,特别关注于Enterprise JavaBeans(EJB)3.1版本。这本书由Oracle Corporation认证,为希望获得...

    Enterprise JavaBeans 3.0 中文版 (第5版) .pdf 下载.rar

    Enterprise JavaBeans(EJB)是Java平台上用于构建可扩展、分布式的、企业级应用程序的核心技术。EJB 3.0是这一技术的重要版本,引入了许多革新,极大地简化了开发过程,提高了开发效率。本篇文章将深入探讨EJB 3.0...

    Wiley.Mastering.Enterprise.JavaBeans.3.0.4th.Edition.Jul.2006

    《Mastering Enterprise JavaBeans 3.0》是Java EE领域的一本权威著作,专注于讲解Java企业版中的核心组件——Enterprise JavaBeans(EJB)3.0版本。这本书由Wiley出版社于2006年7月出版,是第四版,为开发者提供了...

    Mastering Enterprise JavaBeans™ 3.0

    ### 掌握企业级JavaBeans™ 3.0:核心知识点解析 #### 一、企业级JavaBeans(EJB)概述 **企业级JavaBeans (EJB)** 是一种基于Java平台的企业级应用开发模型,主要面向大型分布式系统。EJB 3.0是该技术的一个重要...

    Wiley.Mastering.Enterprise.JavaBeans.3.0.4th.Edition

    《精通企业JavaBeans 3.0 第4版》是一本深度探讨Java企业级开发的权威著作,主要聚焦于Java EE平台中的核心组件——Enterprise JavaBeans(EJB)。这本书旨在帮助开发者掌握EJB 3.0规范,从而在企业级应用开发中实现...

    EJB3.0规范文档.rar

    **企业级JavaBeans(Enterprise JavaBeans,EJB)3.0规范**是Java平台上用于构建分布式、组件化的企业级应用程序的重要框架。EJB3.0是EJB规范的一个重大革新,它极大地简化了开发过程,引入了许多现代软件工程的最佳...

    04.最新EJB 3.0实例教程.rar

    EJB(Enterprise JavaBeans)是Java EE平台中的核心组件,主要用于构建可扩展的、安全的、事务处理的企业级应用。EJB 3.0是其一个重要版本,发布于2006年,带来了许多重大的改进和简化,使得开发过程更为简洁,降低...

    ejb3.0实例教程.rar

    EJB(Enterprise JavaBeans)是Java企业级应用开发的核心组件之一,主要用于构建可复用的、分布式的、事务处理的服务器端应用程序。EJB 3.0是其一个重要的版本,发布于2006年,它在前几个版本的基础上进行了大量的...

    Manning.EJB.3.0.in.Action

    《EJB 3.0 in Action》是一本深入探讨企业级JavaBeans(EJB)3.0版本的专业书籍。EJB是Java平台上的核心组件,用于构建可扩展、可靠的、多用户的企业应用。这本书旨在帮助开发者理解并充分利用EJB 3.0的改进和简化,...

    EJB3.0实例教程.pdf

    **企业级JavaBeans(EJB)3.0详解** 企业级JavaBeans(EJB)是Java平台上用于构建可扩展、安全且事务处理能力强的企业级应用的核心技术。EJB 3.0是其的一个重要版本,引入了许多重大的改进,使得开发更加简单、直观...

    EJB3.0_Servlet.rar_ejb3.0 example

    EJB(Enterprise JavaBeans)是Java EE平台中的核心组件,用于构建可扩展、安全和事务处理的服务器端应用程序。EJB 3.0是EJB规范的一个重要版本,它极大地简化了EJB的开发,降低了对开发者的要求,使得Java EE应用...

Global site tag (gtag.js) - Google Analytics