原因之二
a) ejb 提供了一个开发框架
b)容器管理
session Beand 受容器管理,具体怎么管理,看看ejb 方面的书籍吧

解决方案 »

  1.   

    谢谢,既然有容器管理,是否只有ejb类,不需要一般的java类?例如javabean,在web端的jsp或者servlet中是否只有ejb类,不能有一般的java类(当然是和ejb有关的类,例如一个cmp ejb的wraper类)?
      

  2.   

    这是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.
      

  3.   

    谢谢两位的帮助,是否可以这样理解无状态会话bean完全可以被一般java类代替?
    结合自己的理解。是否可以这样组织结构。对于频繁使用的实体bean,写一个对应的wraper类,实体bean的调用尽量通过会话bean调用。以减少对数据库的频繁访问。通过wraper类也减少通过远程调用ejb的开销。
      

  4.   

    是EJB是用来进行分布式应用系统的开发,也就是如果一个应用系统可以分割成若干组件部署在若干台计算机上运行,你如果用普通的JAVABEAN是无法做到的,普通的应用系统只能部署在一台服务器上
    所以无状态SESSIONBEAN是不能被普通的JAVABEAN代替的
    一般来说实体BEAN的性能不好,所以一般用会话BEAN+JDBC做,让JDBC把查到的数据通过会话BEAN 返回