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

Sun Microsystem Inc

Responsibilities of the Enterprise Bean ProviderEnterprise JavaBeans v1.1, Final Release

Entity Bean Component Contract

Compatibility Note: EJB 1.0 allowed the finder methods to throw the java.rmi.RemoteException to indicate a non-application exception. This practice is deprecated in EJB 1.1—an EJB 1.1 compliant enterprise bean should throw the javax.ejb.EJBException or another java.lang.RuntimeException to indicate non-application exceptions to the Container (see Section 12.2.2).

9.2.6 Business methods

The entity bean class may define zero or more business methods whose signatures must follow these rules:

The method names can be arbitrary, but they must not start with ‘ejb’ to avoid conflicts with the callback methods used by the EJB architecture.

The business method must be declared as public.

The method must not be declared as final or static.

The method argument and return value types must be legal types for RMI-IIOP.

The throws clause may define arbitrary application specific exceptions.

Compatibility Note: EJB 1.0 allowed the business methods to throw the java.rmi.RemoteException to indicate a non-application exception. This practice is deprecated in EJB 1.1—an EJB 1.1 compliant enterprise bean should throw the javax.ejb.EJBException or another java.lang.RuntimeException to indicate non-application exceptions to the Container (see Section 12.2.2).

9.2.7 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.

125

11/24/99

Sun Microsystems Inc.

Entity Bean Component Contract

Enterprise JavaBeans v1.1, Final Release Responsibilities of the Enterprise Bean Pro-

9.2.8 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 clause 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.

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

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

All the exceptions defined in the throws clause of the matching ejbCreate and ejbPostCreate 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 must be a superset of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)

The throws clause of a create 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.

11/24/99

126