Package org.apache.cxf.continuations

Examples of org.apache.cxf.continuations.Continuation


        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

    @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

        throw new UnsupportedOperationException();
    }
   
    public String greetMe(String name) {
       
        Continuation continuation = getContinuation(name);
        if (continuation == null) {
            throw new RuntimeException("Failed to get continuation");
        }
        synchronized (continuation) {
            if (continuation.isNew()) {
                if (suspended) {
                    throw new RuntimeException("Was already suspended");
                }
                Object userObject = "Fred".equals(name) ? "Ruby" : null;
                continuation.setObject(userObject);
                suspended = true;
                continuation.suspend(2000);
            } else {
                if (!suspended) {
                    throw new RuntimeException("Was not suspended yet");
                }
                if (continuation.isResumed()) {
                    throw new RuntimeException("It must be a timeout");
                }
                StringBuilder sb = new StringBuilder();
                sb.append(name);
               
                Object userObject = continuation.getObject();
                if (userObject != null) {
                    sb.append(' ').append(userObject.toString());
                }
                System.out.println("Saying hi to " + sb.toString());
                return "Hi " + sb.toString();
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 RMException if message had already been acknowledged
     */
    boolean applyDeliveryAssurance(long mn, Message message) throws RMException {
        Continuation cont = getContinuation(message);
        DeliveryAssuranceType da = destination.getManager().getDeliveryAssurance();
        boolean canSkip = !da.isSetAtLeastOnce() && !da.isSetExactlyOnce();
        boolean robust = false;
        boolean robustDelivering = false;
        if (message != null) {
            robust = MessageUtils.isTrue(message.getContextualProperty(Message.ROBUST_ONEWAY));
            if (robust) {
                robustDelivering =
                    MessageUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY));
            }
        }
        if (robust && !robustDelivering) {
            // no check performed if in robust and not in delivering
            removeDeliveringMessageNumber(mn);
            return true;
        }
        if (cont != null && da.isSetInOrder() && !cont.isNew()) {
            return waitInQueue(mn, canSkip, message, cont);
        }
        if ((da.isSetExactlyOnce() || da.isSetAtMostOnce())
            && (isAcknowledged(mn)
                || (robustDelivering && deliveringMessageNumbers.contains(mn)))) {           
View Full Code Here

            }
        }
    }
    synchronized void wakeupAll() {
        while (!continuations.isEmpty()) {
            Continuation c = continuations.remove(0);
            c.resume();
        }
        notifyAll();
    }
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(long mn, Message message) throws RMException {
        Continuation cont = getContinuation(message);
        DeliveryAssuranceType da = destination.getManager().getDeliveryAssurance();
        boolean robust = false;
        boolean robustDelivering = false;
        if (message != null) {
            robust = MessageUtils.isTrue(message.getContextualProperty(Message.ROBUST_ONEWAY));
            if (robust) {
                robustDelivering =
                    MessageUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY));
            }
        }
        if (robust && !robustDelivering) {
            // no check performed if in robust and not in delivering
            removeDeliveringMessageNumber(mn);
            return true;
        }
        if (cont != null && da.isSetInOrder() && !cont.isNew()) {
            return waitInQueue(mn, !(da.isSetAtLeastOnce() || da.isSetExactlyOnce()),
                               message, cont);
        }
        if ((da.isSetExactlyOnce() || da.isSetAtMostOnce())
            && (isAcknowledged(mn)
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.