FileDocCategorySizeDatePackage
RailAsyncFilter.javaAPI DocGlassfish v2 API2892Thu Jun 21 14:52:16 BST 2007com.sun.grizzly.rails

RailAsyncFilter

public class RailAsyncFilter extends Object implements com.sun.enterprise.web.connector.grizzly.AsyncFilter
AyncFilter that park the request if the number of Ruby runtime are all in use.
author
Jeanfrancois Arcand

Fields Summary
private BlockingQueue
rubyRuntimeQueue
private LinkedBlockingQueue
parkedRequest
Constructors Summary
public RailAsyncFilter()

    
      
    
Methods Summary
public booleandoFilter(com.sun.enterprise.web.connector.grizzly.AsyncExecutor asyncExecutor)

        AsyncProcessorTask apt = (AsyncProcessorTask)asyncExecutor.getAsyncTask();
        
        if (rubyRuntimeQueue.size() == 0){
            parkedRequest.offer(apt);
            return false;
        } else {
            try{
                apt.getProcessorTask().invokeAdapter();
            } catch (IllegalStateException ex){
                parkedRequest.offer(apt);
                return false;
            }
            apt.setStage(AsyncTask.POST_EXECUTE);
            return true;
        }        
    
protected voidsetRubyRuntimeQueue(java.util.concurrent.BlockingQueue rubyRuntimeQueue)

        this.rubyRuntimeQueue = rubyRuntimeQueue;        
    
protected voidunpark()

        
        AsyncProcessorTask apt = parkedRequest.poll();
        if (apt == null) return;
        
        apt.setStage(AsyncTask.EXECUTE);
        try{
            apt.doTask();
        } catch (IllegalStateException e) {
            // Runtime was zero, add the token back to the queue.
             parkedRequest.offer(apt);
        } catch (IOException ex){
            ; //
        }