Package org.rapidcontext.app
Class ApplicationContext
java.lang.Object
org.rapidcontext.core.ctx.Context
org.rapidcontext.app.ApplicationContext
The application context. This is a singleton object that contains
references to global application settings and objects. It also
provides simple procedure execution and resource and plug-in
initialization and deinitialization.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateThe class load time (system initialization time).static final PathThe path to the global configuration.static DateThe context start (or reset) time.Fields inherited from class org.rapidcontext.core.ctx.Context
actives, CX_DIRECTORY, CX_ENVIRONMENT, CX_SCHEDULER, CX_STORAGE, id, parent, root -
Method Summary
Modifier and TypeMethodDescriptionstatic ApplicationContextactive()Returns the currently active application context.Returns the app (root) data store.Returns the current web cache path.Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.protected static voiddestroy()Destroys the application context and frees all resources used.execute(String name, Object[] args, String source, StringBuilder trace) Deprecated, for removal: This API element is subject to removal in a future version.Use CallContext.execute() instead.voidexecuteAsync(String name, Object[] args, String source) Deprecated, for removal: This API element is subject to removal in a future version.Background thread execution will be removed in a future release.findContext(int threadId) Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.findContext(Thread thread) Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.baseDir() instead.Returns the application configuration.Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.environment() instead.static ApplicationContextDeprecated, for removal: This API element is subject to removal in a future version.Use active() instead.Deprecated, for removal: This API element is subject to removal in a future version.Procedures and interceptors are now initialized as normal storage objects instead.Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.storage() or appStorage() instead.Returns the array of cached web matchers (from the web services).protected static ApplicationContextCreates and initializes the application context.installPlugin(File file) Installs a plug-in from the specified file.booleanisPluginBuiltIn(String pluginId) Checks if the specified plug-in is built-in (or installed).voidloadPlugin(String pluginId) Loads a plug-in.voidreset()Resets this context and reloads all resources.voiduninstallPlugin(String pluginId) Uninstalls and removes a plug-in file.voidunloadPlugin(String pluginId) Unloads a plug-in.version()Returns the platform version information (in a sealed dictionary).
-
Field Details
-
PATH_CONFIG
The path to the global configuration. -
INIT_TIME
The class load time (system initialization time). -
START_TIME
The context start (or reset) time.
-
-
Method Details
-
active
Returns the currently active application context.- Returns:
- the currently active application context, or null
-
init
Creates and initializes the application context. If the start flag is set, all plug-ins will be loaded along with procedures and the environment configuration. Otherwise only the storages will be initialized. Note that if the context has already been created, it will not be recreated.- Parameters:
baseDir- the base application directorylocalDir- the local add-on directorystart- the initialize plug-ins flag- Returns:
- the application context created or found
-
destroy
protected static void destroy()Destroys the application context and frees all resources used. -
getInstance
Deprecated, for removal: This API element is subject to removal in a future version.Use active() instead.Returns the singleton application context instance.- Returns:
- the singleton application context instance
- See Also:
-
reset
public void reset()Resets this context and reloads all resources. -
cachePath
Returns the current web cache path. This is renewed each time the application context is initialized or reset.- Returns:
- the current web cache path
-
getConfig
Returns the application configuration.- Returns:
- the application configuration
-
version
Returns the platform version information (in a sealed dictionary).- Returns:
- the platform version information dictionary
-
getStorage
Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.storage() or appStorage() instead.Returns the application data storage. This is the global data storage that contains all loaded plug-ins and maps requests to them in order.- Returns:
- the application data store
-
appStorage
Returns the app (root) data store.- Returns:
- the context data store
-
getEnvironment
Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.environment() instead.Returns the environment used.- Returns:
- the environment used
-
getWebMatchers
Returns the array of cached web matchers (from the web services). This list is only re-read when the context is reset.- Returns:
- the array of cached web matchers
- See Also:
-
getLibrary
Deprecated, for removal: This API element is subject to removal in a future version.Procedures and interceptors are now initialized as normal storage objects instead. The Library API will be removed.Returns the procedure library used.- Returns:
- the procedure library used
-
getBaseDir
Deprecated, for removal: This API element is subject to removal in a future version.Use inherited Context.baseDir() instead.Returns the application base directory.- Returns:
- the application base directory
-
isPluginBuiltIn
Checks if the specified plug-in is built-in (or installed). Note any plug-ins located in the built-in plug-in directory will be considered built-in.- Parameters:
pluginId- the unique plug-in id- Returns:
- true if the plug-in exists and is built-in, or false otherwise
-
installPlugin
Installs a plug-in from the specified file. If an existing plug-in with the same id already exists, it will be replaced without warning. After installation, the new plug-in will also be loaded and added to the default configuration for automatic launch on the next restart.- Parameters:
file- the plug-in ZIP file- Returns:
- the unique plug-in id
- Throws:
PluginException- if the plug-in couldn't be installed correctly
-
uninstallPlugin
Uninstalls and removes a plug-in file. If the plug-in is loaded or mounted, it will first be unloaded and the associated storage will be destroyed.- Parameters:
pluginId- the unique plug-in id- Throws:
PluginException- if the plug-in removal failed
-
loadPlugin
Loads a plug-in. If the plug-in was loaded successfully, it will also be added to the default configuration for automatic launch on the next restart.- Parameters:
pluginId- the unique plug-in id- Throws:
PluginException- if no plug-in instance could be created or if the plug-in initialization failed
-
unloadPlugin
Unloads a plug-in. The plug-in will also be removed from the default configuration for automatic launches.- Parameters:
pluginId- the unique plug-in id- Throws:
PluginException- if the plug-in deinitialization failed
-
execute
@Deprecated(forRemoval=true) public Object execute(String name, Object[] args, String source, StringBuilder trace) throws ProcedureException Deprecated, for removal: This API element is subject to removal in a future version.Use CallContext.execute() instead.Executes a procedure within this context.- Parameters:
name- the procedure nameargs- the procedure argumentssource- the call source informationtrace- the trace buffer or null for none- Returns:
- the result of the call, or null if the call produced no result
- Throws:
ProcedureException- if the procedure execution failed- See Also:
-
executeAsync
@Deprecated(forRemoval=true) public void executeAsync(String name, Object[] args, String source) throws ProcedureException Deprecated, for removal: This API element is subject to removal in a future version.Background thread execution will be removed in a future release.Executes a procedure asynchronously within this context. This method will sleep for 10 minutes after terminating the procedure execution, allowing the results to be fetched from the context by another thread.- Parameters:
name- the procedure nameargs- the procedure argumentssource- ignored- Throws:
ProcedureException- if the procedure lookup failed
-
contextThreads
Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.Returns a read-only set of active context threads.- Returns:
- a set of active context threads
-
findContext
Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.Finds the currently active call context for a thread.- Parameters:
thread- the thread to search for- Returns:
- the call context found, or null if no context was active
-
findContext
Deprecated, for removal: This API element is subject to removal in a future version.Thread introspection will be removed in a future release.Finds the currently active call context for a thread id. The thread id is identical to the hash code for the thread.- Parameters:
threadId- the thread id to search for- Returns:
- the call context found, or null if no context was active
-