我们为什么要使用EJB? [英] Why should we use EJB?

查看:99
本文介绍了我们为什么要使用EJB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是EJB,为什么要使用它?请用简单的语言解释。谢谢。

What is EJB, and why we should use it? Please explain in simple language. Thank you.

推荐答案

EJB或Enterprise Java Bean是普通的java clases(自3.0版本起),带有注释,可以让你写应用程序的bussines逻辑,然后在Java Enterprise Edition Server上部署(或安装)。

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

如果您希望利用以下服务,必须考虑使用EJB由Java Enterprise Edition(Java EE)服务器提供:

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


  • 群集。您可以在集群环境(依赖于Java EE Application Server)上部署EJB,这为您提供了Fault Tolerance和High Availability。

  • 并发而不使用Threads。所有ejb都通过一个对象池进行实例化,然后您的应用程序在性能上获得并且没有Thread复杂性。

  • 通过JTA进行事务处理。所有ejb都可以从不同资源的事务管理中受益,最重要的数据库,使用注释很容易划分每个事务的边界并进行管理。

  • 连接池到数据库。所有ejb都可以访问定义到Java EE Application Server中的连接池,这个连接池提供了数据库复杂性的抽象,例如,您可以使用XA数据源,使您可以对不同的数据库执行Two Faces Commit。

  • 安全性。所有ejb都可以使用JAAS来保护应用程序。 JAAS已配置到Java EE Application Server中,您可以通过配置(例如使用Active Directory,LDAP或数据库)通过不同的提供程序对EJB的方法进行身份验证和授权。

  • 安排服务。所有ejb都可以使用Timer Service来实现进一步执行任务或包含重复执行。

  • 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 ejb are instantiated through a pool of objects then your application gains on performance and without Thread complexity.
  • Transactionality through JTA. All ejb can benefit of 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 Faces 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.

还有其他服务和好处,但我认为这些是最重要的。如果您不需要这些好处,我的建议是您不使用EJB(并非所有应用程序都是企业应用程序)。

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).

这篇关于我们为什么要使用EJB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆