Examples of WriteHandler


Examples of com.cognitect.transit.WriteHandler

        emitArrayEnd();
    }

    protected void marshal(Object o, boolean asMapKey, WriteCache cache) throws Exception {

        WriteHandler h = getHandler(o);

        boolean supported = false;
        if(h != null) { // TODO: maybe remove getWriteHandler call and this check and just call tag
            String t = h.tag(o);
            if(t != null) {
                supported = true;
                if(t.length() == 1) {
                    switch(t.charAt(0)) {
                        case '_': emitNil(asMapKey, cache); break;
                        case 's': emitString(null, null, escape((String)h.rep(o)), asMapKey, cache); break;
                        case '?': emitBoolean((Boolean)h.rep(o), asMapKey, cache); break;
                        case 'i': emitInteger(h.rep(o), asMapKey, cache); break;
                        case 'd': emitDouble(h.rep(o), asMapKey, cache); break;
                        case 'b': emitBinary(h.rep(o), asMapKey, cache); break;
                        case '\'': emitTagged(t, h.rep(o), false, cache); break;
                        default: emitEncoded(t, h, o, asMapKey, cache); break;
                    }
                }
                else {
                    if(t.equals("array"))
                        emitArray(h.rep(o), asMapKey, cache);
                    else if(t.equals("map"))
                        emitMap(h.rep(o), asMapKey, cache);
                    else
                        emitEncoded(t, h, o, asMapKey, cache);
                }
                flushWriter();
            }
View Full Code Here

Examples of com.cognitect.transit.WriteHandler

            throw new Exception("Not supported: " + o.getClass());
    }

    protected void marshalTop(Object o, WriteCache cache) throws Exception {

        WriteHandler h = getHandler(o);
        if (h == null) {
            throw new Exception("Not supported: " + o);
        }
        String tag = h.tag(o);
        if (tag == null) {
            throw new Exception("Not supported: " + o);
        }

        if (tag.length() == 1)
View Full Code Here

Examples of com.cognitect.transit.WriteHandler

            return rep(o).toString();
        }

        @Override
        public WriteHandler getVerboseHandler() {
            return new WriteHandler() {
                @Override
                public String tag(Object ignored) {
                    return "t";
                }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

        @Override
        public boolean isValid() {
            if (!connection.canWrite()) {
                try {
                    connection.notifyCanWrite(new WriteHandler() {
                        @Override
                        public void onWritePossible() throws Exception {
                            taskProcessor.processTask();
                        }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

            // prepare context for suspend
            final NextAction suspendAction = ctx.getSuspendAction();
            ctx.suspend();

            // notify when connection becomes writable, so we can resume it
            output.notifyCanWrite(new WriteHandler() {
                @Override
                public void onWritePossible() throws Exception {
                    finish();
                }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

    /**
     * Notify WriteHandler
     */
    private void notifyWritePossible() {
        final WriteHandler localHandler = handler;

        if (localHandler != null) {
            final Reentrant reentrant = Reentrant.getWriteReentrant();
           
            try {
                handler = null;
                reentrant.inc();

                isNonBlockingWriteGuaranteed = true;

                localHandler.onWritePossible();
            } catch (Throwable t) {
                localHandler.onError(t);
            } finally {
                reentrant.dec();
            }
        }
    }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

            return;
        }
       
        final FutureImpl<Boolean> future = Futures.createSafeFuture();
       
        httpContext.getOutputSink().notifyCanWrite(new WriteHandler() {

            @Override
            public void onWritePossible() throws Exception {
                future.result(Boolean.TRUE);
            }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

            } catch (Exception ignored) {
            }
        }

        private static void onError0(final OutputBuffer ob, final Throwable t) {
            final WriteHandler localHandler = ob.handler;

            if (localHandler != null) {
                try {
                    ob.handler = null;
                    localHandler.onError(t);
                } catch (Exception ignored) {
                }
            }
        }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

        }
       
        final int maxQueueSize = maxQueueSizeHolder.getMaxQueueSize();
       
        while(spaceInBytes() <= maxQueueSize) {
            WriteHandler writeHandler = pollWriteHandler();
            if (writeHandler == null) {
                return;
            }
           
            try {
                writeHandler.onWritePossible();
            } catch (Throwable e) {
                writeHandler.onError(e);
            }
        }
    }
View Full Code Here

Examples of org.glassfish.grizzly.WriteHandler

            while ((record = poll()) != null) {
                record.notifyFailure(error);
            }
        }
       
        WriteHandler writeHandler;
        while ((writeHandler = pollWriteHandler()) != null) {
            if (error == null) {
                error = new IOException("Connection closed", cause);
            }
            writeHandler.onError(error);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.