当前位置: 首页>>代码示例>>Java>>正文


Java IoHandlerAdapter类代码示例

本文整理汇总了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);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:21,代码来源:TCPTesterRuntime.java

示例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());
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:12,代码来源:TCPTestClient.java

示例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;
}
 
开发者ID:termd,项目名称:termd,代码行数:68,代码来源:PortForwardingTest.java

示例4: setIoHandler

import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter ioHandler) {
    this.ioHandler = ioHandler;
}
 
开发者ID:Red5,项目名称:red5-websocket,代码行数:4,代码来源:WebSocketTransport.java

示例5: setIoHandler

import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter rtmpIOHandler) {
    this.ioHandler = rtmpIOHandler;
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:4,代码来源:RTMPMinaTransport.java

示例6: setIoHandler

import org.apache.mina.core.service.IoHandlerAdapter; //导入依赖的package包/类
public void setIoHandler(IoHandlerAdapter rtmpIOHandler) {
	this.ioHandler = rtmpIOHandler;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:4,代码来源:RTMPMinaTransport.java


注:本文中的org.apache.mina.core.service.IoHandlerAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。