tailieunhanh - Teach Yourself J2EE in 21 Days phần 3

Hôm qua, bạn thấy làm thế nào để sử dụng JNDI để có được một tham chiếu đến một ngôi nhà đậu kỳ họp và làm thế nào để có được một hạt đậu kỳ họp bằng cách gọi phương pháp tạo ra thích hợp (). Bây giờ bạn có một sự hiểu biết đầy đủ của đậu phiên làm việc như thế nào, có một vài điểm khác có giá trị đánh giá cao. | Session EJBs 201 Client s View Yesterday you saw how to use JNDI to obtain a reference to a Session bean home and how to obtain a Session bean by calling the appropriate createO method. Now that you have a full understanding of how Session beans work there are a few other points that are worth appreciating. First if your client has a reference to a stateless Session bean although it should call remove when it is finished with the EJB this method call doesn t actually do particularly much. In particular it won t release any bean resources itself as shown clearly by the state chart diagrams in Figure . What this will do is allow the EJB container to remove the EJBObject proxy for the bean. Conversely calling create for a stateless Session bean doesn t necessarily cause ejbCreate to be called on the underlying bean although the client will have a reference to an EJBObject after making this call. One benefit of stateless beans over stateful is that they are more resilient. That is if the client invokes a method on a stateless bean and it throws an exception the client can still use their reference to try again. The client does not need to discard the reference and obtain a new one from the home interface. This is because behind the scene the EJB container will have discarded the bean that threw the exception but can simply select another bean from the pool to service the client s retry attempt. This is safe to do because the stateless Session beans have no state. Of course it is possible that the retry attempt might fail it would depend on the underlying cause of the exception. In contrast if a stateful Session bean throws an exception the client must obtain a new Session bean reference and start its conversation over again. This is because the EJB container will have discarded the Session bean that threw the exception discarding all the client s conversational state in the process. Sometimes a client may end up having two references to a Session bean. It may have .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.