Collections - Hashtable, ArrayList, etc

Description:

The server exports functions which handel different Java collection containers (java.util.Hashtable, java.util.ArrayList).
Additionally, this example will use some Serializable classes whose instances will be transported "by value" to the client
(see also the Objects by value example.)

Source:

\DemoJava\Collection

Mapping:

java.util.Hashtable <---> System.Collections.Hashtable
java.util.ArrayList <---> System.Collections.ArrayList


Example

Step 1. Write the Java server:

  public class GreetingsImpl extends PortableRemoteObject implements Greetings 
  {
    public java.util.Hashtable queryAddresses( ) throws RemoteException 
    {
      System.out.println("queryAddresses");
      java.util.Hashtable oAddressList = new java.util.Hashtable();
      oAddressList.put("Clark, John", new HomeAddr( "Clark", "John", "21079", "Hamburg"));
      oAddressList.put("Meier, Marie", new HomeAddr( "Meiser", "Marie", "223344", "Bremen"));
      oAddressList.put("Berlin Touring Inc", new CompanyAddr( "Day & Nigth Berlin Touring Inc.", "12345", "Berlin"));  
      return oAddressList;
    }
    
    public java.util.ArrayList queryCustomers( ) 	throws RemoteException 
    {
      System.out.println("queryCustomers");
      java.util.ArrayList oAddressList = new java.util.ArrayList();
      oAddressList.add( new HomeAddr( "Clark", "John", "21079", "Hamburg"));
      oAddressList.add( new HomeAddr( "Meiser", "Marie", "223344", "Bremen"));
      oAddressList.add( new CompanyAddr( "Day & Nigth Berlin Touring Inc.", "12345", "Berlin"));
      return oAddressList;
    }
    
    ...
  }	

Step 2. Write the .NET client:

Call the Server:

  ...
  System.Collections.Hashtable oHash = m_oGreetings.queryAddresses();
  ...
  System.Collection.Arraylist  oArray = m_oGreetings.queryCustomers();
  ...

Step 3. Run the example

a.) Start the sun name service on port 10050:

    > start orbd -ORBInitialPort 10050  

(could also use startNameService.bat located in the DemoJava directory to quick start the name service)

b.) Start the java server by using JNDI CosNaming and work with a name service running on 'localhost' at port '10050':

    > start java -cp .;Server.jar -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:10050 Server  

(could also use buildServer.bat and startServer.bat located in the JavaServer directory to quick build and run the Java Server)

c.) Start the .NET Client.