What is an EJB, and what does it do?

前端 未结 4 1914
夕颜
夕颜 2021-01-29 17:25

Been trying to learn what EJB beans are, what does it mean their instances are managed in a pool, blah blah. Really can\'t get a good grip of them.

Can you

4条回答
  •  一整个雨季
    2021-01-29 18:00

    An EJB is a Java component, containing business logic, that you deploy in a container, and that benefits from technical services provided by the container, usually in a declarative way, thanks to annotations:

    • transaction management: a transaction can be started automatically before a method of the EJB is invoked, and committed or rollbacked once this method returns. This transactional context is propagated to calls to other EJBs.
    • security management: a check can be made that the caller has the necessary roles to execute the method.
    • dependency injection: other EJBs, or resources like a JPA entity manager, a JDBC datasource, etc. can be injected into the EJB.
    • concurrency: the container makes sure that only one thread at a time invokes a method of your EJB instance.
    • distribution: some EJBs can be called remotely, from another JVM.
    • failover and load-balancing: remote clients of your EJBs can automatically have their call redirected to another server if necessary.
    • resource management: stateful beans can automatically be passivated to disk in order to limit the memory consumption of your server.
    • ... I probably have forgotten some points.

提交回复
热议问题