FileDocCategorySizeDatePackage
Client_51b.javaAPI DocExample1928Wed May 29 11:39:20 BST 2002com.titan.clients

Client_51b

public class Client_51b extends Object
Example of EJB meta data and getting the home interface from the meta data.

Fields Summary
Constructors Summary
Methods Summary
public static javax.naming.ContextgetInitialContext()

      // jndi.properties contains InitialContext properties
      return new InitialContext();
   
public static voidmain(java.lang.String[] args)

      try 
      {
         Context jndiContext = getInitialContext();

         Object ref = jndiContext.lookup("CabinHomeRemote");
         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();
      }