EJB Logical Architecture
|
EJB Logical Architecture |
|
· A EJB system is logically a three-tier system · The three tiers are as follows: a) The Client b) The EJB Server c) The Database (or other persistent store) · This is a logical architecture because these tiers don’t necessarily have to reside on three different machines. · For example, a) The EJB server and the database might reside on the same machine, when the EJB server includes built-in functionalities for persistent storage. b) The client and the EJB server might reside on the same machine, when an EJB bean makes a call to another bean in the same container. The caller bean is acting as a client here. c) These two cases can be combined to have all the tiers in a single machine. · EJB’s role in each of these tiers are: a) A program on the client side makes call to remote EJBs. The client needs to know how to find the EJB server and how to interact with the objects that reside on the EJB server. b) The EJB components live in the middle tier. The EJB objects reside inside an EJB container, which in turn resides in an EJB server. c) EJB can access the database themselves, typically via Java Database connecting (JDBC), or they can allow the container to handle their data storage needs for them.
|
EJB’s Role
|
EJB’s Role |
|
1. EJB Specifies an execution environment · The container is responsible for providing services to EJB. · An EJB is a Java class that implements either the Session Bean or the Entity Bean Interface. · The container provides services such as support for transactions, support for persistence, and management of multiple instances of a given bean. · The container does not allow the bean to be accessed directly from the client; rather, the container provides a proxy object for each bean. · This approach gives the container a high degree of freedom in managing the beans and insulates the bean themselves from the outside world. |
|
2. EJB exists in the middle-tier · EJB, like other middle-tier components are used to encapsulate business rules. · A typical EJB consists of methods that encapsulate business logic. · A remote client can invoke these methods, which typically result in the updating of a database. |
|
3. EJB supports transaction processing · An EJB container must support transactions · When the bean is deployed, the container reads this information and provides necessary support. · Possible types of transaction support: i. Requiring that the client provide an open transaction context. ii. Requiring that the container start a new transaction when the bean is invoked. iii. Requiring that the bean be allowed to manage its own transaction. |
|
4. EJB can maintain state · CGI scripts are handy because they work against a well-defined interface. · A CGI application has no built-in mechanism to store state information. · Each invocation of a CGI application is therefore a fresh start. · If the developer would like to build an application with several screens that handles complex input, CGI is not suitable. · EJB can maintain state across several method invocations. · The EJB container keeps track of any state information that a bean needs. · Stateless bean can also be created.
|
|
5. EJB can maintain state · CGI scripts are handy because they work against a well-defined interface. · A CGI application has no built-in mechanism to store state information. · Each invocation of a CGI application is therefore a fresh start. · If the developer would like to build an application with several screens that handles complex input, CGI is not suitable. · EJB can maintain state across several method invocations. · The EJB container keeps track of any state information that a bean needs. · Stateless bean can also be created. |
|
6. EJB is simple · The EJB container handles all the responsibilities and runs on the server environment. So, developer work load is much reduced. · Even the developer need not worry about the multithreaded code, because the container handles concurrent requests. · Because the bean is a middle-tier object, an EJB developer does not need to create any user interface logic. · The developer must write only the code necessary to implement the application’s business rules and manage its data. · EJB brings together several trends in computing: i. Transaction processing ii. Persistent storage of objects iii. Platform independence iv. Multithreaded architecture · EJB provides all of these features in a straight forward, portable, easy-to-use framework. · Because an EJB bean can run in any EJB container, the potential exists for a new market in business-logic middleware. · Write Once, Run Anywhere.
|
