为什么使用ejb

shengzi101 2004-06-23 12:08:32
ejb中的实体可以理解,用于处理数据库。对于会话ejb,特别是无状态会话ejb。到底有何作用。是否完全被一般的java类代替?
再者,开发ejb项目时,既有ejb类,又有一般的java类,如何组织?
请指教!
...全文
107 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphil 2004-06-24
  • 打赏
  • 举报
回复
是EJB是用来进行分布式应用系统的开发,也就是如果一个应用系统可以分割成若干组件部署在若干台计算机上运行,你如果用普通的JAVABEAN是无法做到的,普通的应用系统只能部署在一台服务器上
所以无状态SESSIONBEAN是不能被普通的JAVABEAN代替的
一般来说实体BEAN的性能不好,所以一般用会话BEAN+JDBC做,让JDBC把查到的数据通过会话BEAN 返回
Javatomchen 2004-06-23
  • 打赏
  • 举报
回复
原因之二
a) ejb 提供了一个开发框架
b)容器管理
session Beand 受容器管理,具体怎么管理,看看ejb 方面的书籍吧
shengzi101 2004-06-23
  • 打赏
  • 举报
回复
谢谢两位的帮助,是否可以这样理解无状态会话bean完全可以被一般java类代替?
结合自己的理解。是否可以这样组织结构。对于频繁使用的实体bean,写一个对应的wraper类,实体bean的调用尽量通过会话bean调用。以减少对数据库的频繁访问。通过wraper类也减少通过远程调用ejb的开销。
Keanu_Rocky 2004-06-23
  • 打赏
  • 举报
回复
这是the specification of EJB上摘录的,也许对楼主有帮助:
The Enterprise JavaBeans (EJB) architecture has the following goals:
• The Enterprise JavaBeans architecture will be the standard component architecture for building distributed object-oriented business applications in the Java™ programming language.
• The Enterprise JavaBeans architecture will support the development, deployment, and use of web services.
• The Enterprise JavaBeans architecture will make it easy to write applications: Application developers will not have to understand low-level transaction and state management details,multi-threading, connection pooling, or other complex low-level APIs.
• Enterprise JavaBeans applications will follow the Write Once, Run Anywhere™ philosophy of the Java programming language. An enterprise bean can be developed once, and then deployed on multiple platforms without recompilation or source code modification.
• The Enterprise JavaBeans architecture will address the development, deployment, and runtime aspects of an enterprise application’s life cycle.
• The Enterprise JavaBeans architecture will define the contracts that enable tools from multiple vendors to develop and deploy components that can interoperate at runtime.
• The Enterprise JavaBeans architecture will make it possible to build applications by combining components developed using tools from different vendors.
• The Enterprise JavaBeans architecture will provide interoperability between enterprise beans and Java 2 Platform, Enterprise Edition (J2EE) components as well as non-Java programming language applications.
• The Enterprise JavaBeans architecture will be compatible with existing server platforms. Vendors will be able to extend their existing products to support Enterprise JavaBeans.
• The Enterprise JavaBeans architecture will be compatible with other Java programming language APIs.
• The Enterprise JavaBeans architecture will be compatible with the CORBA protocols.
shengzi101 2004-06-23
  • 打赏
  • 举报
回复
谢谢,既然有容器管理,是否只有ejb类,不需要一般的java类?例如javabean,在web端的jsp或者servlet中是否只有ejb类,不能有一般的java类(当然是和ejb有关的类,例如一个cmp ejb的wraper类)?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧