Package

Source Code of J2EEClientTest

// This program tests the enterprise beans from a J2EE
// application client.

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import com.sun.ebank.ejb.account.AccountControllerHome;
import com.sun.ebank.ejb.customer.CustomerControllerHome;
import com.sun.ebank.ejb.tx.TxControllerHome;
import com.sun.ebank.util.CodedNames;

public class J2EEClientTest {

   public static void main(String[] args) {

       CustomerControllerHome customerControllerHome;
       AccountControllerHome accountControllerHome;
       TxControllerHome txControllerHome;

       try {
           Context initial;
           Object objref;

           // Customer

           initial = new InitialContext();
           objref = initial.lookup
               (CodedNames.CUSTOMER_CONTROLLER_EJBHOME);
           customerControllerHome =
               (CustomerControllerHome)PortableRemoteObject.narrow(objref,
               CustomerControllerHome.class);

           System.out.println('\n' + "*** CustomerTest ***" + '\n');
           new CustomerTest(customerControllerHome.create());

           // Account

           initial = new InitialContext();
           objref = initial.lookup
               (CodedNames.ACCOUNT_CONTROLLER_EJBHOME);
           accountControllerHome =
               (AccountControllerHome)PortableRemoteObject.narrow(objref,
               AccountControllerHome.class);

           System.out.println('\n' + "*** AccountTest ***" + '\n');
           new AccountTest(accountControllerHome.create());

           // Tx

           initial = new InitialContext();
           objref = initial.lookup
               (CodedNames.TX_CONTROLLER_EJBHOME);
           txControllerHome =
               (TxControllerHome)PortableRemoteObject.narrow(objref,
               TxControllerHome.class);

           System.out.println('\n' + "*** TxTest ***" + '\n');
           new TxTest(txControllerHome.create());

       } catch (NamingException ex) {
           System.err.println("caught NamingException: "  + ex.getMessage());
       } catch (RemoteException ex) {
           System.err.println("caught RemoteException: "  + ex.getMessage());
       } catch (CreateException ex) {
           System.err.println("caught CreateException: "  + ex.getMessage());
       }


   } // main

} // class
TOP

Related Classes of J2EEClientTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.