// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.rmi.*;
import java.util.*;

import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;

import eee.*;

public class TestT1 {
    public static void main(String[] args) {
        System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        System.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
        System.setProperty("java.naming.provider.url", "localhost:1099");
        try {
            Context ctx = new InitialContext();
            Object temp = null;
            temp = ctx.lookup("ejb/T1");
            T1RemoteHome home = (T1RemoteHome) PortableRemoteObject.narrow(temp, T1RemoteHome.class);
            Iterator it = home.findAll().iterator();
            while (it.hasNext()) {
                T1Remote bean = (T1Remote) it.next();
                System.out.println(bean.getF1() + " " + bean.getF2());
            }
        } catch (ClassCastException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (FinderException e) {
            e.printStackTrace();
        }
    }
}
