/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.nplusc.izc.iZpl;

import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 *
 * @author LH
 */
public class PLServer
{
    
    public  PlProcessor ppp=null;
    public PLServer(String plPath)
    {
        try
        {
            HttpServer server = HttpServer.create(new InetSocketAddress("localhost",9263), 0);//,InetAddress.getByName("localhost"));
            ppp = new PlProcessor();
            ppp.InitializeOnPath(plPath);
            server.createContext("/", ppp);//nimmt jeden beliebigen namen an
            server.createContext("/reload",new ReloadMgrT(ppp));
            server.createContext("/rcvr",new ReInitializer());
            server.setExecutor(null); // creates a default executor
            server.start();
        }
        catch (IOException ex)
        {
            ex.printStackTrace();
        }
    }
    public PLServer(PlProcessor pp)
    {
        try
        {
            HttpServer server = HttpServer.create(new InetSocketAddress("localhost",9263), 0);//,InetAddress.getByName("localhost"));
            server.createContext("/", pp);//nimmt jeden beliebigen namen an
            ppp=pp;
            server.createContext("/reload",new ReloadMgrT(ppp));
            server.createContext("/rcvr",new ReInitializer());
            server.setExecutor(null); // creates a default executor
            server.start();
        }
        catch (IOException ex)
        {
            ex.printStackTrace();
        }
    }
}
