Examples of CabinRemote


Examples of com.titan.cabin.CabinRemote

            // 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());
            }

        } catch (java.rmi.RemoteException re) {re.printStackTrace();}
          catch (javax.naming.NamingException ne) {ne.printStackTrace();}
          catch (javax.ejb.CreateException ce) {ce.printStackTrace();}
View Full Code Here

Examples of com.titan.cabin.CabinRemote

                                int deckLevel, int shipNumber)
    throws RemoteException, CreateException {

    int bc = 3;
    for (int i = fromId; i <= toId; i++) {       
        CabinRemote cabin = home.create(new Integer(i));
        int suiteNumber = deckLevel*100+(i-fromId);
        cabin.setName("Suite "+suiteNumber);
        cabin.setDeckLevel(deckLevel);
        bc = (bc==3)?2:3;
        cabin.setBedCount(bc);
        cabin.setShipId(shipNumber);
    }
  }
View Full Code Here

Examples of com.titan.cabin.CabinRemote

          
            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());

        } catch (java.rmi.RemoteException re){re.printStackTrace();}
          catch (javax.naming.NamingException ne){ne.printStackTrace();}
          catch (javax.ejb.CreateException ce){ce.printStackTrace();}
          catch (javax.ejb.FinderException fe){fe.printStackTrace();}
View Full Code Here

Examples of com.titan.cabin.CabinRemote

        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.CabinRemote

   */
  public static void testReferences(CabinHomeRemote home)   
    throws Exception {

    System.out.println("Creating Cabin 101 and retrieving additional reference by pk");
    CabinRemote cabin_1 = home.create(new Integer(101));
    Integer pk = (Integer)cabin_1.getPrimaryKey();
    CabinRemote cabin_2 = home.findByPrimaryKey(pk);

    System.out.println("Testing reference equivalence");
    // We now have two remote references to the same bean -- Prove it!
    cabin_1.setName("Keel Korner");
    if (cabin_2.getName().equals("Keel Korner")) {
      System.out.println("Names match!");
    }

    // Test the isIdentical() function
    if (cabin_1.isIdentical(cabin_2)) {
View Full Code Here

Examples of com.titan.cabin.CabinRemote

  public static void testSerialization(CabinHomeRemote home)   
    throws Exception {

    System.out.println("Testing serialization of primary key");
    Integer pk_1 = new Integer(101);
    CabinRemote cabin_1 = home.findByPrimaryKey(pk_1);
    System.out.println("Setting cabin name to Presidential Suite");

    cabin_1.setName("Presidential Suite");

    // Serialize the primary key for cabin 101 to a file.
    FileOutputStream fos = new FileOutputStream("pk101.ser");
    ObjectOutputStream outStream = new ObjectOutputStream(fos);
    System.out.println("Writing primary key object to file...");
    outStream.writeObject(pk_1);
    outStream.flush();
    outStream.close();
    pk_1 = null;

    // Deserialize the primary key for cabin 101.
    FileInputStream fis = new FileInputStream("pk101.ser");
    ObjectInputStream inStream = new ObjectInputStream(fis);
    System.out.println("Reading primary key object from file...");
    Integer pk_2 = (Integer)inStream.readObject();
    inStream.close();

    // Re-obtain a remote reference to cabin 101 and read its name.
    System.out.println("Acquiring reference using deserialized primary key...");
    CabinRemote cabin_2 = home.findByPrimaryKey(pk_2);
    System.out.println("Retrieving name of Cabin using new remote reference...");
    System.out.println(cabin_2.getName());
                System.exit(0);

  }
View Full Code Here

Examples of com.titan.cabin.CabinRemote

            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;
                }
                // Check to see if the bed count and ship ID match.
                if (cabin != null &&
                    cabin.getShipId() == shipID &&
                    cabin.getBedCount() == bedCount) {
                  String details =

                    i+","+cabin.getName()+","+cabin.getDeckLevel();
                  vect.addElement(details);
                }
            }
       
            String [] list = new String[vect.size()];
View Full Code Here

Examples of com.titan.cabin.CabinRemote

            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;
                }
                // Check to see if the bed count and ship ID match.
                if (cabin != null &&
                    cabin.getShipId() == shipID &&
                    cabin.getBedCount() == bedCount) {
                  String details =

                    i+","+cabin.getName()+","+cabin.getDeckLevel();
                  vect.addElement(details);
                }
            }
       
            String [] list = new String[vect.size()];
View Full Code Here

Examples of com.titan.cabin.CabinRemote

      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.CabinRemote

*/
  public static void makeCabin(CabinHomeRemote home,
                                int Id, int deckLevel, int shipNumber, int bc, int suiteNumber)
    throws RemoteException, CreateException {

        CabinRemote cabin = home.create(new Integer(Id));
        cabin.setName("Suite "+suiteNumber);
        cabin.setDeckLevel(deckLevel);
        cabin.setBedCount(bc);
        cabin.setShipId(shipNumber);
  }
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.