Exemple #1
0
        protected virtual string doRealisation(StringReader inputReader)
        {
            xmlrealiser.wrapper.RequestType request = XMLRealiser.getRequest(inputReader);
            string output = XMLRealiser.realise(request.Document);

            return(output);
        }
        /**
         * startServer -- Start's the SimpleServer with a created ServerSocket.
         * @param socket -- The socket for the server to use.
         * @throws IOException
         * @throws SocketException
         */
        private void startServer(TcpListener socket)
        {
            serverSocket = socket;
            serverSocket.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
            serverSocket.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 0);

            int port = ((IPEndPoint)serverSocket.LocalEndpoint).Port;

            Console.WriteLine("Port Number used by Server is: " + port);

            // try to read the lexicon path from lexicon.properties file
            try
            {
                Properties prop = new Properties();
                prop.load("Resources/lexicon.properties");

                string dbFile = prop.getProperty("DB_FILENAME");

                if (null != dbFile)
                {
                    lexiconPath = dbFile;
                }
                else
                {
                    throw new Exception("No DB_FILENAME in lexicon.properties");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            Console.WriteLine("Server is using the following lexicon: " + lexiconPath);

            XMLRealiser.setLexicon(lexiconType, lexiconPath);
        }