Package org.apache.cxf.continuations

Examples of org.apache.cxf.continuations.Continuation


            }
        }
    }
    synchronized void wakeupAll() {
        while (!continuations.isEmpty()) {
            Continuation c = continuations.remove(0);
            c.resume();
        }
        notifyAll();
    }
View Full Code Here


                    JaxwsServerHandler handler = new JaxwsServerHandler(null);
                    ex.put(JaxwsServerHandler.class, handler);
                    params.add(handler);
                    return ret;
                } else if (cp != null && cp.getContinuation() != null) {
                    final Continuation c = cp.getContinuation();
                    c.suspend(0);
                    JaxwsServerHandler handler = new JaxwsServerHandler(c);
                    ex.put(JaxwsServerHandler.class, handler);
                    params.add(handler);
                    return ret;
                }
View Full Code Here

        Message m = new MessageImpl();
        m.setExchange(new ExchangeImpl());
        Counter counter = EasyMock.createMock(Counter.class);
        JMSContinuationProvider provider =
            new JMSContinuationProvider(bus, m, null, counter);
        Continuation cw = provider.getContinuation();
        assertTrue(cw.isNew());
        assertSame(cw, m.get(JMSContinuation.class));
    }
View Full Code Here

        svrBean.setInvoker(new Invoker() {

            // we receive a CXF request when this method is called
            public Object invoke(Exchange cxfExchange, Object o) {
                LOG.trace("Received CXF Request: {}", cxfExchange);               
                Continuation continuation;
                if (!endpoint.isSynchronous() && isAsyncInvocationSupported(cxfExchange)
                    && (continuation = getContinuation(cxfExchange)) != null) {
                    LOG.trace("Calling the Camel async processors.");
                    return asyncInvoke(cxfExchange, continuation);
                } else {
                    LOG.trace("Calling the Camel sync processors.");
                    return syncInvoke(cxfExchange);
                }
            }           
           
            // NOTE this code cannot work with CXF 2.2.x
            private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation) {
                synchronized (continuation) {
                    if (continuation.isNew()) {
                        final org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);
                       
                        // Now we don't set up the timeout value
                        LOG.trace("Suspending continuation of exchangeId: {}", camelExchange.getExchangeId());
                        // TODO Support to set the timeout in case the Camel can't send the response back on time.
                        // The continuation could be called before the suspend is called
                        continuation.suspend(0);

                        // use the asynchronous API to process the exchange
                        getAsyncProcessor().process(camelExchange, new AsyncCallback() {
                            public void done(boolean doneSync) {
                                // make sure the continuation resume will not be called before the suspend method in other thread
                                synchronized (continuation) {
                                    LOG.trace("Resuming continuation of exchangeId: {}", camelExchange.getExchangeId());
                                    // resume processing after both, sync and async callbacks
                                    continuation.setObject(camelExchange);
                                    continuation.resume();
                                }
                            }
                        });
                       
                    } else if (continuation.isResumed()) {
                        org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation
                            .getObject();
                        setResponseBack(cxfExchange, camelExchange);

                    }
                }
View Full Code Here

    @Resource
    private WebServiceContext context;
   
    public String sayHi(String firstName, String secondName) {
       
        Continuation continuation = getContinuation(firstName);
        if (continuation == null) {
            throw new RuntimeException("Failed to get continuation");
        }
        synchronized (continuation) {
            if (continuation.isNew()) {
                Object userObject = secondName != null && secondName.length() > 0
                                    ? secondName : null;
                continuation.setObject(userObject);
                suspendInvocation(firstName, continuation);
            } else {
                if (!continuation.isResumed() && !"Fred".equals(firstName)) {
                    throw new RuntimeException("No timeout expected");
                }
                StringBuilder sb = new StringBuilder();
                sb.append(firstName);
               
                // if the actual parameter is not null
                if (secondName != null && secondName.length() > 0) {
                    String surname = continuation.getObject().toString();
                    sb.append(' ').append(surname);
                }
                //System.out.println("Saying hi to " + sb.toString());
                return "Hi " + sb.toString();
            }
View Full Code Here

        return true;
    }

    public void resumeRequest(final String name) {
       
        Continuation suspendedCont = null;
        synchronized (suspended) {
            suspendedCont = suspended.get(name);
        }
       
        if (suspendedCont != null) {
            synchronized (suspendedCont) {
                suspendedCont.resume();
            }
        }
    }
View Full Code Here

    private Continuation getContinuation(String name) {
       
        //System.out.println("Getting continuation for " + name);
       
        synchronized (suspended) {
            Continuation suspendedCont = suspended.remove(name);
            if (suspendedCont != null) {
                return suspendedCont;
            }
        }
       
View Full Code Here

            // we receive a CXF request when this method is called
            public Object invoke(Exchange cxfExchange, Object o) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Received CXF Request: " + cxfExchange);
                }               
                Continuation continuation;
                if (!endpoint.isSynchronous() && (continuation = getContinuation(cxfExchange)) != null) {
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Calling the Camel async processors.");
                    }
                    return asyncInvoke(cxfExchange, continuation);
                } else {
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Calling the Camel sync processors.");
                    }
                    return syncInvoke(cxfExchange);
                }
            }           
           
            // NOTE this code cannot work with CXF 2.2.x
            private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation) {
                synchronized (continuation) {
                    if (continuation.isNew()) {
                        final org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);
                       
                        // Now we don't set up the timeout value
                        if (LOG.isTraceEnabled()) {
                            LOG.trace("Suspending continuation of exchangeId: " + camelExchange.getExchangeId());
                        }
                        // TODO Support to set the timeout in case the Camel can't send the response back on time.
                        // The continuation could be called before the suspend is called
                        continuation.suspend(0);

                        // use the asynchronous API to process the exchange
                        getAsyncProcessor().process(camelExchange, new AsyncCallback() {
                            public void done(boolean doneSync) {
                                // make sure the continuation resume will not be called before the suspend method in other thread
                                synchronized (continuation) {
                                    if (LOG.isTraceEnabled()) {
                                        LOG.trace("Resuming continuation of exchangeId: "
                                                  + camelExchange.getExchangeId());
                                    }
                                    // resume processing after both, sync and async callbacks
                                    continuation.setObject(camelExchange);
                                    continuation.resume();
                                }
                            }
                        });
                       
                    } else if (continuation.isResumed()) {
                        org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation
                            .getObject();
                        setResponseBack(cxfExchange, camelExchange);

                    }
                }
View Full Code Here

     * @param mn message number
     * @return <code>true</code> if message processing to continue, <code>false</code> if to be dropped
     * @throws Fault if message had already been acknowledged
     */
    boolean applyDeliveryAssurance(BigInteger mn, Message message) throws RMException {
        Continuation cont = getContinuation(message);
        DeliveryAssuranceType da = destination.getManager().getDeliveryAssurance();
        if (cont != null && da.isSetInOrder() && !cont.isNew()) {
            return waitInQueue(mn, !(da.isSetAtLeastOnce() || da.isSetExactlyOnce()),
                               message, cont);
        }
        if ((da.isSetExactlyOnce() || da.isSetAtMostOnce()) && isAcknowledged(mn)) {           
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
View Full Code Here

            }
        }
    }
    synchronized void wakeupAll() {
        while (!continuations.isEmpty()) {
            Continuation c = continuations.remove(0);
            c.resume();
        }
        notifyAll();
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.continuations.Continuation

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.