Examples of ReactorMtImpl


Examples of org.agilewiki.jactor2.core.impl.mtReactors.ReactorMtImpl

     */
    @SuppressWarnings("unchecked")
    @Override
    public void doSend(final ReactorImpl _source,
            final AsyncResponseProcessor<RESPONSE_TYPE> _responseProcessor) {
        final ReactorMtImpl source = (ReactorMtImpl) _source;
        if (PlantMtImpl.DEBUG
                && (source.getThreadReference().get() != Thread.currentThread())) {
            throw new IllegalStateException("send from wrong thread");
        }
        use();
        responseProcessor = _responseProcessor;
        if (responseProcessor == null) {
            responseProcessor = (AsyncResponseProcessor<RESPONSE_TYPE>) OneWayResponseProcessor.SINGLETON;
        }
        requestSource = source;
        if (!source.isRunning()) {
            throw new IllegalStateException(
                    "A valid source sourceReactor can not be idle");
        }
        oldMessage = source.getCurrentRequest();
        if ((oldMessage != null) && oldMessage.getIsolationReactor() != null) {
            isolationReactor = oldMessage.getIsolationReactor();
        } else
            isolationReactor = source.isCommonReactor() ? null : (IsolationReactor) source.asReactor();
        if (!(targetReactor instanceof CommonReactor)) {
            if (isolationReactor != null && isolationReactor != targetReactor && (_responseProcessor != null)) {
                throw new UnsupportedOperationException(
                        "Isolated requests can not be nested, even indirectly:\n" + toString());
            }
            isolationReactor = (IsolationReactor) targetReactor;
        }
        sourceExceptionHandler = (ExceptionHandler<RESPONSE_TYPE>) source
                .getExceptionHandler();
        final boolean local = targetReactor == source.asReactor();
        if (local || !source.buffer(this, targetReactorImpl)) {
            targetReactorImpl.unbufferedAddMessage(this, local);
        }
    }
View Full Code Here

Examples of org.agilewiki.jactor2.core.impl.mtReactors.ReactorMtImpl

     * Process a response.
     */
    @SuppressWarnings("unchecked")
    protected void processResponseMessage() {
        oldMessage.responseReceived(this);
        final ReactorMtImpl sourceMessageProcessor = (ReactorMtImpl) requestSource;
        sourceMessageProcessor.setExceptionHandler(sourceExceptionHandler);
        sourceMessageProcessor.setCurrentRequest(oldMessage);
        if (response instanceof Exception) {
            oldMessage.processException(sourceMessageProcessor,
                    (Exception) response);
            oldMessage.responseProcessed();
            return;
View Full Code Here

Examples of org.agilewiki.jactor2.core.impl.mtReactors.ReactorMtImpl

     * @param _activeReactor The reactor providing the facility for processing the throwable.
     * @param _e             The exception to be processed.
     */
    public void processException(final ReactorMtImpl _activeReactor,
            final Exception _e) {
        final ReactorMtImpl activeMessageProcessor = _activeReactor;
        @SuppressWarnings("unchecked")
        final ExceptionHandler<RESPONSE_TYPE> exceptionHandler = (ExceptionHandler<RESPONSE_TYPE>) activeMessageProcessor
                .getExceptionHandler();
        if (exceptionHandler != null) {
            try {
                exceptionHandler.processException(_e,
                        new AsyncResponseProcessor<RESPONSE_TYPE>() {
                            @Override
                            public void processAsyncResponse(
                                    final Object _response) {
                                processObjectResponse(_response);
                            }
                        });
            } catch (final Throwable u) {
                if (!isOneWay()) {
                    if (!incomplete) {
                        return;
                    }
                    setResponse(u, activeMessageProcessor);
                    requestSource
                            .incomingResponse(this, activeMessageProcessor);
                } else {
                    activeMessageProcessor
                            .error("Thrown by exception handler and uncaught "
                                    + exceptionHandler.getClass().getName(), _e);
                }
            }
        } else {
            if (!incomplete) {
                return;
            }
            setResponse(_e, activeMessageProcessor);
            if (!isOneWay()) {
                requestSource.incomingResponse(this, activeMessageProcessor);
            } else {
                activeMessageProcessor.warn("Uncaught throwable", _e);
            }
        }
    }
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.