2 Replies Latest reply on Dec 13, 2005 12:35 PM by Chili Way

    Extending Teller WS example

    glindstrom Newbie

      I am seeking to extend the Teller WS example of Chapter 5 to support additional functionality, namely, transfer of funds between accounts, e.g. as provided by the TxController.transferFunds.

      I realize this will involve extending the ws ejb-jar.xml to include additional ejb-ref's.

      But I am baffled how the ejb-ref.xml as given works -- it includes

       <ejb-ref>
       <ejb-ref-name>ejb/account</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <home>com.sun.ebank.ejb.customer.CustomerHome</home>
       <remote>com.sun.ebank.ejb.customer.Customer</remote>
       </ejb-ref>
      

      which is used in TellerBean.getController() to instantiate an AccountControllerHome object
       AccountControllerHome home = (AccountControllerHome)
       ctx.lookup("java:comp/env/ejb/account");
      


      How can this be, given that the ejb-ref specifies a CustomerHome?

      Thanks,
      --Gary


        • 1. Re: Extending Teller WS example
          glindstrom Newbie

          I am still baffled by the issue I raised in my prior post, but I have been able to get TellerBean to support funds transfer through use of TxController.

          For the record, it's easy -- here are the steps:

          1) In dd/ws/ejb-jar.xml, in the element for TellerBean, add

           <ejb-ref>
           <ejb-ref-name>ejb/tx</ejb-ref-name>
           <ejb-ref-type>Session</ejb-ref-type>
           <home>com.sun.ebank.ejb.tx.TxControllerHome</home>
           <remote>com.sun.ebank.ejb.tx.TxController</remote>
           </ejb-ref>
          


          2) In dd/ws/jboss.xml, in the element for TellerBean, add
           <ejb-ref>
           <ejb-ref-name>ejb/tx</ejb-ref-name>
           <jndi-name>ebankTxController</jndi-name>
           </ejb-ref>
          


          3) Add to TellerEndpoint.java:
           public BigDecimal transfer(String fromAccountID, String toAccountID,
           BigDecimal amountToTransfer)
           throws RemoteException;
          


          4) In TellerBean.java, instantiate a TxController proxy by:
           InitialContext ctx = new InitialContext();
           TxControllerHome txHome = (TxControllerHome)
           ctx.lookup("java:comp/env/ejb/tx");
          
           TxController txController = txHome.create();
          


          5) Within TellerBean.transfer(String,String,BigDecimal), invoke whatever method of TxController you want for your "business logic" -- in my case, it was TxController.transferFunds(BigDecimal,String,String,String). It works great, including transaction logging, etc., as verified by the bank/main web app.

          Back to your regularly scheduled hacking,
          --Gary

          • 2. Re: Extending Teller WS example
            Chili Way Newbie

            I have the same question.
            It seems to me it's inconsistent in the content of ejb-ref.
            Can anybody tell me why the home and remote interfaces point to a Customer Bean?


            "glindstrom" wrote:
            I am seeking to extend the Teller WS example of Chapter 5 to support additional functionality, namely, transfer of funds between accounts, e.g. as provided by the TxController.transferFunds.

            I realize this will involve extending the ws ejb-jar.xml to include additional ejb-ref's.

            But I am baffled how the ejb-ref.xml as given works -- it includes
             <ejb-ref>
             <ejb-ref-name>ejb/account</ejb-ref-name>
             <ejb-ref-type>Session</ejb-ref-type>
             <home>com.sun.ebank.ejb.customer.CustomerHome</home>
             <remote>com.sun.ebank.ejb.customer.Customer</remote>
             </ejb-ref>
            

            which is used in TellerBean.getController() to instantiate an AccountControllerHome object
             AccountControllerHome home = (AccountControllerHome)
             ctx.lookup("java:comp/env/ejb/account");
            


            How can this be, given that the ejb-ref specifies a CustomerHome?

            Thanks,
            --Gary