Main page / Java Connectivity page

Collections - HashTable, ArrayList,...


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: 
	MinCor\DemoJava\Collection

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



Example 

The Java server:

    Interface     : Collections\Greetings.java
    Implementation: Collections\GreetingsImpl.java
	
    Serializables : Collections\HomeAddr.java
                    Collections\CompanyAddr.java

    
    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;	
    }	
	


The .Net client:

    Implementation: ClientImpl.cs
    IDL-File      : Collections.idl
    Generated     : Collections.cs

    Serializables : HomeAddrImpl.cs
                    CompanyAddrImpl.cs

    Call the Server:
      
    // ...
    System.Collections.Hashtable oHash = m_oGreetings.queryAddresses();
    // ...
    System.Collection.Arraylist  oArray = m_oGreetings.queryCustomers();
    // ...
          
    
    Note, that we have to add several items to the list of assemblies to be searched for 
    by the .Net Reflection. This list is set using the "-AddAssembly" parameter during ORB 
    initialization:
    
    private static string[] m_strORBInit = {"-ORBEndpoint iiop://localhost:8545/portspan=100", 
                                            "-ORBInitRef NameService=corbaloc:iiop:1.2@localhost:1050/NameService",
                                            "-ORBDebug",
                                            "-AddAssembly DotNetClient.exe,JavaBuiltinTypesCF.dll,MinCorCF.dll" };