@Suspend @GET public String suspend() { return ""; }
long suspendTimeout = am.getAnnotation(Suspend.class).period(); TimeUnit tu = am.getAnnotation(Suspend.class).timeUnit(); suspendTimeout = translateTimeUnit(suspendTimeout, tu); Suspend.SCOPE scope = am.getAnnotation(Suspend.class).scope(); if (am.getAnnotation(Suspend.class).resumeOnBroadcast()) { f = new Filter(Action.SUSPEND_RESUME, suspendTimeout, null, null, am.getAnnotation(Suspend.class).writeEntity(), am.getAnnotation(Suspend.class).contentType()); } else { f = new Filter(Action.SUSPEND, null, null, am.getAnnotation(Suspend.class).writeEntity(), am.getAnnotation(Suspend.class).contentType()); f.setListeners(am.getAnnotation(Suspend.class).listeners());
@Suspend(contentType = MediaType.APPLICATION_JSON) @GET public String suspend(@Context AtmosphereResource resource) { resource.setBroadcaster(BroadcastHelper.getTradeBroadcaster()); return ""; } }
/** * Open a long poll channel for the given cluster controller. * The channel is closed automatically by the server at * regular intervals to ensure liveliness. * * @param ccid cluster controller id * @param cacheIndex cache index * @param atmosphereTrackingId the tracking for atmosphere * @return new message(s), or nothing if the channel is closed by the servr */ @GET @Path("/{ccid: [A-Z,a-z,0-9,_,\\-,\\.]+}") @Produces({ MediaType.APPLICATION_JSON }) @Suspend(resumeOnBroadcast = true, period = ChannelServiceConstants.EXPIRE_TIME_CONNECTION, timeUnit = TimeUnit.SECONDS, contentType = MediaType.APPLICATION_JSON) public Broadcastable open(@PathParam("ccid") String ccid, @HeaderParam("X-Cache-Index") Integer cacheIndex, @HeaderParam(ChannelServiceConstants.X_ATMOSPHERE_TRACKING_ID) String atmosphereTrackingId) { try { return channelService.openChannel(ccid, cacheIndex, atmosphereTrackingId); } catch (WebApplicationException e) { throw e; } catch (Exception e) { log.error("GET Channels open long poll ccid: error: {}", e.getMessage(), e); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }