import java.lang.*;
import java.io.*;
import java.util.*;
import Server.*;
import Server.ProcessHitsCollectionPackage.*;

class ProducerConsumer extends ProcessHitsCollectionPOA {

    private static Database dataBase;
    private static int nextKey;
    private static Database.DBRecordData recordData;

    ProducerConsumer() {
        dataBase = new Database();
        nextKey = 0;
    }

    public static void main(String args[]) throws Exception {

        Properties props = System.getProperties();
        props.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
        props.put("org.omg.CORBA.ORBSingletonClass", "com.ooc.CORBA.ORBSingleton
");
        org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
        System.out.println("[client] orb.inirialized");
        org.omg.PortableServer.POA rootPOA =
            org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_referenc
es("RootPOA"));
        org.omg.PortableServer.POAManager manager = rootPOA.the_POAManager();
        ProducerConsumer aProcessImpl = new ProducerConsumer();
        org.omg.CORBA.Object aProcess = aProcessImpl._this(orb);
        try{
            PrintWriter pw = new PrintWriter( new FileWriter(args[0]) );
            pw.write(orb.object_to_string(aProcess));
            pw.close();
        }catch(java.io.IOException e) {
            System.out.println("Exception: " + e);
            System.exit(1);
        }

        manager.activate();
        orb.run();
    }

    public void process(Hit[] aHitsCol) {
        int sLength = aHitsCol.length;
        System.out.println("# Lenght of received sequence = "+sLength);
        for (int i=0; i