package com.test.core; import java.io.IOException; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import Ice.Application; public class Server extends Application { public static void main(String[] args) { Server app = new Server (); app.main ("Server", args); } public int run(String[] arg0) { int status = 0; Ice.Communicator ic = null; Directory fsDir = null; IndexSearcher is = null; System.out.println ("Starting server..."); try { fsDir = FSDirectory.getDirectory ("/home/jordi/workspace/server/index", false); is = new IndexSearcher (fsDir); } catch (IOException e1) { e1.printStackTrace(); } try { ic = Ice.Util.initialize(arg0); Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("Server", "default -h 172.20.3.17 -p 10000"); Ice.Object indexer = new TIndexerI(); Ice.Object searcher = new TSearcherI (is); adapter.add (indexer, Ice.Util.stringToIdentity ("Indexer")); adapter.add (searcher, Ice.Util.stringToIdentity ("Searcher")); adapter.activate(); ic.waitForShutdown(); } catch (Ice.LocalException e) { e.printStackTrace(); status = 1; } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } System.out.println ("Closing server..."); if (ic != null) { // Clean up // try { ic.destroy(); } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } } return status; } }