public void start()

in CodeCoverage/JavaServer/java/src/org/apache/flex/tools/codecoverage/server/CodeCoverageServer.java [249:327]


    public void start() throws IOException, InterruptedException
    {
        if (isAlive())
        {
            System.out.println("Apache Flex Code Coverage Server is already running");
            return;
        }
        
        final String dataProperty = config.getProperty(DATA_DIRECTORY_KEY);
        final File dataDirectory;
        
        if (dataProperty == null)
            dataDirectory = new File(System.getProperty("user.home"), "ccdata");
        else 
            dataDirectory = new File(dataProperty); 
        
        if (!dataDirectory.exists())
        {
            // mkdir() is creating the directory but returning false, so
            // re-test with exists()
            if (!dataDirectory.mkdir() && !dataDirectory.exists())
            {
                System.err.println("Error: Data directory does not exist and unable to create it: " + dataDirectory.getAbsolutePath());
                return;
            }
        }
        
        int fileCount = initDataDirectory(dataDirectory);
        
        // modify mm.cfg file
        updateMMCFG(ADD_PRELOADSWF_KEY);

        // create thread to listen for connections on the data port
        final DataSocketAccepter dataSocketAccepter = 
                new DataSocketAccepter(host, dataPort, dataDirectory, fileCount);
        final Thread dataThread = new Thread(dataSocketAccepter);
        dataThread.start();
        
        // create thread to listen the policy file port and server up the socket policy file.
        final PolicyFileServer policyFileServer = new PolicyFileServer(host,
                dataPort, policyFilePort);
        final Thread policyFileServerThread = new Thread(policyFileServer);
        policyFileServerThread.start();
        
        System.out.println("listening on port " + dataPort);

        // read commands on command socket
        final ServerSocket commandSocket = new ServerSocket(commandPort);
        
        try
        {
            while (listening)
            {
                try (Socket socket = commandSocket.accept();
                     InputStreamReader reader = new InputStreamReader(socket.getInputStream());
                     OutputStreamWriter writer = new OutputStreamWriter(socket.getOutputStream()))
                {
                    // wait for request
                    char[] cbuf = new char[256];
                    int charsRead = reader.read(cbuf);
                    if (charsRead > 0)
                    {
                        processCommand(reader, writer, String.valueOf(cbuf).trim());
                    }
                }
            }
        }
        finally
        {
            commandSocket.close();
            policyFileServer.close();
            policyFileServerThread.join();
            dataSocketAccepter.close();
            dataThread.join();
            updateMMCFG(REMOVE_PRELOADSWF_KEY);        	
        }
        
        System.out.println("stopping Apache Flex Code Coverage Server");
    }