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

2010-08-01  来源:本站原创  分类:Java  人气:137 

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 [email protected] 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.

相关文章
  • Reading Notes: Enterprise JavaBeans, 3.0 Chapter 2. Architectural Overview 2010-08-01

    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

  • Reading Notes: Enterprise JavaBeans, 3.0 Chapter 1. Introduction 2010-07-31

    Reading Notes: Enterprise JavaBeans, 3.0 Chapter 1. Introduction 1.1. Server-Side Components In business systems, object-oriented languages are used to improve development of GUIs, to simplify access to data, and to encapsulate the business logic. A

  • javascript DOM programming arts reading notes 2010-09-06

    javascript DOM programming arts reading notes The first part of the directory Chapter 1 Origin of JavaScript 1.1 JavaScript 1.2 A Brief History of the browser war 1.3 standard 1.4 Summary Chapter 2, JavaScript 2.2 Grammar 2.1 Grammar 2.3 statement pr

  • Reading notes on the code refactoring (1) 2010-04-16

    AgileJava reading notes (1) AgileJava is a test-driven development based on the method to help you learn how to polish your Java code, and thus obtain a stable object-oriented design and high-maintainable, high-quality systems. The book with a studen

  • Reading Notes: Your First Cup: An Introduction to the Java EE Platform 2010-07-10

    Reading Notes: Your First Cup: An Introduction to the Java EE Platform 1. Differences Among Three platforms Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language that has

  • JUnit In Action Reading Notes (1) 2008-03-29

    JUnit In Action Reading Notes (1) Part1 JUnit distilled chapter1 will teach you what the JUnit framework is and what problems it solves. chapter2 will take you on a discovery tour of the core JUnit classes and how to best use them. chapter3, you'll p

  • Reading notes (1) array 2010-05-04

    Reading notes 1. In c + +, there are two ways the array statements: one is to use the built-in array; Another is to use Vector. Vector is much easier to use and more secure than the basic element array, and should therefore be preferred to use Vector

  • RedHat Enterprise Linux 5.0 install Oracle10g 2010-08-07

    [Change] http://linuxsafe.blog.51cto.com/438124/205560 1, server system RedHat Enterprise Linux 5.0 Second, the database software Oracle10g (10.2.0) Third, the basic needs of the hardware (command to see the demand as shown) Memory / 512M Swap / 1G t

  • Core Python Programming 3 reading notes 2010-10-15

    In fact, this study notes that the book in Chapter 4 of the learning process. Chapter 4 introduces the knowledge of python objects, some priorities include a built-in data types, built-in types, standard functions, built-in type operator and so on. A

  • Reading Notes explain design pattern mode (Interpreter pattern) 2010-10-28

    Interpreter Pattern: Given a language, define a representation of its grammar, and define an interpreter, the interpreter uses the representation to interpret sentences in the language. By the definition, does not explain the mode is a commonly used

  • Groovy study notes of the Quick Start chapter 2010-12-26

    Groovy study notes of the Quick Start chapter About Groovy What is Groovy? Simply put, Groovy is the next generation Java, and Java, running on the JVM. Groovy, Java and the JVM relationship is like C #, VB.NET, like the relationship with the CLR. De

  • Oracle +9 i & 10g art of programming: in-depth database architecture, reading notes / summary 2010-12-27

    Abstract: Successful development of Chapter 1 of Oracle Applications Bitmap index is only applicable to low base (low-cardinality) value, but the frequently updated list does not apply. (So-called low cardinality column refers to this column can be o

  • JBoss EJB 3.0 Chapter II: References and injected 2009-10-09

    JBoss EJB 3.0 Chapter II: References and injected JBoss EJB3.0 RC6-PFD http://www.jboss.org/jbossejb3/docs/reference/build/reference/en/html/index.html 2 references and the injection 2.2 EJB reference * @ EJB's mappedName () manufacturers custom, JBo

  • How to use APT to maintain Red Hat Enterprise Linux 4.0 (RHEL) 2010-04-30

    Using APT to maintain Red Hat Enterprise Linux 4.0 (RHEL) Introduction of how to use APT (Advanced Packaging Tool) to maintain Red Hat Enterprise Linux (RHEL), to provide individual users can not upgrade RHEL solution to the problem. Keywords: APT, L

  • <Software Architecture Design> reading notes notes 2010-05-07

    "Software Architecture Design" reading notes http://uptodate.javaeye.com/blog/346676 Domain model lack of knowledge, not in-depth understanding of Robustness analysis?

  • Reading Notes: Tutorial for building J2EE Applications using JBOSS and ECLIPSE 2010-07-11

    Tutorial for building J2EE Applications using JBOSS and ECLIPSE Chapter2: The Java 2 Enterprise Edition (J2EE) is a multitiered architecture for implementing enterprise-class applications and web based applications. Application clients and applets ar

  • Reading Notes: Based on fuzzy c-means algorithm for data classification and forecasting of space - Hu Caiping. Qin Xiaolin 2010-11-06

    Reading Notes: Based on fuzzy c-means algorithm for data classification and forecasting of space - Hucai Ping, Qin Xiaolin Background Introduction c-means c-means clustering method is the most common and most commonly used method, in the "Data Mining

  • asp.net(c#)Enterprise Library 3.0 下载 2013-12-20

    微软今天发布了Enterprise Library 3.0,又有新的东西可以研究了,在Enterprise Library 3.0中包含如下8个应用程序块: l Caching Application Block l Cryptography Application Block l Data Access Application Block l Exception Handling Application Block l Logging Application Block l Policy In

  • CSDN总编孟岩访谈:深入理解SOA和Enterprise Web 2.0 2014-07-03

    概要 对中国的企业来说,SOA是机会也是挑战,严格来说挑战大于机会,这更需要我们深入了解面向服务架构这一技术背后的本质.技术专家.CSDN总编孟岩在深入研究这一技术之后给出了自己的理解,并指出国内企业和国外企业在实施SOA时所面对的不同境况,在具体的实施过程中应该注意的问题和难点,这一技术趋势对开发人员和架构师所带来的挑战和机遇,以及SOA和Web 2.0包括Enterprise Web 2.0的关系等. 请问你是怎么理解SOA的? 我这个理解来说下来就是,有这么大概几个过程,也分成这么几个阶段

  • Lost connection to MySQL server at 'reading authorization packet', system error: 0 2015-01-29

    这篇文章主要介绍了Lost connection to MySQL server at 'reading authorization packet', system error: 0错误解决方法,需要的朋友可以参考下 1.进入Mysqld 如果已经设置Mysql/Bin环境变量,直接在CMD里输入命令,如果没有设置Mysql环境变量,去Mysql安装目录的Bin文件夹里运行 F:\AppServ\MySQL\bin\mysql.exe -u root -p 其中root是用户名,然后就可以进入M