本文整理汇总了Java中org.apache.mina.core.service.IoHandlerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java IoHandlerAdapter类的具体用法?Java IoHandlerAdapter怎么用?Java IoHandlerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IoHandlerAdapter类属于org.apache.mina.core.service包,在下文中一共展示了IoHandlerAdapter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTCPServerAndSink
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
/**
* 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);
}
示例2: TCPTestClient
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public TCPTestClient(InetSocketAddress addr) {
this.addr = addr;
connector.setConnectTimeoutMillis(5000);
IoFilter tupleEncoder = new ProtocolCodecFilter(new TestTupleEncoder(),
new TestTupleDecoder());
connector.getFilterChain().addLast("tuples", tupleEncoder);
connector.setHandler(new IoHandlerAdapter());
}
示例3: setUp
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
sshd = setupTestServer();
PropertyResolverUtils.updateProperty(sshd, FactoryManager.WINDOW_SIZE, 2048);
PropertyResolverUtils.updateProperty(sshd, FactoryManager.MAX_PACKET_SIZE, 256);
sshd.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
sshd.start();
if (!requestsQ.isEmpty()) {
requestsQ.clear();
}
final TcpipForwarderFactory factory = ValidateUtils.checkNotNull(sshd.getTcpipForwarderFactory(), "No TcpipForwarderFactory");
sshd.setTcpipForwarderFactory(new TcpipForwarderFactory() {
private final Class<?>[] interfaces = {TcpipForwarder.class};
private final Map<String, String> method2req = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER) {
private static final long serialVersionUID = 1L; // we're not serializing it...
{
put("localPortForwardingRequested", TcpipForwardHandler.REQUEST);
put("localPortForwardingCancelled", CancelTcpipForwardHandler.REQUEST);
}
};
@Override
public TcpipForwarder create(ConnectionService service) {
Thread thread = Thread.currentThread();
ClassLoader cl = thread.getContextClassLoader();
final TcpipForwarder forwarder = factory.create(service);
return (TcpipForwarder) Proxy.newProxyInstance(cl, interfaces, new InvocationHandler() {
@SuppressWarnings("synthetic-access")
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = method.invoke(forwarder, args);
String name = method.getName();
String request = method2req.get(name);
if (GenericUtils.length(request) > 0) {
if (requestsQ.offer(request)) {
log.info("Signal " + request);
} else {
log.error("Failed to offer request=" + request);
}
}
return result;
}
});
}
});
sshPort = sshd.getPort();
NioSocketAcceptor acceptor = new NioSocketAcceptor();
acceptor.setHandler(new IoHandlerAdapter() {
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
IoBuffer recv = (IoBuffer) message;
IoBuffer sent = IoBuffer.allocate(recv.remaining());
sent.put(recv);
sent.flip();
session.write(sent);
}
});
acceptor.setReuseAddress(true);
acceptor.bind(new InetSocketAddress(0));
echoPort = acceptor.getLocalAddress().getPort();
this.acceptor = acceptor;
}
示例4: setIoHandler
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter ioHandler) {
this.ioHandler = ioHandler;
}
示例5: setIoHandler
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter rtmpIOHandler) {
this.ioHandler = rtmpIOHandler;
}
示例6: setIoHandler
import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter rtmpIOHandler) {
this.ioHandler = rtmpIOHandler;
}