I'm just getting to grips with Java EE. I know that adding @Stateful
or @Stateless
annotations to a class will make it an EJB bean. But what is actually happening in the background once I do that? I see the following listed on Wikipedia in relation to EJBs.
Use @Stateless annotation to signify it a stateless bean. EJB Container automatically creates the relevant configurations or interfaces required by reading this annotation during deployment.
In EJB 3.0, annotations are used to describe configuration meta-data in EJB classes. By this way, EJB 3.0 eliminates the need to describe configuration data in configuration XML files. EJB container uses compiler tool to generate required artifacts like interfaces, deployment descriptors by reading those annotations.
An instance of a stateful session bean has a unique identity that is assigned by the container at create time. Stateless: A stateless session bean does not maintain conversational state. Instances of a stateless session bean have no conversational state.
See this answer for some insight on both questions.
The highlights to focus on in that answer are that:
Note, one thing I did miss in that answer was the entire @MessageDriven
concept.
It's very interesting you put JMS / Connector on the same line as that is exactly how they are implemented. Message-Driven Beans (MDBs) should actually be called "Connector-Driven Beans" as all communication and lifecycle of an MDB is actually tied to the Connector Architecture specification and has nothing to do with JMS directly -- JMS is just the only Connector people ever see. There's a great deal of potential there. Hopefully we'll see some improvements in Java EE 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With