Package org.apache.mina.common

Examples of org.apache.mina.common.IoSession


    @Override
    public List<Runnable> shutdownNow() {
        shutdown();

        List<Runnable> answer = new ArrayList<Runnable>();
        IoSession session;
        while ((session = waitingSessions.poll()) != null) {
            if (session == EXIT_SIGNAL) {
                waitingSessions.offer(EXIT_SIGNAL);
                Thread.yield(); // Let others take the signal.
                continue;
            }

            SessionBuffer buf = (SessionBuffer) session.getAttribute(BUFFER);
            synchronized (buf.queue) {
                for (Runnable task: buf.queue) {
                    getQueueHandler().polled(this, (IoEvent) task);
                    answer.add(task);
                }
View Full Code Here


        }

        checkTaskType(task);

        IoEvent e = (IoEvent) task;
        IoSession s = e.getSession();
        SessionBuffer buf = getSessionBuffer(s);
        Queue<Runnable> queue = buf.queue;
        boolean offerSession;
        boolean offerEvent = queueHandler.accept(this, e);
        if (offerEvent) {
View Full Code Here

    @Override
    public boolean remove(Runnable task) {
        checkTaskType(task);
        IoEvent e = (IoEvent) task;
        IoSession s = e.getSession();
        SessionBuffer buffer = (SessionBuffer) s.getAttribute(BUFFER);
        if (buffer == null) {
            return false;
        }

        boolean removed;
View Full Code Here

        public void run() {
            thread = Thread.currentThread();

            try {
                for (;;) {
                    IoSession session = fetchSession();

                    idleWorkers.decrementAndGet();

                    if (session == null) {
                        synchronized (workers) {
View Full Code Here

                }
            }
        }

        private IoSession fetchSession() {
            IoSession session = null;
            long currentTime = System.currentTimeMillis();
            long deadline = currentTime + getKeepAliveTime(TimeUnit.MILLISECONDS);
            for (;;) {
                try {
                    long waitTime = deadline - currentTime;
View Full Code Here

        {
            SocketAddress element = ( SocketAddress ) iter.next();

            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext(); )
            {
                IoSession session = ( IoSession ) iter2.next();
                session.close();
            }
        }

    }
View Full Code Here

*/
public class ObjectSerializationTest extends TestCase {
    public void testEncoder() throws Exception {
        final String expected = "1234";

        IoSession session = new MockIoSession();
        SimpleProtocolEncoderOutput out = new SimpleProtocolEncoderOutput() {
            protected WriteFuture doFlush(ByteBuffer buf) {
                return null;
            }
        };
View Full Code Here

        assertEquals(expected, actual);

        // Test ProtocolDecoder
        ProtocolDecoder decoder = new ObjectSerializationDecoder();
        MockProtocolDecoderOutput decoderOut = new MockProtocolDecoderOutput();
        IoSession session = new MockIoSession();
        decoder.decode(session, in.duplicate(), decoderOut);

        Assert.assertEquals(expected, decoderOut.result.get(0));
        Assert.assertEquals(1, decoderOut.result.size());
    }
View Full Code Here

    }

    public void testEncode() throws Exception {
        TextLineEncoder encoder = new TextLineEncoder(Charset.forName("UTF-8"),
                LineDelimiter.WINDOWS);
        IoSession session = new DummySession();
        SimpleProtocolEncoderOutput out = new SimpleProtocolEncoderOutput() {
            @Override
            protected WriteFuture doFlush(ByteBuffer buf) {
                return null;
            }
View Full Code Here

        assertNull(future.getSession());

        TestThread thread = new TestThread(future);
        thread.start();

        IoSession session = new BaseIoSession() {
            public IoHandler getHandler() {
                return null;
            }

            public IoFilterChain getFilterChain() {
View Full Code Here

TOP

Related Classes of org.apache.mina.common.IoSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.