public final class Framework extends Object
It offers an easy way to create new sessions, to access system services and other resources.
There are two type of services:
Modifier and Type | Field and Description |
---|---|
static String |
NUXEO_DEV_SYSTEM_PROP
Global dev property
|
static String |
NUXEO_STRICT_RUNTIME_SYSTEM_PROP
Property to control strict runtime mode
|
static String |
NUXEO_TESTING_SYSTEM_PROP
Global testing property
|
Modifier and Type | Method and Description |
---|---|
static void |
addListener(RuntimeServiceListener listener)
Registers a listener to be notified about runtime events.
|
static String |
expandVars(String expression)
Expands any variable found in the given expression with the value of the
corresponding framework property.
|
static <T> T |
getLocalService(Class<T> serviceClass)
Gets a nuxeo-runtime local service.
|
static Properties |
getProperties()
Gets all the framework properties.
|
static String |
getProperty(String key)
Gets the given property value if any, otherwise null.
|
static String |
getProperty(String key,
String defValue)
Gets the given property value if any, otherwise returns the given
default value.
|
static SharedResourceLoader |
getResourceLoader() |
static RuntimeService |
getRuntime()
Gets the runtime service instance.
|
static <T> T |
getService(Class<T> serviceClass)
Gets a service given its class.
|
static <T> T |
getService(Class<T> serviceClass,
String name)
Gets a service given its class and an identifier.
|
static void |
handleDevError(Throwable t)
Since 5.6, this method stops the application if property
NUXEO_STRICT_RUNTIME_SYSTEM_PROP is set to true, and one of the
following errors occurred during startup. |
static void |
initialize(RuntimeService runtimeService) |
static boolean |
isBooleanPropertyFalse(String propName)
Returns true if given property is false when compared to a boolean value.
|
static boolean |
isBooleanPropertyTrue(String propName)
Returns true if given property is true when compared to a boolean value.
|
static boolean |
isDevModeSet()
Returns true if dev mode is set.
|
static boolean |
isInitialized()
Tests whether or not the runtime was initialized.
|
static boolean |
isOSGiServiceSupported() |
static boolean |
isTestModeSet()
Returns true if test mode is set.
|
static LoginContext |
login()
Login in the system as the system user (a pseudo-user having all
privileges).
|
static LoginContext |
login(CallbackHandler cbHandler)
Login in the system using the given callback handler for login info
resolution.
|
static LoginContext |
login(String username,
Object password)
Login in the system as the given user using the given password.
|
static LoginContext |
loginAs(String username)
Login in the system as the system user (a pseudo-user having all
privileges).
|
static LoginContext |
loginAsUser(String username)
Login in the system as the given user without checking the password.
|
static Object |
lookup(String key)
Lookup a registered object given its key.
|
static void |
main(String[] args) |
static void |
reloadResourceLoader() |
static void |
reloadResourceLoader(List<URL> urlsToAdd,
List<URL> urlsToRemove)
Reload the resources loader, keeping URLs already tracked, and adding
possibility to add or remove some URLs.
|
static void |
removeListener(RuntimeServiceListener listener)
Removes the given listener.
|
static void |
sendEvent(RuntimeServiceEvent event) |
static void |
shutdown() |
static void |
trackFile(File file,
Object marker)
Deletes the given file when the marker object is collected by GC.
|
static void |
trackFile(File file,
Object marker,
FileDeleteStrategy fileDeleteStrategy)
Deletes the given file when the marker object is collected by GC.
|
public static final String NUXEO_DEV_SYSTEM_PROP
isDevModeSet()
,
Constant Field Valuespublic static final String NUXEO_TESTING_SYSTEM_PROP
isTestModeSet()
,
Constant Field Valuespublic static final String NUXEO_STRICT_RUNTIME_SYSTEM_PROP
handleDevError(Throwable)
,
Constant Field Valuespublic static void initialize(RuntimeService runtimeService) throws Exception
Exception
public static void reloadResourceLoader(List<URL> urlsToAdd, List<URL> urlsToRemove) throws MalformedURLException
Useful for hot reload of jars.
MalformedURLException
Exception
public static boolean isInitialized()
public static SharedResourceLoader getResourceLoader()
public static RuntimeService getRuntime()
public static <T> T getService(Class<T> serviceClass) throws Exception
Exception
public static <T> T getService(Class<T> serviceClass, String name) throws Exception
Exception
public static <T> T getLocalService(Class<T> serviceClass)
public static LoginContext login() throws LoginException
LoginException
- on login failurepublic static LoginContext loginAs(String username) throws LoginException
username
- the originating user idLoginException
- on login failurepublic static LoginContext loginAsUser(String username) throws LoginException
username
- the user name to login as.LoginException
- if any error occurspublic static LoginContext login(String username, Object password) throws LoginException
username
- the username to loginpassword
- the passwordLoginException
- if login failedpublic static LoginContext login(CallbackHandler cbHandler) throws LoginException
cbHandler
- used to fetch the login infoLoginException
public static void sendEvent(RuntimeServiceEvent event)
public static void addListener(RuntimeServiceListener listener)
If the listener is already registered, do nothing.
listener
- the listener to registerpublic static void removeListener(RuntimeServiceListener listener)
If the listener is not registered, do nothing.
listener
- the listener to removepublic static String getProperty(String key)
The framework properties will be searched first then if any matching property is found the system properties are searched too.
key
- the property keypublic static String getProperty(String key, String defValue)
The framework properties will be searched first then if any matching property is found the system properties are searched too.
key
- the property keydefValue
- the default value to usepublic static Properties getProperties()
public static String expandVars(String expression)
The variable format is ${property_key}.
System properties are also expanded.
public static boolean isOSGiServiceSupported()
public static boolean isDevModeSet()
Activating this mode, some of the code may not behave as it would in production, to ease up debugging and working on developing the application.
For instance, it'll enable hot-reload if some packages are installed while the framework is running. It will also reset some caches when that happens.
Before 5.6, when activating this mode, the Runtime Framework stopped on
low-level errors, see handleDevError(Throwable)
but this
behaviour has been removed.
public static boolean isTestModeSet()
Activating this mode, some of the code may not behave as it would in production, to ease up testing.
public static boolean isBooleanPropertyFalse(String propName)
Checks for the system properties if property is not found in the runtime properties.
public static boolean isBooleanPropertyTrue(String propName)
Checks for the system properties if property is not found in the runtime properties.
public static void handleDevError(Throwable t)
NUXEO_STRICT_RUNTIME_SYSTEM_PROP
is set to true, and one of the
following errors occurred during startup.
Before 5.6, this method stopped the application if development mode was enabled (i.e. org.nuxeo.dev system property is set) but this is not the case anymore to handle a dev mode that does not stop the runtime framework when using hot reload.
t
- the exception or null if nonepublic static void trackFile(File file, Object marker)
file
- The file to deletemarker
- the marker Objectpublic static void trackFile(File file, Object marker, FileDeleteStrategy fileDeleteStrategy)
file
- The file to deletemarker
- the marker ObjectfileDeleteStrategy
- add a custom delete strategypublic static void main(String[] args)
Copyright © 2013 Nuxeo SA. All Rights Reserved.