Search in sources :

Example 1 with IoHandlerAdapter

use of org.apache.mina.core.service.IoHandlerAdapter in project streamsx.topology by IBMStreams.

the class TupleCollection method addTCPServerAndSink.

/**
     * Add a TCP server that will list for tuples to be directed to handlers.
     * Adds a sink to the topology to capture those tuples and deliver them to
     * the current jvm to run Junit type tests.
     */
private void addTCPServerAndSink() throws Exception {
    tcpServer = new TCPTestServer(0, new IoHandlerAdapter() {

        @Override
        public void messageReceived(IoSession session, Object message) throws Exception {
            TestTuple tuple = (TestTuple) message;
            TestTupleInjector injector = injectors.get(tuple.getTesterId());
            injector.tuple(tuple.getTupleData());
        }
    });
    InetSocketAddress testAddr = tcpServer.start();
    addTesterSink(testAddr);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IoHandlerAdapter(org.apache.mina.core.service.IoHandlerAdapter) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 IoHandlerAdapter (org.apache.mina.core.service.IoHandlerAdapter)1 IoSession (org.apache.mina.core.session.IoSession)1