public class AppContext
extends java.lang.Object
ApplicationContext
app.properties
filesSecurityContext
isStarted()
to check whether the app is fully initialized at the moment.Modifier and Type | Class and Description |
---|---|
static class |
AppContext.Internals
INTERNAL.
|
static interface |
AppContext.Listener
Application startup/shutdown listener.
|
static interface |
AppContext.SecuredOperation<T> |
Modifier and Type | Field and Description |
---|---|
static SecurityContext |
NO_USER_CONTEXT |
Constructor and Description |
---|
AppContext() |
Modifier and Type | Method and Description |
---|---|
static void |
addListener(AppContext.Listener listener)
Register an application start/stop listener.
|
static AppComponents |
getAppComponents() |
static org.springframework.context.ApplicationContext |
getApplicationContext()
INTERNAL.
|
static java.lang.String |
getProperty(java.lang.String key)
Get property value defined in the set of
app.properties files. |
static java.lang.String[] |
getPropertyNames() |
static SecurityContext |
getSecurityContext() |
static SecurityContext |
getSecurityContextNN() |
static boolean |
isReady() |
static boolean |
isStarted() |
static void |
setProperty(java.lang.String key,
java.lang.String value)
Set property value.
|
static void |
setSecurityContext(SecurityContext securityContext)
Set current thread's
SecurityContext . |
static <T> T |
withSecurityContext(SecurityContext securityContext,
AppContext.SecuredOperation<T> operation)
Sets current thread's
SecurityContext , calls operation and sets previous security context back. |
static void |
withSecurityContext(SecurityContext securityContext,
java.lang.Runnable runnable)
Sets current thread's
SecurityContext , invokes runnable and sets previous security context back. |
public static final SecurityContext NO_USER_CONTEXT
public static org.springframework.context.ApplicationContext getApplicationContext()
public static java.lang.String[] getPropertyNames()
app.properties
files@Nullable public static java.lang.String getProperty(java.lang.String key)
app.properties
files.key
- property keypublic static void setProperty(java.lang.String key, @Nullable java.lang.String value)
getProperty(String)
and
getPropertyNames()
, but will not be saved in any app.properties
file and will be lost
after the application restart.key
- property keyvalue
- property value. If null, the property will be removed.@Nullable public static SecurityContext getSecurityContext()
SecurityContext
or null if there is no context boundpublic static SecurityContext getSecurityContextNN()
SecurityContext
java.lang.SecurityException
- if there is no context bound to the current threadpublic static void setSecurityContext(@Nullable SecurityContext securityContext)
SecurityContext
.securityContext
- security context to be set for the current threadpublic static void withSecurityContext(SecurityContext securityContext, java.lang.Runnable runnable)
SecurityContext
, invokes runnable and sets previous security context back.securityContext
- security context to be set for the current threadrunnable
- runnablepublic static <T> T withSecurityContext(SecurityContext securityContext, AppContext.SecuredOperation<T> operation)
SecurityContext
, calls operation and sets previous security context back.securityContext
- security context to be set for the current threadoperation
- operationpublic static AppComponents getAppComponents()
public static void addListener(AppContext.Listener listener)
listener
- listener implementationpublic static boolean isStarted()
public static boolean isReady()
AppContext.Listener
s have been notified