Various functions exported by DWR to help us with various book-keeping duties. @author Joe Walker [joe at getahead dot ltd dot uk]
| 43 | * @author Joe Walker [joe at getahead dot ltd dot uk] |
| 44 | */ |
| 45 | public class System |
| 46 | { |
| 47 | /** |
| 48 | * Generates and returns a new unique id suitable to use for the |
| 49 | * CSRF session cookie. This method is itself exempted from CSRF checking. |
| 50 | */ |
| 51 | public String generateId() |
| 52 | { |
| 53 | WebContext webContext = WebContextFactory.get(); |
| 54 | |
| 55 | // If the current session already has a set DWRSESSIONID then we return that |
| 56 | HttpServletRequest request = webContext.getHttpServletRequest(); |
| 57 | HttpSession sess = request.getSession(false); |
| 58 | if (sess != null && sess.getAttribute(ATTRIBUTE_DWRSESSIONID) != null) |
| 59 | { |
| 60 | return (String) sess.getAttribute(ATTRIBUTE_DWRSESSIONID); |
| 61 | } |
| 62 | |
| 63 | // Otherwise generate a fresh ID |
| 64 | IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class); |
| 65 | return idGenerator.generate(); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * A method designed to be called on page load so the client knows about |
| 70 | * the http and script sessions. This method doesn't actually do anything |
| 71 | * however it does allow DWR's script session checking code to work |
| 72 | */ |
| 73 | public void pageLoaded() |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * A method designed to be called when the client is offline. |
| 79 | * When the server is back online this method will return immediately |
| 80 | * so reverse AJAX polling may resume. |
| 81 | */ |
| 82 | public void checkHeartbeat() |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Call {@link ScriptSession#invalidate()} on the {@link ScriptSession} |
| 88 | * that called this method. |
| 89 | * Used by the page unloader. |
| 90 | */ |
| 91 | public void pageUnloaded() |
| 92 | { |
| 93 | WebContext wctx = WebContextFactory.get(); |
| 94 | ScriptSession scriptSession = wctx.getScriptSession(); |
| 95 | |
| 96 | log.debug("pageUnloaded is invalidating scriptSession: " + scriptSession); |
| 97 | scriptSession.invalidate(); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Used by reverse ajax proxies to send data back to the server |
| 102 | * @param key The unique id under which a callback is registered |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…