Java Code Examples for io.undertow.servlet.handlers.ServletRequestContext#current()
The following examples show how to use
io.undertow.servlet.handlers.ServletRequestContext#current() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpSessionImpl.java From quarkus-http with Apache License 2.0 | 6 votes |
public static HttpSessionImpl forSession(final Session session, final ServletContext servletContext, final boolean newSession) { // forSession is called by privileged actions only so no need to do it again ServletRequestContext current = ServletRequestContext.current(); if (current == null) { return new HttpSessionImpl(session, servletContext, newSession, null); } else { HttpSessionImpl httpSession = current.getSession(); if (httpSession == null) { httpSession = new HttpSessionImpl(session, servletContext, newSession, current); current.setSession(httpSession); } else { if(httpSession.session != session) { //in some rare cases it may be that there are two different service contexts involved in the one request //in this case we just return a new session rather than using the thread local version httpSession = new HttpSessionImpl(session, servletContext, newSession, current); } } return httpSession; } }
Example 2
Source File: ServletRequestContextThreadSetupAction.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public <T, C> Action<T, C> create(final Action<T, C> action) { return new Action<T, C>() { @Override public T call(HttpServerExchange exchange, C context) throws Exception { if (exchange == null) { return action.call(null, context); } else { ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); final ServletRequestContext old = ServletRequestContext.current(); SecurityActions.setCurrentRequestContext(servletRequestContext); try { return action.call(exchange, context); } finally { ServletRequestContext.setCurrentRequestContext(old); } } } }; }
Example 3
Source File: HttpSessionImpl.java From lams with GNU General Public License v2.0 | 6 votes |
public static HttpSessionImpl forSession(final Session session, final ServletContext servletContext, final boolean newSession) { // forSession is called by privileged actions only so no need to do it again ServletRequestContext current = ServletRequestContext.current(); if (current == null) { return new HttpSessionImpl(session, servletContext, newSession, null); } else { HttpSessionImpl httpSession = current.getSession(); if (httpSession == null) { httpSession = new HttpSessionImpl(session, servletContext, newSession, current); current.setSession(httpSession); } else { if(httpSession.session != session) { //in some rare cases it may be that there are two different service contexts involved in the one request //in this case we just return a new session rather than using the thread local version httpSession = new HttpSessionImpl(session, servletContext, newSession, current); } } return httpSession; } }
Example 4
Source File: ServletRequestContextThreadSetupAction.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public <T, C> Action<T, C> create(final Action<T, C> action) { return new Action<T, C>() { @Override public T call(HttpServerExchange exchange, C context) throws Exception { if (exchange == null) { return action.call(null, context); } else { ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); final ServletRequestContext old = ServletRequestContext.current(); SecurityActions.setCurrentRequestContext(servletRequestContext); try { return action.call(exchange, context); } finally { ServletRequestContext.setCurrentRequestContext(old); } } } }; }
Example 5
Source File: SecurityActions.java From quarkus-http with Apache License 2.0 | 5 votes |
static ServletRequestContext currentServletRequestContext() { if (System.getSecurityManager() == null) { return ServletRequestContext.current(); } else { return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() { @Override public ServletRequestContext run() { return ServletRequestContext.current(); } }); } }
Example 6
Source File: SecurityActions.java From quarkus-http with Apache License 2.0 | 5 votes |
static ServletRequestContext currentServletRequestContext() { if (System.getSecurityManager() == null) { return ServletRequestContext.current(); } else { return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() { @Override public ServletRequestContext run() { return ServletRequestContext.current(); } }); } }
Example 7
Source File: ServletThreadContextProvider.java From quarkus with Apache License 2.0 | 5 votes |
private ServletRequestContext restore(ServletRequestContext context) { ServletRequestContext currentContext = ServletRequestContext.current(); if (context == null) ServletRequestContext.clearCurrentServletAttachments(); else ServletRequestContext.setCurrentRequestContext(context); return currentContext; }
Example 8
Source File: SecurityActions.java From lams with GNU General Public License v2.0 | 5 votes |
static ServletRequestContext currentServletRequestContext() { if (System.getSecurityManager() == null) { return ServletRequestContext.current(); } else { return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() { @Override public ServletRequestContext run() { return ServletRequestContext.current(); } }); } }
Example 9
Source File: SecurityActions.java From lams with GNU General Public License v2.0 | 5 votes |
static ServletRequestContext currentServletRequestContext() { if (System.getSecurityManager() == null) { return ServletRequestContext.current(); } else { return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() { @Override public ServletRequestContext run() { return ServletRequestContext.current(); } }); } }