Package org.glassfish.grizzly.nio

Examples of org.glassfish.grizzly.nio.NIOConnection$ProcessorStatesMap$StaticMapAccessor


        this.listener = listener;
    }

    @Override
    public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
        final NIOConnection nioConnection = (NIOConnection) ctx.getConnection();
        final SelectableChannel channel = nioConnection.getChannel();
        if (targetInitializer == null) {
            synchronized (LOCK_OBJ) {
                if (targetInitializer == null) {
                    LazyServiceInitializer targetInitializerLocal = null;
                    for (final ActiveDescriptor<?> initializer : initializerImplList) {
                        String listenerName = listener.getName();
                        String serviceName = initializer.getName();
                        if (serviceName != null && listenerName.equalsIgnoreCase(serviceName)) {
                            targetInitializerLocal = (LazyServiceInitializer) locator.getServiceHandle(initializer).getService();
                            break;
                        }
                    }

                    if (targetInitializerLocal == null) {
                        logger.log(Level.SEVERE, "NO Lazy Initialiser implementation was found for port = {0}",
                                String.valueOf(listener.getPort()));
                        nioConnection.close();

                        return ctx.getStopAction();
                    }
                    if (!targetInitializerLocal.initializeService()) {
                        logger.log(Level.SEVERE, "Lazy Service initialization failed for port = {0}",
                                String.valueOf(listener.getPort()));

                        nioConnection.close();

                        return ctx.getStopAction();
                    }
                   
                    targetInitializer = targetInitializerLocal;
                }
            }
        }

        final NextAction nextAction = ctx.getSuspendAction();
        ctx.completeAndRecycle();

        // Deregister channel
        final SelectorRunner runner = nioConnection.getSelectorRunner();
        final SelectorHandler selectorHandler =
                ((NIOTransport) nioConnection.getTransport()).getSelectorHandler();

        selectorHandler.deregisterChannel(runner, channel);

        // Underlying service rely the channel is blocking
        channel.configureBlocking(true);
View Full Code Here


        this.listener = listener;
    }

    @Override
    public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
        final NIOConnection nioConnection = (NIOConnection) ctx.getConnection();
        final SelectableChannel channel = nioConnection.getChannel();
        if (targetInitializer == null) {
            synchronized (LOCK_OBJ) {
                if (targetInitializer == null) {
                    LazyServiceInitializer targetInitializerLocal = null;
                    for (final ServiceHandle<LazyServiceInitializer> initializer : initializerImplList) {
                        String listenerName = listener.getName();
                        String serviceName = initializer.getActiveDescriptor().getName();
                        if (serviceName != null && listenerName.equalsIgnoreCase(serviceName)) {
                            targetInitializerLocal = initializer.getService();
                            break;
                        }
                    }

                    if (targetInitializerLocal == null) {
                        logger.log(Level.SEVERE, "NO Lazy Initialiser implementation was found for port = {0}",
                                listener.getPort());
                        nioConnection.close();

                        return ctx.getStopAction();
                    }
                    if (!targetInitializerLocal.initializeService()) {
                        logger.log(Level.SEVERE, "Lazy Service initialization failed for port = {0}",
                                listener.getPort());

                        nioConnection.close();

                        return ctx.getStopAction();
                    }
                   
                    targetInitializer = targetInitializerLocal;
                }
            }
        }

        final NextAction nextAction = ctx.getSuspendAction();
        ctx.completeAndRecycle();

        // Deregister channel
        final SelectorRunner runner = nioConnection.getSelectorRunner();
        final SelectorHandler selectorHandler =
                ((NIOTransport) nioConnection.getTransport()).getSelectorHandler();

        selectorHandler.deregisterChannel(runner, channel);

        // Underlying service rely the channel is blocking
        channel.configureBlocking(true);
View Full Code Here

        final AsyncWriteQueueRecord nextRecord = writeTaskQueue.getQueue().poll();
        if (nextRecord == null) {
            return null;
        } else if (!canBeAggregated(nextRecord)) {
            final NIOConnection connection = (NIOConnection) nextRecord.getConnection();
            offerToTaskQueue(connection, nextRecord, writeTaskQueue);
            return null;
        }

        return nextRecord;
View Full Code Here

        }

        @Override
        public void onComplete(final Context context, final Object data)
                throws IOException {
            final NIOConnection connection = (NIOConnection) context.getConnection();

            if (completionHandler != null) {
                completionHandler.completed(connection);
            }

            if (!connection.isStandalone()) {
                connection.enableIOEvent(IOEvent.READ);
            }
        }
View Full Code Here

        ((UDPNIOConnection) connection).getAsyncReadQueue().offer(record);
    }

    @Override
    protected void onReadyToRead(Connection connection) throws IOException {
        final NIOConnection nioConnection = (NIOConnection) connection;
        nioConnection.enableIOEvent(IOEvent.READ);
    }
View Full Code Here

        ((TCPNIOConnection) connection).getAsyncReadQueue().offer(record);
    }

    @Override
    protected final void onReadyToRead(Connection connection) throws IOException {
        final NIOConnection nioConnection = (NIOConnection) connection;
        nioConnection.enableIOEvent(IOEvent.READ);
    }
View Full Code Here

        }
       
        @Override
        public void onComplete(final Context context, final Object data)
                throws IOException {
            final NIOConnection connection = (NIOConnection) context.getConnection();

            if (completionHandler != null) {
                completionHandler.completed(connection);
            }

            if (!connection.isStandalone()) {
                connection.enableIOEvent(IOEvent.READ);
            }
        }
View Full Code Here

            failure(new IllegalStateException("Connection should be NIOConnection and cannot be null"),
                    completionHandler);
            return;
        }

        final NIOConnection nioConnection = (NIOConnection) connection;
       
        final WriteResult<WritableMessage, SocketAddress> writeResult =
                WriteResult.create(connection,
                        message, dstAddress, 0);
View Full Code Here

                    "Connection should be NIOConnection and cannot be null"),
                    completionHandler);
            return;
        }

        final NIOConnection nioConnection = (NIOConnection) connection;
       
        final ReadResult<Buffer, SocketAddress> currentResult =
                ReadResult.create(connection, message, null, 0);

        try {
View Full Code Here

    @Override
    public boolean executeIoEvent(final Connection connection,
            final IOEvent ioEvent, final boolean isIoEventEnabled) throws IOException {

        final NIOConnection nioConnection = (NIOConnection) connection;
        IOEventLifeCycleListener listener = null;
        if (isReadWrite(ioEvent)) {
            if (isIoEventEnabled) {
                connection.disableIOEvent(ioEvent);
            }
           
            listener = ENABLE_INTEREST_LIFECYCLE_LISTENER;
        }

        final Executor threadPool = getThreadPoolFor(connection, ioEvent);
        if (threadPool != null) {
            final SelectorRunner runner = nioConnection.getSelectorRunner();
            runner.postpone();
            threadPool.execute(runner);
            fireIOEvent(connection, ioEvent, listener, logger);

            return false;
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.nio.NIOConnection$ProcessorStatesMap$StaticMapAccessor

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.