Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
101 views
in Technique[技术] by (71.8m points)

java - Why should we use EJB?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The EJB or Enterprise Java Beans are plain java classes (since version 3.0) with annotations that enable to you write the business logic of your applications and later deploy it (or install) on a Java Enterprise Edition Server.

You must consider use EJB if you wish to take advantage of the following services provided by the Java Enterprise Edition (Java EE) server:

  • Clustering. You can deploy your EJB on a cluster environment (dependent of Java EE Application Server), this provides to you Fault Tolerance and High Availability.
  • Concurrency without use Threads. All EJBs are instantiated through a pool of objects then your application gains on performance and without Thread complexity.
  • Transactionality through JTA. All EJBs can benefit from Transactionality management for different resources, the most important Databases, using annotations is easy to delimit the frontier of every transaction and manage them.
  • Connection Pool to Database. All ejb can access to connection pools defined into the Java EE Application Server, this connection pools provide an abstraction of the database complexity, by example you can use a XA Datasource that enables to you do Two Phased Commit to different databases.
  • Security. All ejb can use JAAS for secure the applications. JAAS is configured into the Java EE Application Server and lets you to Authenticate and Authorize the methods of your EJB through different providers just with configuration (By example using Active Directory, LDAP or Database).
  • Schedule service. All ejb can use the Timer Service that enables to you implement task for further execution or inclusive for repetitive execution.

There is other services and benefits but I think that these are the most importants. If you don't need these benefits my recommendation is that you don't use EJB (not all applications are Enterprise Applications).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...