EJB trail

Enterprise Beans
1.the EJB container provides system-level services such as transactions and security to its enterprise beans

What Is an Enterprise Bean?
an enterprise bean is a server-side component that encapsulates the business logic of an application

Benifit of EJB:

enterprise beans simplify the development of large, distributed applications :
the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems.
EJB container--and not the bean developer--is responsible for system-level services such as transaction management and security authorization.
because the beans--and not the clients--contain the application's business logic, the client developer can focus on the presentation of the client.
 enterprise beans are portable components, the application assembler can build new applications from existing beans. These applications can run
 on any compliant Java EE server provided that they use the standard APIs.


When to Use Enterprise Beans

1 ,The application must be scalable ,which means you must distribute the system in different geographical locations or other situations.
2.Transactions must ensure data integrity. Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects
3.The application will have a variety of clients. With only a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.


EJB types:

Session bean :  excutes a task for a client , optionally web service

Message-Driven Bean : acts as a listener , to listen the message such as JMS API

Entity Bean is replaced by persistence API : 

----------------------------------------------------------------NOTE 2-----------------------------SESSION BEAN------------------------------------------------
What Is a Session Bean?

Session Bean represents a client ,  in my opinion ,  when a client visits an application on the server , it will invoke the session bean ,then the session bean will execute task for the client
and shield the client  away from the complicated operations ,

Session Bean should not be persistent , every session is associated with one client.

State Management Modes

Stateless Bean
stateful Bean  The state of an object consists of the values of its instance variables. In a stateful session bean, the instance variables represent the state of a unique client-bean session

A stateless session bean can implement a web service, but other types of enterprise beans cannot.

When to Use Session Beans
In general, you should use a session bean if the following circumstances hold:

At any given time, only one client has access to the bean instance.
The state of the bean is not persistent, existing only for a short period (perhaps a few hours).
The bean implements a web service.
Stateful session beans are appropriate if any of the following conditions are true:

The bean's state represents the interaction between the bean and a specific client.
The bean needs to hold information about the client across method invocations.
The bean mediates between the client and the other components of the application, presenting a simplified view to the client.
Behind the scenes, the bean manages the work flow of several enterprise beans. For an example, see the AccountControllerBean session bean in Chapter 37.
To improve performance, you might choose a stateless session bean if it has any of these traits:

The bean's state has no data for a specific client.
In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an email that confirms an online order.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值