没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=273
MEAP Edition
Manning Early Access Program
Copyright 2006 Manning Publications
For more information on this and other Manning titles go to
www.manning.com
Licensed to John Sweitzer <admin@saolailaem.info>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=273
Contents
Chapter 1 - EJB 3.0 Overview
Chapter 2 - A First taste of EJB
Chapter 3 - Building Business Logic with Session beans
Chapter 4 - Messaging and Developing Message Driven Beans
Chapter 5 - Learning Advanced EJB Concepts
Chapter 6 - Transactions and Security
Chapter 7 - Implementing Domain Models with EJB 3.0
Chapter 8 - Object-Relationship Mapping using EJB 3 JPA
Chapter 9 - Manipulating entities with EntityManager API
Chapter 10 - Using the Query API and the Java Persistence
Query Language
Chapter 11 - Packaging EJB 3 Applications
Chapter 12 - Effectively Integrating EJB 3 across Your Application Tiers
Chapter 13 - Taming Wild EJBs
Chapter 14 - Migrating to EJB 3
Chapter 15 - Exposing EJBs as Web Services
Chapter 16 - EJB 3 and Spring
Licensed to John Sweitzer <admin@saolailaem.info>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=273
Chapter 1 What’s what in EJB 3.0
One day, when God was looking over his creatures, he noticed a boy named Sadhu whose humor
and cleverness pleased him. God felt generous that day and granted Sadhu three wishes. Sadhu asked
for three reincarnations--one as a ladybug, one as an elephant, and the last as a cow. Surprised by
these wishes, God asked Sadhu to explain himself. The boy replied, "I want to be a ladybug so that
everyone in the world will admire me for my beauty and forgive the fact that I do no work. Being an
elephant will be fun because I can gobble down enormous amounts of food without being ridiculed. I
will like being a cow the best because I will be loved by all and useful to mankind." God was charmed
by these answers and allowed Sadhu to live through the three incarnations. He then made Sadhu a
morning star for his service to mankind as a cow.
EJB too has lived through three incarnations. When it was first released, the industry was dazzled
by its innovations. But like the ladybug, EJB 1 had limited functionality. The second EJB
incarnation was just about as heavy as the largest of our beloved pachyderms. The brave souls who
could not do without its elephant-power had to tame the awesome complexity of EJB 2. And finally,
in its third incarnation, EJB has become much more useful to the huddled masses, just like the gentle
bovine that is sacred for Hindus and respected as a mother whose milk feeds us all..
A lot of people have put in a lot of hard work to make EJB 3 as simple and lightweight as
possible without sacrificing enterprise-ready power. EJB components are now little more than Plain
Old Java Objects (POJOs) that look a lot like code in a Hello World program. We hope you will
agree with us as you read through the next Chapters that it has all the makings of a star.
We’ve strived to keep this book as earthy as possible without skimping on content. The book is
designed to help you learn EJB 3.0 as quickly and as easily as possible. At the same time, we will not
neglect to cover the basics where needed. We will also dive into deep waters with you where we can,
share with you all the amazing sights we’ve discovered and warn you about any lurking dangers.
This book is about the radical transformation of a very important and uniquely influential
technology in the Java World. We suspect you are not picking this book up to learn too much about
EJB 2. You probably either already know EJB 2.x or are completely new to the world of EJB. In
either case, spending too much time on previous versions is a waste of your time --you won't be
surprised to learn that EJB 3.0 and EJB 2.x have very little in common. . If you are really curious
about the journey that brought us to the current point, we encourage you to pick up one of the many
good books on the previous versions of EJB.
Our goal in this Chapter is to tell you what’s what in EJB 3.0, why you should consider using it,
and, for EJB 2.x veterans, outline the significant improvements the newest version offers. We will
then jump right into code in the next Chapter to build on the momentum of this one. With this goal
in mind, we now start with a broad overview of EJB.
1.1 EJB Overview
In very straightforward terms, Enterprise Java Beans (EJB) is a platform for building portable,
reusable and scalable business applications using Java programming language. Since its initial
Licensed to John Sweitzer <admin@saolailaem.info>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=273
incarnation, EJB has been touted a component model or framework to build enterprise Java
applications without having to reinvent a lot of services such as transactions, security, automated,
persistence, and so on that you may need for building an application. EJB lets application developers
focus on building business logic without having to spend time on building infrastructure code.
From a developer’s point of view an EJB is a piece of Java code that executes in a specialized
runtime environment called the EJB container that provides a bunch of component services. The
persistence services are provided by a specialized framework called the persistence provider. We’ll talk
more about the EJB container, persistence provider and services in Section 1.3.
In this section, you will learn how EJB functions as both a component and a framework. We’ll
also examine how EJB lends itself to building layered applications. We’ll round off this section by
listing a few reasons why EJB might be right for you.
1.1.1 EJB as a Component
In this book, when we talk about EJBs, we are talking about the server-side components that you
can use to build parts of your application like the business logic or persistence code. A lot of us tend
to associate the term component with developing complex and heavyweight CORBA, Microsoft
COM+ code. In the brave new world of EJB 3.0, a component is really what it ought to be—nothing
more than a POJO with some special powers. More importantly, these powers stay invisible until
they are needed and don’t distract from the real purpose of the component. You will see this
firsthand throughout this book, especially starting with Chapter 2.
The real idea behind a component is that it should effectively encapsulate application behavior.
The users of a component are not required to know its inner workings. All they need to know is what
to pass in and what to expect back.
There are three types of EJB components: Session beans, Message Driven beans, and Entities.
Session beans and Message driven beans are used to implement business logic in an EJB application
and Entities are used for persistence.
Components can be reusable. For instance, suppose you were in charge of building a web site for
an online merchant that sells technology books. You implemented a module to charge the Credit
Card as part of a regular Java object. Your company did fairly well and you moved on to greener
pastures. The company then decided to diversify and began developing a web site for selling CDs and
DVDs. Since the deployment environment for the new site was different, it could not be located on
the same server as your module. The person building the new site was forced to duplicate your
Credit card module in the new website because there was no easy way to access your module. If you
had implemented the Credit Card charging module as an EJB component as depicted in Figure 1.1
(or as a web service) it would have been much easier for the new person to access it by simply making
a call to it when she needed that functionality. She could have reused it without having to understand
its implementation.
Licensed to John Sweitzer <admin@saolailaem.info>
剩余268页未读,继续阅读
资源评论
- yangyunqi20112011-10-11已经打印再看了,很不错,和原来EJB2.0比较着看,收获会很大
- chungsinwei2012-04-23The book is quite complete, well written, with good examples. It is a very valuable tool to enter the ejb3 world
tombow
- 粉丝: 9
- 资源: 27
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功