/** * Returns the instance of {@link SecurityContext} in current request. * * @throws IllegalStateException if the context not exists in current request. */ public static SecurityContext current() { SecurityContext context = (SecurityContext)RequestContext.current().getAttribute(CONTEXT_ATTRIBUTE_NAME); if(null == context){ throw new IllegalStateException("Current security context does not exists"); } return context; }
static SecurityContextHolder current() { SecurityContextHolder context = (SecurityContextHolder)RequestContext.current().getAttribute(CONTEXT_HOLDER_ATTRIBUTE_NAME); if(null == context){ throw new IllegalStateException("Current security context holder does not exists"); } return context; }
public static String get(Locale locale, String key,Object... args){ return RequestContext.current().getMessageSource().getMessage(locale, key, args); }
public static String get(String key,Object... args){ return RequestContext.current().getMessageSource().getMessage(key, args); }
public static String get(Locale locale, String key){ return RequestContext.current().getMessageSource().getMessage(locale, key); }
protected Object resolveRequestVariable(VariableDefinition vd){ return resolveScopedVariable(vd, getVariablesScope(RequestContext.current())); }
public static String get(String key){ return RequestContext.current().getMessageSource().getMessage(key); }
/** * Returns a formatted {@link String} of the given key and current locale. * * @throws ObjectNotFoundException if the given key not exists. * * @see MessageSource#getMessage(String, Object...) */ public static String getMessage(String key,Object... args) throws ObjectNotFoundException { RequestContext current = current(); return current.getMessageSource().getMessage(current.getLocale(),key, args); }
protected Object resolveSessionVariable(VariableDefinition vd){ return resolveScopedVariable(vd, getVariablesScope(RequestContext.current().getSession())); }
/** * Returns a formatted {@link String} of the given key for current {@link Locale}. * * <p> * Returns <code>null</code> if the given key not exists for current {@link Locale}. * * @see MessageSource#tryGetMessage(Locale, String, Object...) */ public static String tryGetMessage(String key,Object... args) { RequestContext current = current(); return current.getMessageSource().tryGetMessage(current.getLocale(),key, args); }