/** * @return {@link Application} bound to current thread */ public static Application getApplication() { ThreadContext context = get(false); return context != null ? context.application : null; }
@Override public Object deserialize(final byte[] data) ThreadContext old = ThreadContext.get(false); final ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois = null;
@Override public Object deserialize(final byte[] data) ThreadContext old = ThreadContext.get(false); final ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois = null;
/** * @return {@link Session} bound to current thread */ public static Session getSession() { ThreadContext context = get(false); return context != null ? context.session : null; }
/** * Binds the {@link RequestCycle} to current thread. * * @param requestCycle */ public static void setRequestCycle(RequestCycle requestCycle) { ThreadContext context = get(true); context.requestCycle = requestCycle; }
/** * Binds the session to current thread. * * @param session */ public static void setSession(Session session) { ThreadContext context = get(true); context.session = session; }
/** * @return {@link RequestCycle} bound to current thrad */ public static RequestCycle getRequestCycle() { ThreadContext context = get(false); return context != null ? context.requestCycle : null; }
/** * @return {@link Session} bound to current thread */ public static Session getSession() { ThreadContext context = get(false); return context != null ? context.session : null; }
/** * Checks if {@link ThreadContext} exists for the current thread * * @return {@code true} if {@link ThreadContext} exists for the current thread */ public static boolean exists() { return get(false) != null; }
/** * Binds the session to current thread. * * @param session */ public static void setSession(Session session) { ThreadContext context = get(true); context.session = session; }
/** * Checks if {@link ThreadContext} exists for the current thread * * @return {@code true} if {@link ThreadContext} exists for the current thread */ public static boolean exists() { return get(false) != null; }
/** * Binds the specified application to current thread. * * @param application */ public static void setApplication(Application application) { ThreadContext context = get(true); context.application = application; }
/** * @return {@link Application} bound to current thread */ public static Application getApplication() { ThreadContext context = get(false); return context != null ? context.application : null; }
/** * Binds the specified application to current thread. * * @param application */ public static void setApplication(Application application) { ThreadContext context = get(true); context.application = application; }
/** * @return {@link RequestCycle} bound to current thrad */ public static RequestCycle getRequestCycle() { ThreadContext context = get(false); return context != null ? context.requestCycle : null; }
/** * Binds the {@link RequestCycle} to current thread. * * @param requestCycle */ public static void setRequestCycle(RequestCycle requestCycle) { ThreadContext context = get(true); context.requestCycle = requestCycle; }
/** * Post an event to a single resource. This will invoke the event handlers on all components on * the page with the suspended connection. The resulting AJAX update (if any) is pushed to the * client. * * @param event * @param resource */ public void post(Object event, AtmosphereResource resource) { ThreadContext oldContext = ThreadContext.get(false); try { postToSingleResource(event, resource); } finally { ThreadContext.restore(oldContext); } }
/** * Post an event to a single resource. This will invoke the event handlers on all components on * the page with the suspended connection. The resulting AJAX update (if any) is pushed to the * client. * * @param event * @param resource */ public void post(Object event, AtmosphereResource resource) { ThreadContext oldContext = ThreadContext.get(false); try { postToSingleResource(event, resource); } finally { ThreadContext.restore(oldContext); } }
/** * Post an event to all pages that have a suspended connection. This will invoke the event * handlers on components, annotated with {@link Subscribe}. The resulting AJAX updates are * pushed to the clients. * * @param event */ public void post(Object event) { ThreadContext oldContext = ThreadContext.get(false); try { for (AtmosphereResource resource : ImmutableList.copyOf(getBroadcaster().getAtmosphereResources())) { postToSingleResource(event, resource); } } finally { ThreadContext.restore(oldContext); } }
/** * Post an event to all pages that have a suspended connection. This will invoke the event * handlers on components, annotated with {@link Subscribe}. The resulting AJAX updates are * pushed to the clients. * * @param event */ public void post(Object event) { ThreadContext oldContext = ThreadContext.get(false); try { for (AtmosphereResource resource : broadcaster.getAtmosphereResources()) { postToSingleResource(event, resource); } } finally { ThreadContext.restore(oldContext); } }