public ScriptSession get() { WebContext webcx = WebContextFactory.get(); return webcx.getScriptSession(); }
@Override public ScriptSession get() { return WebContextFactory.get().getScriptSession(); }
/** * Create a Callback from a DWR thread, * i.e. where {@link WebContextFactory#get()} =! null */ public Callback() { WebContext context = WebContextFactory.get(); if (context == null) { throw new IllegalStateException("Attempt to use Callback without any ScriptSessions, from a non DWR thread. There is nowhere for replies to go."); } sessions.add(context.getScriptSession()); }
/** * Call {@link ScriptSession#invalidate()} on the {@link ScriptSession} * that called this method. * Used by the page unloader. */ public void pageUnloaded() { WebContext wctx = WebContextFactory.get(); ScriptSession scriptSession = wctx.getScriptSession(); log.debug("pageUnloaded is invalidating scriptSession: " + scriptSession); scriptSession.invalidate(); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); DefaultJavascriptObject object = new DefaultJavascriptObject(session, id); return Proxy.newProxyInstance(paramType.getClassLoader(), new Class[] { paramType }, object); }
/** * This method discovers the sessions that are currently being targeted * by browser updates. * <p> * It will generally only be useful to authors of reverse ajax UI proxy * APIs. Using it directly may cause scaling problems * @return The list of current browser windows. */ public static Collection<ScriptSession> getTargetSessions() { TaskDispatcher taskDispatcher = TaskDispatcherFactory.get(getServerContext()); Collection<ScriptSession> sessions = taskDispatcher.getTargetSessions(); if (sessions != null) { return sessions; } WebContext webContext = WebContextFactory.get(); if (webContext != null) { sessions = new ArrayList<ScriptSession>(); sessions.add(webContext.getScriptSession()); return sessions; } throw new IllegalStateException("No current UI to manipulate. See org.directwebremoting.Browser to set one."); }
/** * Stop notifications of against a subscription id * @param subscriptionId The ID to pass back to link to client side data * @return true iff someone was unsubscribed */ @SuppressWarnings("unchecked") public boolean unsubscribe(String subscriptionId) { WebContext webContext = WebContextFactory.get(); Hub hub = HubFactory.get(); ScriptSession session = webContext.getScriptSession(); Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS); BrowserMessageListener subscription = subscriptions.get(subscriptionId); return hub.unsubscribe(subscription.topic, subscription); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); return new DefaultJavascriptObject(session, id); }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } ScriptSession session = WebContextFactory.get().getScriptSession(); String id = data.getValue(); return new DefaultJavascriptFunction(session, id); }
object = webcx.getScriptSession().getAttribute(name); webcx.getScriptSession().setAttribute(name, object);
/** * Internal method to find or create a StoreProvider for a given user. */ @Override protected StoreProvider<T> getStoreProvider() { ScriptSession session = WebContextFactory.get().getScriptSession(); @SuppressWarnings("unchecked") StoreProvider<T> storeProvider = (StoreProvider<T>) session.getAttribute(attributeName); if (storeProvider == null) { storeProvider = factory.create(session); session.setAttribute(attributeName, storeProvider); } return storeProvider; }
private void initScriptSession() { WebContext webContext = WebContextFactory.get(); HttpServletRequest request = webContext.getHttpServletRequest(); ScriptSession currentSession = webContext.getScriptSession(); String host = request.getServerName(); RiotUser user = AccessController.getCurrentUser(); currentSession.setAttribute("host", host); currentSession.setAttribute("userId", user.getUserId()); }
/** * Ensure that the clients know about server publishes * @param topic The topic being subscribed to * @param subscriptionId The ID to pass back to link to client side data */ @SuppressWarnings("unchecked") public void subscribe(String topic, String subscriptionId) { WebContext webContext = WebContextFactory.get(); Hub hub = HubFactory.get(); final ScriptSession session = webContext.getScriptSession(); // Create a subscription block BrowserMessageListener subscription = new BrowserMessageListener(session, topic, subscriptionId); Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS); if (subscriptions == null) { subscriptions = new HashMap<String, BrowserMessageListener>(); } subscriptions.put(subscriptionId, subscription); session.setAttribute(ATTRIBUTE_SUBSCRIPTIONS, subscriptions); hub.subscribe(subscription.topic, subscription); }
public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception { ScriptSession session = WebContextFactory.get().getScriptSession(); Long lastAccess = (Long) session.getAttribute(ATTRIBUTE_LAST_ACTION); // Free pass in if you've not done anything so far. if (lastAccess != null) { long now = System.currentTimeMillis(); if (now > lastAccess + actionTimeoutMillis) { session.addScript(new ScriptBuffer(onTimeout)); session.invalidate(); throw new DwrConvertedException("Your session has timed out"); } } Object reply = chain.doFilter(obj, method, params); session.setAttribute(ATTRIBUTE_LAST_ACTION, System.currentTimeMillis()); return reply; }
HttpServletRequest request = webContext.getHttpServletRequest(); final ScriptSession currentSession = webContext.getScriptSession(); final RiotUser user = AccessController.getCurrentUser(); final String host = request.getServerName();
RealScriptSession scriptSession = (RealScriptSession) webCtx.getScriptSession(); HttpSession httpSession = webCtx.getSession(false); String httpSessionId = (httpSession != null ? httpSession.getId() : null);
ScriptSession session = webContext.getScriptSession(); ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class);
try scriptSession = (RealScriptSession) WebContextFactory.get().getScriptSession();