Search in sources :

Example 1 with ServerConnFactory

use of org.apache.synapse.transport.http.conn.ServerConnFactory in project wso2-synapse by wso2.

the class PassThroughListeningIOReactorManager method getSharedSSLIOReactor.

private ListeningIOReactor getSharedSSLIOReactor(NHttpServerEventHandler nHttpServerEventHandler, String endpointName, int port, SSLConfiguration sslConfiguration) throws Exception {
    if (!isSharedSSLIOReactorInitiated.get()) {
        if (sslPassThroughListenerConfiguration != null) {
            try {
                synchronized (this) {
                    sharedSSLListeningIOReactor = createListeningIOReactor(sslPassThroughListenerConfiguration);
                    ServerIODispatch serverIODispatch = new MultiListenerSSLServerIODispatch(portServerHandlerMapper, nHttpServerEventHandler, serverConnectionFactoryMapper);
                    startIOReactor(sharedSSLListeningIOReactor, serverIODispatch, "HTTPS");
                    isSharedSSLIOReactorInitiated.compareAndSet(false, true);
                }
            } catch (IOReactorException e) {
                throw new IOReactorException("Error occurred when creating shared IO Reactor for non axis2 Listener " + endpointName, e);
            }
        } else {
            throw new Exception("Cannot start Endpoint for" + endpointName + "Axis2 SSL Transport Listeners for PassThrough transport" + " not started correctly or not created the " + "IOReactor Configuration");
        }
    }
    ServerConnFactory serverConnFactory = SSLConnectionUtils.getServerConnectionFactory(endpointName, sslPassThroughListenerConfiguration, sslConfiguration);
    if (serverConnectionFactoryMapper.get(port) != null) {
        throw new Exception("Cannot create ServerConnectionFactory for " + endpointName + "in port " + port + "already registered a server connection factory ");
    } else {
        serverConnectionFactoryMapper.put(port, serverConnFactory);
    }
    return sharedSSLListeningIOReactor;
}
Also used : IOReactorException(org.apache.http.nio.reactor.IOReactorException) ServerIODispatch(org.apache.synapse.transport.passthru.ServerIODispatch) MultiListenerSSLServerIODispatch(org.apache.synapse.transport.passthru.core.ssl.MultiListenerSSLServerIODispatch) ServerConnFactory(org.apache.synapse.transport.http.conn.ServerConnFactory) MultiListenerSSLServerIODispatch(org.apache.synapse.transport.passthru.core.ssl.MultiListenerSSLServerIODispatch) IOException(java.io.IOException) IOReactorException(org.apache.http.nio.reactor.IOReactorException)

Example 2 with ServerConnFactory

use of org.apache.synapse.transport.http.conn.ServerConnFactory in project wso2-synapse by wso2.

the class MultiListenerSSLServerIODispatch method createConnection.

@Override
protected DefaultNHttpServerConnection createConnection(IOSession session) {
    ServerConnFactory serverConnFactory;
    SocketAddress socketAddress = session.getLocalAddress();
    int port = ((InetSocketAddress) socketAddress).getPort();
    serverConnFactory = endpointSSLConfigHolder.get(port);
    if (serverConnFactory != null) {
        return serverConnFactory.createConnection(session);
    } else {
        log.error("Cannot find Configured Server Connection Factory for port " + port);
    }
    return null;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ServerConnFactory(org.apache.synapse.transport.http.conn.ServerConnFactory) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

ServerConnFactory (org.apache.synapse.transport.http.conn.ServerConnFactory)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 IOReactorException (org.apache.http.nio.reactor.IOReactorException)1 ServerIODispatch (org.apache.synapse.transport.passthru.ServerIODispatch)1 MultiListenerSSLServerIODispatch (org.apache.synapse.transport.passthru.core.ssl.MultiListenerSSLServerIODispatch)1