Tuesday, May 12, 2009

EJB 3 In Action, Chapter #1

EJB3 is nothing more than POJO with some special features
EJB Container -- Container Services,
Persistance Provider -- Persistance Services, manages entities

3 types of EJBs
Session Beans -- Business Logic, live in and managed by container
Message-Driven Beans -- Business Logic, live in managed by container
Entities -- Persistance, managed by entitymanger/persistance provider

Metadata Annotations through Java 5 are used to preconfigure the EJBs by specifying the types of services like Transactions, Security, Persistance, remotability, Interceptors, Timers, State Management, Messaging etc .. to add when container deploys the EJBs. This is declarative style of programming in which developer specifies what should be done, the system adds the code to do it. No need to depend on External XML config file

Layered Architectures
Four-tier layered architecture --> Presentation layer, business logic layer, persistance layer, database layer. (Its not perfect)
Domain-Driven Design --> you can use JPA entities as model domain objects including modelling state and behaviour.

session beans
stateful bean -- automatically saves bean's state between client invocations without having/writing additional code. Invoked locally, remotely using java RMI
stateless bean -- doesnt saves to state, Invoked locally, remotely using java RMI, can be exposed as web service.

Message-Driven Bean -- No client invocations, asynchronous process of messages comes from messaging servers like IBM MQ, SonicMQ, Oracle Advanced Queueing, TIBCO..

Entities and JPA
JPA defines standards for
1)The creation of ORM configuration metadata for mapping entities to relational tables
2)Entity Manger API for performing CRUD/Persistance operations for entities
3)Java Persistance Query Language(JPQL)

Entities -- java objects that are persisted into the database. Employee entity, user entity, item entity. It contains ORM metadata.
Entity Manager/JPA -- It reads ORM metadata for an entity and performs persistance operations. JPA handle lifecycle management, performance tuning, caching,transaction management.

JPQL -- to search, retrieve entities saved into database. supports native, database specific SQL.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home