FileDocCategorySizeDatePackage
Client_52.javaAPI DocExample1687Tue Jul 31 23:26:06 BST 2001com.titan.clients

Client_52

public class Client_52 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()

    return new InitialContext();
  
public static voidmain(java.lang.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();}