A brief analysis of the differences between beans and ejbs in Java

  • 2020-04-01 03:42:33
  • OfStack

Java beans are reusable components. There is no strict specification for Java beans. In theory, any Java class can be a Bean. But typically, because Java beans are created by a container (such as Tomcat), Java beans should have a no-argument constructor, and generally Java beans implement the Serializable interface to implement the persistence of beans. Java beans are effectively equivalent to the local in-process COM component in the Microsoft COM model and cannot be accessed across processes. Enterprise Java beans are the equivalent of DCOM, or distributed components. It is based on Java's remote method invocation (RMI) technology, so ejbs can be accessed remotely (across processes, across computers). But ejbs must be deployed in containers such as Webspere and WebLogic, and EJB clients never access real EJB components directly, but through their containers. The EJB container is a proxy for EJB components, which are created and managed by the container. The client accesses the actual EJB components through the container.


Related articles: