Hi,
currently I'm working on subj implementation and have something
completed.
Please take a look at the example [1].
It's simple example, where you can read/write Strings directly, using
standalone filterchain processing.
What do you think?
Thanks.
WBR,
Alexey.
[1]
public class FilterChainTest extends TestCase {
public static final int PORT = 7778;
public void testStandaloneFilter() throws Exception {
Connection connection = null;
TCPNIOTransport transport =
TransportManager.instance().createTCPTransport();
transport.getFilterChain().add(new TransportFilter());
transport.getFilterChain().add(new UTFStringFilter());
transport.getFilterChain().add(new EchoFilter());
try {
transport.bind(PORT);
transport.start();
ConnectFuture future =
transport.connectAsync("localhost", PORT);
connection = (TCPNIOConnection) future.get(10,
TimeUnit.SECONDS);
assertTrue(connection != null);
String message = "Hello world!";
FilterChain filterChain = transport.getFilterChain();
WriteResult result = filterChain.write(connection,
message);
assertEquals(result.getMessage(), message);
ReadResult readResult = filterChain.read(connection);
String responseMessage = (String) readResult.getMessage();
assertEquals(message, responseMessage);
} finally {
if (connection != null) {
connection.close();
}
transport.stop();
TransportManager.instance().close();
}
}
}