Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
J2EE发展背景: 中间件的演化 • Historically, mission-critical apps were built directly atop hardware • Tedious, error-prone, & costly over lifecycles • There are layers of middleware • Commonalities abstraction • Separation of concern
EJB的实现(举例)—创建远程接口 // business methods public interface Account extends EJBObject { //return the account information corresponding to this account. public AccountModel getDetails() throws RemoteException; // updates the contact information for the specified account public void changeContactInformation(ContactInformation info) throws RemoteException; }
EJB的实现—创建Home接口 public interface AccountHome extends javax.ejb.EJBHome { public Account create(String userId, String status, ContactInformation info) throws RemoteException,DuplicateKeyException,CreateException; public Account findByPrimaryKey (String userId) throws RemoteException, FinderException; }
EJB的实现—AccountBean的实现 public class AccountEJB implements EntityBean { // entity state private String userId; private String status; private ContactInformation info; // resources private EntityContext context; // implement account interface business methods public void changeContactInformation(ContactInformation info) { this.info = info; } public AccountModel getDetails() { return(new AccountModel(userId, status, info)); }
EJB的实现—AccountBean的实现 // must match signatures of create methods in Home interface public String ejbCreate (String userId, String status, ContactInformation info) throws DuplicateKeyException,CreateException { // set the instance data this.userId = userId; this.status = status; this.info = info; AccountDAO ADAO = new AccountDAO(userId, status,info); try{ ADAO.create(); // insert data in database return (userId); // return primary key }catch (java.sql.SQLException se) { throw new CreateException ("SQL Exception in create:" + se); } }