Search in sources :

Example 1 with IPortChangeListener

use of com.predic8.membrane.core.model.IPortChangeListener in project service-proxy by membrane.

the class HttpTransport method openPort.

/**
 * @param port
 * @throws IOException
 */
@Override
public synchronized void openPort(String ip, int port, SSLProvider sslProvider) throws IOException {
    if (isAnyThreadListeningAt(ip, port)) {
        return;
    }
    if (port == -1)
        throw new RuntimeException("The port-attribute is missing (probably on a <serviceProxy> element).");
    HttpEndpointListener portListenerThread = new HttpEndpointListener(ip, port, this, sslProvider);
    portListenerMapping.put(new IpPort(ip, port), portListenerThread);
    portListenerThread.start();
    for (IPortChangeListener listener : menuListeners) {
        listener.addPort(port);
    }
}
Also used : IPortChangeListener(com.predic8.membrane.core.model.IPortChangeListener)

Example 2 with IPortChangeListener

use of com.predic8.membrane.core.model.IPortChangeListener in project service-proxy by membrane.

the class HttpTransport method closePort.

/**
 * Closes the corresponding server port. Note that connections might still be open and exchanges still running after
 * this method completes.
 */
public synchronized void closePort(String ip, int port) throws IOException {
    IpPort p = new IpPort(ip, port);
    log.debug("Closing server port: " + p);
    HttpEndpointListener plt = portListenerMapping.get(p);
    if (plt == null)
        return;
    plt.closePort();
    try {
        plt.join();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    portListenerMapping.remove(p);
    stillRunning.add(new WeakReference<HttpEndpointListener>(plt));
    for (IPortChangeListener listener : menuListeners) {
        listener.removePort(port);
    }
}
Also used : IPortChangeListener(com.predic8.membrane.core.model.IPortChangeListener)

Aggregations

IPortChangeListener (com.predic8.membrane.core.model.IPortChangeListener)2