List of usage examples for org.springframework.web.context.request RequestContextHolder getRequestAttributes
@Nullable public static RequestAttributes getRequestAttributes()
From source file:com.wms.multitenant.tenant.resolver.CurrentTenantResolverImpl.java
@Override public String resolveCurrentTenantIdentifier() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes != null) { String identifier = (String) requestAttributes.getAttribute("Current_Tenant", RequestAttributes.SCOPE_REQUEST); if (identifier != null) { return identifier; }//from w ww. jav a 2 s . co m } return ""; }
From source file:org.jdal.vaadin.VaadinUtils.java
public static HttpServletRequest getRequest() { return (HttpServletRequest) RequestContextHolder.getRequestAttributes() .resolveReference(RequestAttributes.REFERENCE_REQUEST); }
From source file:com.springsource.greenhouse.utils.Location.java
/** * Get the location of the user associated with the current request, if resolvable. *///from ww w . ja va 2s . c om public static Location getCurrentLocation() { RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); return attributes != null ? (Location) attributes.getAttribute(UserLocationHandlerInterceptor.USER_LOCATION_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST) : null; }
From source file:org.jdal.vaadin.VaadinUtils.java
public static HttpSession getSession() { RequestAttributes ra = RequestContextHolder.getRequestAttributes(); return (HttpSession) (ra != null ? ra.resolveReference(RequestAttributes.REFERENCE_SESSION) : null); }
From source file:org.gwtwidgets.server.spring.ServletUtils.java
/** * Return the request which invokes the service. Valid only if used in the * dispatching thread.// w w w.j av a 2 s .c om * @return the servlet request */ public static HttpServletRequest getRequest() { return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ?Host//from w ww . j a v a 2s .com */ public static String remoteHost() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); return request.getRemoteHost(); }
From source file:nl.ctrlaltdev.harbinger.response.InvalidateSessionAction.java
@Override public boolean perform(HarbingerContext ctx) { ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (sra != null) { HttpSession session = sra.getRequest().getSession(false); if (session != null) { LoggerFactory.getLogger(getClass()).warn("Invalidated session '{}'", session.getId()); session.invalidate();/* w ww. j a v a 2s .c o m*/ } } return true; }
From source file:org.ngrinder.infra.spring.SpringContext.java
/** * Determine if the current thread is from servlet context. * * @return true if it's servlet context. *//* w w w .ja v a 2s . co m*/ public boolean isServletRequestContext() { return RequestContextHolder.getRequestAttributes() != null; }
From source file:org.carewebframework.ui.util.RequestUtil.java
/** * Return current HttpServletRequest. Note that this will return null when invoked outside the * scope of an execution/request./*from w ww. ja v a2 s . com*/ * * @see RequestContextHolder#currentRequestAttributes() * @return HttpServletRequest, null when invoked outside the scope of an * Execution/ServletRequest */ public static HttpServletRequest getRequest() { final ServletRequestAttributes requestAttrs = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); if (requestAttrs == null) { return null; } return requestAttrs.getRequest(); }
From source file:com.vko.core.web.filter.InvocationUtils.java
public static HttpServletRequest getCurrentThreadRequest() { HttpServletRequest request = currentRequests.get(); if (request != null) { return request; }//from w ww . j av a 2 s.c o m return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); }