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 | 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)
This method stops the application if development mode is enabled (i.e.
|
static void |
initialize(RuntimeService runtimeService) |
static boolean |
isDevModeSet() |
static boolean |
isInitialized()
Tests whether or not the runtime was initialized.
|
static boolean |
isOSGiServiceSupported() |
static boolean |
isTestModeSet() |
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 |
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 void initialize(RuntimeService runtimeService) throws Exception
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()
public static boolean isTestModeSet()
public static void handleDevError(Throwable t)
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 © 2011 Nuxeo SA. All Rights Reserved.