Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Jeanfrancois Arcand
   *
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 package org.atmosphere.plugin.jaxrs;
 
 
 
 public class AtmosphereExecutionContext implements ExecutionContext {
 
     private final Logger logger = LoggerFactory.getLogger(AtmosphereExecutionContext.class);
     private final AtmosphereResourceImpl resource;
     private Object response;
     private TimeUnit unit;
     private long time = -1;
     private AtomicBoolean resumed = new AtomicBoolean(false);
 
         this. = r;
             @Override
             public void onResume(AtmosphereResourceEvent event) {
                 if (!.getAndSet(true)) {
                     try {
                         JerseyBroadcasterUtil.broadcast(,
                                 new AtmosphereResourceEventImpl(falsefalsenull).setMessage(),
                                 .getBroadcaster());
                     } catch (Throwable t) {
                         .trace(""t);
                         try {
                             .cancel();
                         } catch (IOException e) {
                             .trace(""t);
                         }
                     }
                 }
             }
         });
     }
 
     @Override
     public void resume(Object responsethrows IllegalStateException {
         JerseyBroadcasterUtil.broadcast(,
                 new AtmosphereResourceEventImpl(falsefalsenull).setMessage(response),
                 .getBroadcaster());
         .resume();
     }
 
     @Override
     public void resume(Exception responsethrows IllegalStateException {
         throw new IllegalStateException("Not supported");
     }
 
     @Override
     public void suspend() throws IllegalStateException {
         if (this. == null) {
             .suspend(-1, false);
         } else {
             .suspend(false);
         }
     }
 
     @Override
     public void suspend(long millisthrows IllegalStateException {
         if (this. == null) {
             .suspend(millis);
         } else {
             .suspend(false);
         }
     }
 
     @Override
     public void suspend(long timeTimeUnit unitthrows IllegalStateException {
         if (this. == null) {
             .suspend(timeunit);
         } else {
            .suspend(timeunitfalse);
        }
    }
    @Override
    public void setSuspendTimeout(long timeTimeUnit unitthrows IllegalStateException {
        this. = time;
        this. = unit;
    }
    @Override
    public void cancel() {
        try {
            .cancel();
        } catch (IOException e) {
            .debug(""e);
        }
    }
    @Override
    public boolean isSuspended() {
        return .isSuspended();
    }
    @Override
    public boolean isCancelled() {
        return .isCancelled();
    }
    @Override
    public boolean isDone() {
        return !isSuspended();
    }
    @Override
    public void setResponse(Object response) {
        this. = response;
    }
    @Override
    public Response getResponse() {
        return Response.ok().build();
    }
New to GrepCode? Check out our FAQ X