Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc

Responsibilities of the Enterprise Bean ProviderEnterprise JavaBeans 2.0, Public Draft

Entity Bean Component Contract for Bean

11.2.8 Entity bean’s remote interface

The following are the requirements for the entity bean’s remote interface:

The interface must extend the javax.ejb.EJBObject interface.

The methods defined in the remote interface must follow the rules for RMI-IIOP. This means that their argument and return value types must be valid types for RMI-IIOP, and their throws clauses must include the java.rmi.RemoteException.

The remote interface is allowed to have superinterfaces. Use of interface inheritance is subject to the RMI-IIOP rules for the definition of remote interfaces.

For each method defined in the remote interface, there must be a matching method in the entity bean’s class. The matching method must have:

The same name.

The same number and types of its arguments, and the same return type.

All the exceptions defined in the throws clause of the matching method of the enterprise Bean class must be defined in the throws clause of the method of the remote interface.

11.2.9 Entity bean’s home interface

The following are the requirements for the entity bean’s home interface:

The interface must extend the javax.ejb.EJBHome interface.

The methods defined in this interface must follow the rules for RMI-IIOP. This means that their argument and return types must be of valid types for RMI-IIOP, and that their throws clauses must include the java.rmi.RemoteException.

The home interface is allowed to have superinterfaces. Use of interface inheritance is subject to the RMI-IIOP rules for the definition of remote interfaces.

Each method defined in the home interface must be one of the following:

A create method.

A finder method.

A home method.

Each create method must be the named “ create<METHOD>”, and it must match one of the ejbCreate<METHOD> methods defined in the enterprise Bean class. The matching ejbCreate<METHOD> method must have the same number and types of its arguments. (Note that the return type is different.)

243

5/31/00

Sun Microsystems Inc.

Entity Bean Component Contract for Bean Managed PersistenceEnterprise JavaBeans 2.0, Public Draft Responsibilities of the Enter-

The return type for a create<METHOD> method must be the entity bean’s remote interface type.

All the exceptions defined in the throws clause of the matching ejbCreate<METHOD> and ejbPostCreate<METHOD> methods of the enterprise Bean class must be included in the throws clause of the matching create method of the home interface (i.e the set of exceptions defined for the create<METHOD> method must be a superset of the union of exceptions defined for the ejbCreate<METHOD> and ejbPostCreate<METHOD> methods)

The throws clause of a create<METHOD> method must include the javax.ejb.CreateException.

Each finder method must be named “ find<METHOD>” (e.g. findLargeAccounts), and it must match one of the ejbFind<METHOD> methods defined in the entity bean class (e.g. ejbFindLargeAccounts). The matching ejbFind<METHOD> method must have the same number and types of arguments. (Note that the return type may be different.)

The return type for a find<METHOD> method must be the entity bean’s remote interface type (for a single-object finder), or a collection thereof (for a multi-object finder).

The home interface must always include the findByPrimaryKey method, which is always a sin- gle-object finder. The method must declare the primary key class as the method argument.

All the exceptions defined in the throws clause of an ejbFind method of the entity bean class must be included in the throws clause of the matching find method of the home interface.

The throws clause of a finder method must include the javax.ejb.FinderException.

Home methods can have arbitrary names, provided that they don’t clash with create, find and remove method names. Their argument and return types must be of valid types for RMI-IIOP, and that their throws clauses must include the java.rmi.RemoteException. The matching ejbHome method specified in the entity bean class must have the same number and types of arguments and must return the same type as specified in the home interface of the bean.

11.2.10 Entity bean’s primary key class

The Bean Provider must specify a primary key class in the deployment descriptor.

The primary key type must be a legal Value Type in RMI-IIOP.

The class must provide suitable implementation of the hashCode() and equals(Object other) methods to simplify the management of the primary keys by client code.

5/31/00

244