Thursday, March 01, 2007

JAVA 認證心得 -- SCBCD (3)

Component Contract for Container-Managed Persistence (CMP)
##CONTINUE##

  • The <cmr-field-type> element is used for collection-valued container-managed relationship(CMR) fields only. It’s specifies the type of the collection that is used. Java.util.Collection and java.util.Set. It’s in <cmr-field>
  • The bean provider must not expose the following through the remote interface
    1. Container-managed collection classes, which are used for relationship
    2. Local interface types or local home interface types
    3. Get and set methods for CMR fields
    4. Persistent Collection classes used in container-managed relationships (ps. Accessor methods for the persistent fields is legal but not good!)
  • CMP and CMR fields are not defined in the bean class. These are virtual fields and their implementation is also the container’s responsibility.
  • Container-managed relationships are defined in terms of the local interfaces of the related beans.
  • Each entity-to-entity relationship is defined in a <ejb-relation> element within the <relationships> element
  • The CMP entity bean class must implement the EntityBean interface. It may, but is not required to implement the component interface. However, if the class does implement the component interface, the class must provide implementations of the methods defined by that interface.
  • The container-managed persistent and relationship fields must not be defined in the entity bean class. The container-managed persistent and relationship fields are defined in the abstract persistence schema (specified in the deployment descriptor) of the entity bean.
  • The accessor methods for container-managed persistent and relationship fields must be defined in the entity bean class. The abstract accessor methods defined in the entity bean class are implemented by the container.The container-managed relationship fields can't be initialized in the ejbCreate<METHOD> method but they can be initialized in the corresponding ejbPostCreate<METHOD> method. The ejbPostCreate<METHOD> is responsible for initializing the container-managed relationship fields.

Read more!

No comments: