Here is the code for your question :

import java.rmi.RemoteException;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import Simple.*;// This import  is from the server !!!!!!
import SimpleHome.*;
import java.util.Hashtable;
import java.util.*;
public class Class1  {

  /**
   * Constructor
   */
  public Class1() {
  }
  private static Context setJNDIEnv(String URL) throws javax.naming.NamingException
  {
    Hashtable env=new Hashtable();
    //orion specific !!!
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
//com.sun.jndi.rmi.registry.RegistryContextFactory
//com.evermind.server.rmi.RMIInitialContextFactory
    env.put(Context.PROVIDER_URL, URL);
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "123");

    System.out.println("Environment variables initialazied ...");
    return new InitialContext(env);
  }
 
  public static void main(String[] args) {
    Class1 TestClient = new Class1();
    Vector v=new Vector();
    try{
      System.out.println("Trying to initialize context ...");
      Context context = setJNDIEnv("rmi://xxx.xxx.xx.xx/orion-simple");
      System.out.println("Initialize context ended...");
      System.out.println("starting Object lookup ...");

      // Get a reference to the Hello home interface
      SimpleHome simpleHome;
      try {
         Object boundObject = context.lookup("MySimple");
         simpleHome = (SimpleHome) PortableRemoteObject.narrow(boundObject,SimpleHome.class);
      }
      catch (Throwable exception) {
         throw new Exception("Unable to get home interface: " + exception.toString());
      }
       // Get a reference to a Hello instance
      //Simple _simple;
      try {
          //_simple = simpleHome.create();
          for(int iii=0;iii<50;iii++){
            System.out.println("" +iii );
            v.addElement((Object)simpleHome.create());
          }
      }
      catch (Throwable exception) {
         throw new Exception("Unable to create Hello instance: " + exception.toString());
      }
      for(int i=0;i<50;i++){
            System.out.println(((Simple)v.elementAt(i)).getString());
          }
      //System.out.println(_simple.getString()+ v.size() );

    }catch(Exception e) {e.printStackTrace() ;}
  }
}

:)
--
/****************************************************************/
Shlomo Kashani ,                  | PictureVision R&D
Information Systems Engineer      | Har Hotzvim  POB 45048 ,
       [EMAIL PROTECTED]      | Jerusalem 91450 ,
                                             | Israel .
tel  : 972-2-5813401  Ex-260      | www.picturevision.com
/****************************************************************/
 



Reply via email to