Examples of CabinHomeRemote


Examples of com.titan.cabin.CabinHomeRemote

        try {
            Context jndiContext = getInitialContext();
           
            Object ref =
                jndiContext.lookup("CabinHome");
            CabinHomeRemote home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref,CabinHomeRemote.class)
            // Add 9 cabins to deck 1 of ship 1.
            makeCabins(home, 2, 10, 1, 1);
            // Add 10 cabins to deck 2 of ship 1.
            makeCabins(home, 11, 20, 2, 1);
            // Add 10 cabins to deck 3 of ship 1.

            makeCabins(home, 21, 30, 3, 1);
           
            // Add 10 cabins to deck 1 of ship 2.
            makeCabins(home, 31, 40, 1, 2);
            // Add 10 cabins to deck 2 of ship 2.
            makeCabins(home, 41, 50, 2, 2);
            // Add 10 cabins to deck 3 of ship 2.
            makeCabins(home, 51, 60, 3, 2);
           
            // Add 10 cabins to deck 1 of ship 3.
            makeCabins(home, 61, 70, 1, 3);
            // Add 10 cabins to deck 2 of ship 3.
            makeCabins(home, 71, 80, 2, 3);
            // Add 10 cabins to deck 3 of ship 3.
            makeCabins(home, 81, 90, 3, 3);
            // Add 10 cabins to deck 4 of ship 3.
            makeCabins(home, 91, 100, 4, 3);

            for (int i = 1; i <= 100; i++){
                Integer pk = new Integer(i);
                CabinRemote cabin = home.findByPrimaryKey(pk);
                System.out.println("PK = "+i+", Ship = "+cabin.getShipId()
                  + ", Deck = "+cabin.getDeckLevel()
                  + ", BedCount = "+cabin.getBedCount()
                  + ", Name = "+cabin.getName());
            }
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

public class Client_41 {
    public static void main(String [] args) {
        try {
            Context jndiContext = getInitialContext();
            Object ref = jndiContext.lookup("CabinHome");
            CabinHomeRemote home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref,CabinHomeRemote.class);  
          
            if ( ref != null )
            {
                System.out.println(" Found Cabin Home");
            }
            CabinRemote cabin_1 = home.create(new Integer(1));
            cabin_1.setName("Master Suite");
            cabin_1.setDeckLevel(1);
            cabin_1.setShipId(1);
            cabin_1.setBedCount(3);

               
            Integer pk = new Integer(1);
           
            CabinRemote cabin_2 = home.findByPrimaryKey(pk);
            System.out.println(cabin_2.getName());
            System.out.println(cabin_2.getDeckLevel());
            System.out.println(cabin_2.getShipId());
            System.out.println(cabin_2.getBedCount());
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

    try {

      Context jndiContext = getInitialContext()

      Object ref = jndiContext.lookup("CabinHome");
      CabinHomeRemote home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref,CabinHomeRemote.class);

      System.out.println("Testing serialization of EJBObject handle");

      Integer pk_1 = new Integer(100);
      CabinRemote cabin_1 = home.findByPrimaryKey(pk_1);

      // Serialize the Handle for cabin 100 to a file.
      Handle handle = cabin_1.getHandle();
      FileOutputStream fos = new FileOutputStream("handle100.ser");
      ObjectOutputStream outStream = new ObjectOutputStream(fos);
      System.out.println("Writing handle to file...");
      outStream.writeObject(handle);
      outStream.flush();
      fos.close();
      handle = null;

      // Deserialize the Handle for cabin 100.
      FileInputStream fis = new FileInputStream("handle100.ser");
      ObjectInputStream inStream = new ObjectInputStream(fis);
      System.out.println("Reading handle from file...");
      handle = (Handle)inStream.readObject();
      fis.close();

      // Reobtain a remote reference to cabin 100 and read its name.
      System.out.println("Acquiring reference using deserialized handle...");
      ref = handle.getEJBObject();
      CabinRemote cabin_2 = (CabinRemote)
        PortableRemoteObject.narrow(ref, CabinRemote.class);

      if(cabin_1.isIdentical(cabin_2)) {
        System.out.println("cabin_1.isIdentical(cabin_2) returns true - This is correct");
      } else {
        System.out.println("cabin_1.isIdentical(cabin_2) returns false - This is wrong!");
      }

      System.out.println("Testing serialization of Home handle");

      // Serialize the HomeHandle for the cabin bean.
      HomeHandle homeHandle = home.getHomeHandle();
      fos = new FileOutputStream("handle.ser");
      outStream = new ObjectOutputStream(fos);
      System.out.println("Writing Home handle to file...");
      outStream.writeObject(homeHandle);
      outStream.flush();
      fos.close();
      homeHandle = null;

      // Deserialize the HomeHandle for the cabin bean.
      fis = new FileInputStream("handle.ser");
      inStream = new ObjectInputStream(fis);
      System.out.println("Reading Home handle from file...");
      homeHandle = (HomeHandle)inStream.readObject();
      fis.close();

      System.out.println("Acquiring reference using deserialized Home handle...");
      Object hometemp = homeHandle.getEJBHome();
      CabinHomeRemote home2 = (CabinHomeRemote)
        PortableRemoteObject.narrow(hometemp,CabinHomeRemote.class);


      System.out.println("Acquiring reference to bean using new Home interface...");
      CabinRemote cabin_3 = home2.findByPrimaryKey(pk_1);

      // Test that we end up with the same bean after finding it through this home
      if(cabin_1.isIdentical(cabin_3)) {
        System.out.println("cabin_1.isIdentical(cabin_3) returns true - This is correct");
      } else {
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

    try {

      Context jndiContext = getInitialContext()

      Object ref = jndiContext.lookup("CabinHome");
      CabinHomeRemote home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref,CabinHomeRemote.class);

      testReferences(home);
      testSerialization(home);

      System.out.println("Removing Cabin from database to clean up..");
      // Make this client class re-entrant by cleaning up the bean we created
      Integer pk = new Integer(101);
      home.remove(pk);

        } catch (java.rmi.RemoteException re){re.printStackTrace();}
          catch (Throwable t){t.printStackTrace();}
  }
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

           javax.naming.Context jndiContext = new InitialContext();
            Object obj =
                   jndiContext.lookup("java:comp/env/ejb/CabinHome");


            CabinHomeRemote home = (CabinHomeRemote)
            javax.rmi.PortableRemoteObject.narrow(obj,CabinHomeRemote.class);
   
            Vector vect = new Vector();
            for (int i = 1; ; i++) {
              Integer pk = new Integer(i);
              CabinRemote cabin = null;
              try {
                  cabin = home.findByPrimaryKey(pk);
                } catch(javax.ejb.FinderException fe) {
                    System.out.println("Caught exception: "+fe.getMessage()+" for pk="+i);

                    break;
                }
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

           javax.naming.Context jndiContext = new InitialContext();
            Object obj =
                   jndiContext.lookup("java:comp/env/ejb/CabinHome");


            CabinHomeRemote home = (CabinHomeRemote)
            javax.rmi.PortableRemoteObject.narrow(obj,CabinHomeRemote.class);
   
            Vector vect = new Vector();
            for (int i = 1; ; i++) {
              Integer pk = new Integer(i);
              CabinRemote cabin = null;
              try {
                  cabin = home.findByPrimaryKey(pk);
                } catch(javax.ejb.FinderException fe) {
                    System.out.println("Caught exception: "+fe.getMessage()+" for pk="+i);

                    break;
                }
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

    public static void main(String [] args) {
        try {
      Context jndiContext = getInitialContext();

      Object ref = jndiContext.lookup("CabinHome");
      CabinHomeRemote c_home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref, CabinHomeRemote.class);

      EJBMetaData meta = c_home.getEJBMetaData();

      System.out.println(meta.getHomeInterfaceClass().getName());
      System.out.println(meta.getRemoteInterfaceClass().getName());
      System.out.println(meta.getPrimaryKeyClass().getName());
      System.out.println(meta.isSession());

      Class primKeyType = meta.getPrimaryKeyClass();
      if (primKeyType.getName().equals("java.lang.Integer")) {
        Integer pk = new Integer(1);
        Object ref2 = meta.getEJBHome();
        CabinHomeRemote c_home2 = (CabinHomeRemote)
          PortableRemoteObject.narrow(ref2,CabinHomeRemote.class);
        CabinRemote cabin = c_home2.findByPrimaryKey(pk);
        System.out.println(cabin.getName());
      }
       
        } catch(java.rmi.RemoteException re){re.printStackTrace();}
          catch(Throwable t){t.printStackTrace();}
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

      }

      // Obtain the home and re-create cabin 30. Rerun the same cabin list.

      ref = jndiContext.lookup("java:comp/env/ejb/CabinHome");
      CabinHomeRemote c_home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref, CabinHomeRemote.class);

      // re-create the single cabin (#30) we deleted with Client_4 example
            makeCabin(c_home, 30, 3, 1, 3, 309);
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

      }

      // Obtain the home and remove cabin 30. Rerun the same cabin list.

      ref = jndiContext.lookup("CabinHome");
      CabinHomeRemote c_home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref, CabinHomeRemote.class);

      Integer pk = new Integer(30);
      c_home.remove(pk);
      list = agent.listCabins(1,3)
      System.out.println("2nd List: After deleting cabin number 30");
      for (int i = 0; i < list.length; i++) {
        System.out.println(list[i]);
      }
View Full Code Here

Examples of com.titan.cabin.CabinHomeRemote

        try {
            Context jndiContext = getInitialContext();
           
            Object ref =
                jndiContext.lookup("CabinHomeRemote");
            CabinHomeRemote home = (CabinHomeRemote)
        PortableRemoteObject.narrow(ref,CabinHomeRemote.class)
            // Add 9 cabins to deck 1 of ship 1.
            makeCabins(home, 2, 10, 1, 1);
            // Add 10 cabins to deck 2 of ship 1.
            makeCabins(home, 11, 20, 2, 1);
            // Add 10 cabins to deck 3 of ship 1.

            makeCabins(home, 21, 30, 3, 1);
           
            // Add 10 cabins to deck 1 of ship 2.
            makeCabins(home, 31, 40, 1, 2);
            // Add 10 cabins to deck 2 of ship 2.
            makeCabins(home, 41, 50, 2, 2);
            // Add 10 cabins to deck 3 of ship 2.
            makeCabins(home, 51, 60, 3, 2);
           
            // Add 10 cabins to deck 1 of ship 3.
            makeCabins(home, 61, 70, 1, 3);
            // Add 10 cabins to deck 2 of ship 3.
            makeCabins(home, 71, 80, 2, 3);
            // Add 10 cabins to deck 3 of ship 3.
            makeCabins(home, 81, 90, 3, 3);
            // Add 10 cabins to deck 4 of ship 3.
            makeCabins(home, 91, 100, 4, 3);

            for (int i = 1; i <= 100; i++){
                Integer pk = new Integer(i);
                CabinRemote cabin = home.findByPrimaryKey(pk);
                System.out.println("PK = "+i+", Ship = "+cabin.getShipId()
                  + ", Deck = "+cabin.getDeckLevel()
                  + ", BedCount = "+cabin.getBedCount()
                  + ", Name = "+cabin.getName());
            }
View Full Code Here
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.