您的位置:首页 >> 编程开发 >> Java >> Java基础 >> Eclipse >> 正文
Eclipse RSS
 

TutorialforbuildingJ2EEApplicationsusingJBOSSandECLIPSE-7

http://www.rdxx.com 06年12月09日 04:26 互联网 我要投稿

关键词: Tutorial , san , J2EE , Eclipse , JB , ATI , UI , ONS , IP

  • Create an Immutable Value Object named DeliverItem under the package au.com.tusc.mdb. Add some attributes and implement their accessor and mutator methods. The attributes are:

    private String username

    private String passwd

    private String itemID

    private int quantity

  • Implement the onMessage method in your DeliverItems Bean.

    Add these two variables to store references.

    private StoreAccessHome storeAccess = null;private ItemLocalHome itemLocalHome = null;

    Extract the data from the message into your immutable value object as shown below.

    DelieverItem di =  (DeliverItem) ((ObjectMessage) message).getObject();

    Get the references for the StoreAccess and Item beans.

    StoreAccess access = StoreAccessUtil.getHome().create();itemLocalHome = ItemUtil.getLocalHome();

    Invoke the loginUser method for supplier to get the Supplier's userid(accessID) and then find the Supplier's ID by invoking the getSupplierData method.

    String suppAcessID = access.loginUser(di.getUsername(), di.getPasswd());SupplierData sd = access.getSupplierData(suppAccessID);String suppID = sd.getSupplierID();

    If suppID is not equal to null, then invoke the finder method on the Item bean to get the details of the item to be delivered, by extracting itemID from message.

    ItemLocal item = this.itemLocalHome.findByPrimaryKey(di.getItemID());

    Get the supplier ID associated with the item found, so we can fill up the stock.

    String itemSuppID = item.getSupplierID(); 

    Compare itemSuppID and ItemID, if these are the same then fill the stock for that item by invoking the fillStock method in Item bean.

    if ( suppID.equals(itemSuppID)) {    System.out.println ("Delivering items in store now... :");    Integer quantity = new Integer (di.getQuantity());    item.fillStock(quantity);    System.out.println ("Stock of iten after dleivery is :" + item.getItemData());}
  • Add the following tags for deployment at the class level for linking/referencing Supplier.

    1. 1. @ejb.ejb-ref    ejb-name="StoreAccess"    view-type="remote"    ref-name="StoreAccess"2. @ejb.ejb-ref    ejb-name="Item"    view-type="local"    ref-name="ItemLocal"3. @jboss.ejb-ref-jndi ref-name="ItemLocal"    jndi-name="ItemLocal"4. @jboss.ejb-ref-jndi ref-name="StoreAccess"    jndi-name="StoreAccessBean"  5. @jboss.destination-jndi-name     name="queue/DelMdbQueue" 
    1. Deploy your DeliverItems Bean.

    2. Create a test client named DeliverMDBClient under the package au.com.tusc.mdb.

    3. Add a method named testMDBBean with the following signature.

      public void testMDBBean

    4. Implement testMDBBean, for this a few steps have to be carried out.

      Add a Data Object which is to be sent as the message.

      Create Initial context.

      Create Connection factory.

      Using this context perform the JNDI lookup, where the lookup string is "queue/DelMdbQueue".

      Create QueueConnection.

      Create QueueSender.

      Create QueueSession for the bean.

      Create Object Message and pass the Data Object in the message.

      Send the message.

      Finally, commit the session and close both the session and the connection.

    共6页  第1页 第2页 第3页 第4页 第5页 第6页


     
     
    标签: Tutorial , san , J2EE , Eclipse , JB , ATI , UI , ONS , IP 打印本文
     
     
      热点搜索
     
     
     



    Valid XHTML 1.0 Transitional
    Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
    收藏本页
    收藏本站