tailieunhanh - Design ejb design patterns phần 3

Hơn nữa, kể từ khi đậu thực thể là những sinh vật giao dịch, mỗi cuộc gọi phương thức trên một thực thể sẽ yêu cầu một giao dịch riêng biệt ở phía máy chủ, yêu cầu đồng bộ hóa của các thực thể từ xa với lưu trữ dữ liệu cơ bản của nó và duy trì thay mặt cho các máy chủ ứng dụng. | EJB Layer Architectural Patterns 35 public Map getAllAttributes return HashMap Used by clients to specify the attributes they are interested in @return @param keysofAttributes the name of the attributes the client is interested in public Map getAttributes Collection keysofAttributes Iterator keys Object aKey null HashMap aMap new HashMap while aKey aKey aKey map now has all requested data return aMap Used by clients to update particular attributes in the entity bean @param keyValuePairs public void setAttributes Map keyValuePairs Iterator entries .iterator anEntry null while anEntry In Container-Managed Persistence CMP using an internal map of attributes is not possible since the implementation of an entity bean s classes is abstracted behind container generated get and set methods. When using an internal map is not possible the attribute access interface can be implemented generically using the Java Reflection API. That is in setAttributes reflection can 36 Chapter One be performed on the key-value of the attribute a client wants to set. Specifically if the key-value is XXX the setAttribute implementation will attempt to call setXXX . on the entity bean. Similarly in the getAttributes method reflection can be used to find all get methods on an entity bean invoke them and populate a map for the client. If a developer would prefer not to use the Reflection API then implementing the Attribute Access method cannot be done generically for CMP. The developer will need to interlace his Attribute Access implementation with IF statements that call hard-coded get set methods on the entity bean depending on the key-value string. In order to make the Attribute Access implementation code reusable across all entity beans a superclass .

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.