Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 package org.eclipse.jetty.continuation;
 
 import java.util.List;
 
 
 import  org.mortbay.log.Log;
 import  org.mortbay.log.Logger;
 
 /* ------------------------------------------------------------ */
This implementation of Continuation is used by ContinuationSupport when it detects that the application is deployed in a jetty-6 server. This continuation requires the ContinuationFilter to be deployed.
 
 {
     private static final Logger LOG = Log.getLogger(Jetty6Continuation.class.getName());
 
     // Exception reused for all continuations
     // Turn on debug in ContinuationFilter to see real stack trace.
     private final static ContinuationThrowable __exception = new ContinuationThrowable();
 
     private final ServletRequest _request;
     private ServletResponse _response;
     private final org.mortbay.util.ajax.Continuation _j6Continuation;
 
     private Throwable _retry;
     private int _timeout;
     private boolean _initial=true;
     private volatile boolean _completed=false;
     private volatile boolean _resumed=false;
     private volatile boolean _expired=false;
     private boolean _responseWrapped=false;
     private List<ContinuationListener_listeners;
 
     public Jetty6Continuation(ServletRequest request, org.mortbay.util.ajax.Continuation continuation)
     {
         if (!.)
         {
             .warn("!ContinuationFilter installed",null,null);
             throw new IllegalStateException("!ContinuationFilter installed");
         }
         =request;
         =continuation;
     }
 
     public void addContinuationListener(final ContinuationListener listener)
     {
         if (==null)
             =new ArrayList<ContinuationListener>();
         .add(listener);
     }
 
     public void complete()
     {
         synchronized(this)
         {
             if ()
                 throw new IllegalStateException();
             =true;
             if (.isPending())
                 .resume();
         }
     }
 
     /* ------------------------------------------------------------ */
    

See also:
org.eclipse.jetty.continuation.Continuation.getAttribute(java.lang.String)
 
     public Object getAttribute(String name)
     {
         return .getAttribute(name);
     }
 
     /* ------------------------------------------------------------ */
    

See also:
org.eclipse.jetty.continuation.Continuation.removeAttribute(java.lang.String)
    public void removeAttribute(String name)
    {
        .removeAttribute(name);
    }
    /* ------------------------------------------------------------ */
    

See also:
org.eclipse.jetty.continuation.Continuation.setAttribute(java.lang.String, java.lang.Object)
    public void setAttribute(String nameObject attribute)
    {
        .setAttribute(name,attribute);
    }
    /* ------------------------------------------------------------ */
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public boolean isExpired()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public boolean isInitial()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public boolean isResumed()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    public boolean isSuspended()
    {
        return !=null;
    }
    /* ------------------------------------------------------------ */
    public void resume()
    {
        synchronized(this)
        {
            if ()
                throw new IllegalStateException();
            =true;
            if (.isPending())
                .resume();
        }
    }
    /* ------------------------------------------------------------ */
    public void setTimeout(long timeoutMs)
    {
        =(timeoutMs>.)?.:(int)timeoutMs;
    }
    /* ------------------------------------------------------------ */
    

See also:
org.eclipse.jetty.continuation.Continuation.suspend(javax.servlet.ServletResponse)
    public void suspend(ServletResponse response)
    {
        try
        {
            =response;
            = instanceof ServletResponseWrapper;
            =false;
            =false;
            =false;
            .suspend();
        }
        catch(Throwable retry)
        {
            =retry;
        }
    }
    /* ------------------------------------------------------------ */
    public void suspend()
    {
        try
        {
            =null;
            =false;
            =false;
            =false;
            =false;
            .suspend();
        }
        catch(Throwable retry)
        {
            =retry;
        }
    }
    /* ------------------------------------------------------------ */
    public boolean isResponseWrapped()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

See also:
org.eclipse.jetty.continuation.Continuation.undispatch()
    public void undispatch()
    {
        if (isSuspended())
        {
            if (.)
                throw new ContinuationThrowable();
            throw ;
        }
        throw new IllegalStateException("!suspended");
    }
    /* ------------------------------------------------------------ */
    public boolean enter(ServletResponse response)
    {
        =response;
        =!.isResumed();
        if ()
            return true;
        .reset();
        if ()
        {
            if (!=null)
            {
                for (ContinuationListener l)
                    l.onTimeout(this);
            }
        }
        return !;
    }
    /* ------------------------------------------------------------ */
    public boolean exit()
    {
        =false;
        Throwable th=;
        =null;
        if (th instanceof Error)
            throw (Error)th;
        if (th instanceof RuntimeException)
            throw (RuntimeException)th;
        if (!=null)
        {
            for (ContinuationListener l)
                l.onComplete(this);
        }
        return true;
    }
New to GrepCode? Check out our FAQ X