Enterprise JavaBeans Flashcards
What is an Enterprise JavaBean (EJB)?
An Enterprise JavaBean is a component written in Java.
(3 answers)
What are the types of component in v3 of Enterprise JavaBeans (EJB)?
- Session beans
- Message-driven beans
- Entity classes
(4 answers)
What are session beans?
- Part of the javax.ejb package
- Provide business logic
- Run inside an EJB container (a runtime environment)
- Client communicates with the data via the session bean
(2 answers)
What are the types of session bean?
- Stateful session beans
- Stateless session beans
What are stateful session beans?
Stateful session beans keep state across multiple method calls.
They are either ready, non-existent or passive (passive when written to disk, goes back to ready when read from disk).
(e.g. shopping cart)
What are stateless session beans?
Stateless session beans discard the state after each method call.
They are either ready or non-existent.
(e.g. a database query)
(4 answers)
What are entity classes?
- Part of the javax.persistence package
- Provide business data
- Capture the persistent business entities stored in a database
- Correspond to a table in a database
What are entities?
Entities are instances of an entity class.
What are entity managers?
Entity managers are used to manage entities and are part of the javax.persistence package.
(2 answers)
What are the types of entity manager?
- Application-managed
- Explicitly created and closed by the application
- Container-managed
- Implicitly created and closed by the EJB container
What are transfer objects?
Transfer objects represent the client’s view of data and are suitable for data transfer between session beans and clients.
They contain all necessary information in their instance variables.
What are the differences between entities and transfer objects?
Entities:
- Reflect the way data is organised in the database
- Suitable for data transfer between the database and session beans
- May contain confidential information that should not be accessible to clients
Transfer objects:
- Represent the client’s view of data
- Suitable for data transfer between session beans and clients
- Only include information that is relevant to clients
- Can aggregate information stored across different entities, to match the way a client views information