积木首页 | 500多种网页特效 | 函数手册 | 广播电台 | 高清晰图片素材 | 服务器合租 | 万年历 | 网友最新浏览记录
程序开发 网页设计 搜索引擎 特效代码 操作系统 防范病毒 黑客技术 图形图象 电脑硬件 网络技术 服 务 器 数 据 库 网文精粹
您的位置:积木首页 >> 程序开发频道 >> J2EE >> 正文:
标题:wsad使用过程
时间:2002-9-26 来源:不详 浏览数:
     Developing EJB by WSAD
Prerequisite:
        1. WSAD 402
        2. DB2/UDB 7.2.1 or greater version
        3. Has DB2 sample database created

Part One:     Creat a new EJB Project

1.    Perspective -> Open -> Other -> J2EE Perspective. 
         

2.    File -> New -> EJB Project
    Project Name:        AccountAndTransferEJBModule
    EAR Project:        AccountAndTransferEAR
Next -> Next -> Finish
 
Verify: 
J2EE Perspective -> J2EE View
        EJB Modules ->             AccountAndTransferEJBModule
        Enterprise Applications ->     AccountAndTransferEAR
     

Part Two:     Creating a CMP entity bean
1.     Create a CMP 
    File -> New -> Enterprise Bean
        Bean Name:                Account
        EJB Project:            AccountAndTransferEJBModule
        Source folder:            ejbModule
        Default package:        com.ibm.wsad.spc
 
    -> Next
        Bean supertype:            <none>
        Bean class:                com.ibm.wsad.spc.AccountBean
        Home interface:            com.ibm.wsad.spc.AccountHome
        Remote interface:        com.ibm.wsad.spc.Account
        Key class:                com.ibm.wsad.spc.AccountKey
        CMP attributes:        
        1). accountId:            long        (key field)
                   
        2). type:            int        
         
         3). balance:        float
         
    -> Next
        import             javax.ejb.*
     
    -> Finish
    Verify:    
    J2EE Perspective-> J2EE View
    EJB Modules ->  AccountAndTransferEJBModule -> Account
     
2.     Create a custom exception
    File -> New -> Other -> Java -> Java Class.
 
 
            Folder:                /AccountAndTransferEJBModule/ejbModule
            Package:            com.ibm.wsad.spc
            Name:                InsufficientFundsException
            Superclass:            java.lang.Exception
            Check "Constructor from superclass"
 
    -> Finish
 

3.       Add two methods to AccountBean.java
 

    /* adds the specified amount to the account balance and returns
    * the new balance
    */
    public float add(float amount) {
        balance += amount;
        return balance;
    }
    /* subtracts the specified amount from the account balance and
    * returns the new balance
    */
    public float subtract(float amount) throws InsufficientFundsException {
        if (balance < amount) {
            throw new InsufficientFundsException("Insufficient funds");
        }
        balance -= amount;
        return balance;
    }

4.     Add these two methods to Remote Interface
    Double Click J2EE Perspective -> J2EE View -> EJB Modules ->  AccountAndTransferEJBModule -> Account -> AccountBean
     
    Outline view
     
            Right mouse click add(float)         ->         Promote to Remote Interface
            Right mouse click substract(float)    ->         Promote to Remote Interface

     
    Verify:
    J2EE Perspective -> J2EE View -> EJB Modules ->  AccountAndTransferEJBModule -> Account -> Account 
    
    /* adds the specified amount to the account balance and returns
    * the new balance
    */
    public float add(float amount) throws java.rmi.RemoteException;
    /* subtracts the specified amount from the account balance and
    * returns the new balance
    */
    public float subtract(float amount) throws InsufficientFundsException,     java.rmi.RemoteException;

     

5.     Create Top Down EJB/RDB Mapping
    J2EE Perspective -> Navigator View 
     
    Right-click AccountAndTransferEJBModule
    Generate -> EJB to RDB maping
     
    Select Top Down way to build EJB to RDB maping 
&

[1] [2] [3] 下一页


(责任编辑:笑虎)
关于本站 | 广告服务 | 联系我们 | 版权申明 | 强强联盟 | 投稿热线 | 网站地图 | 申请链接
Copyright ©2005-2006 Gimoo.net All rights reserved. 积木网 版权所有
E-mail:gimoohr@gmail.com 京ICP备05050695号