Interface RuntimeService
-
- All Known Implementing Classes:
AbstractRuntimeService
,OSGiRuntimeService
,OSGiRuntimeTestService
,SimpleRuntime
,TestRuntime
public interface RuntimeService
The runtime service: a singleton object that provides access to the Nuxeo Runtime. The runtime service must be started before any other runtime component or object that accesses the runtime.This service is usually implemented for each target platform where Nuxeo Runtime should run.
It is recommended to extend the
AbstractRuntimeService
class instead of directly implementing this interface.After the runtime service was initialized, it may be accessed through the facade class
Framework
.See:
Framework
- Author:
- Bogdan Stefanescu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
expandVars(String expression)
Replaces any substring in the form${property.name}
with the corresponding runtime property value if any, otherwise leaves the substring unchanged.org.osgi.framework.Bundle
getBundle(String symbolicName)
Get an installed bundle given its symbolic name.File
getBundleFile(org.osgi.framework.Bundle bundle)
OSGi frameworks are using a stringBundle.getLocation()
to identify bundle locations.default Object
getComponent(String name)
Gets a component given its name as a string.Object
getComponent(ComponentName name)
Gets a component given its name.default ComponentInstance
getComponentInstance(String name)
Gets a component implementation instance given its name as a string.ComponentInstance
getComponentInstance(ComponentName name)
Gets a component implementation instance given its name.ComponentManager
getComponentManager()
Gets the component manager.RuntimeContext
getContext()
Gets the context of the runtime bundle.String
getDescription()
Gets the description of this runtime service.File
getHome()
Gets the home directory of the runtime.RuntimeMessageHandler
getMessageHandler()
Gets the runtime message handler.String
getName()
Gets the name of this runtime service.Properties
getProperties()
Gets runtime service properties.String
getProperty(String name)
Gets a runtime service property given its name.String
getProperty(String name, String defaultValue)
Gets a property value using a default value if the property was not set.<T> T
getService(Class<T> serviceClass)
Gets the service of type serviceClass if such a service was declared by a resolved runtime component.boolean
getStatusMessage(StringBuilder msg)
Computes the runtime status, adds it to the given string builder, and return true if some problems have been detected.Version
getVersion()
Gets the version of this runtime service.boolean
isShuttingDown()
Returns true if the runtime is shutting down.boolean
isStarted()
Returns true if the runtime is started.void
reloadProperties()
Reread all property files loaded at startup.void
setProperty(String name, Object value)
void
start()
Starts the runtime.void
stop()
Stops the runtime.
-
-
-
Method Detail
-
start
void start()
Starts the runtime.
-
stop
void stop() throws InterruptedException
Stops the runtime.- Throws:
InterruptedException
-
isStarted
boolean isStarted()
Returns true if the runtime is started.- Returns:
- true if the runtime is started, false otherwise
-
isShuttingDown
boolean isShuttingDown()
Returns true if the runtime is shutting down.- Returns:
- true if the runtime is shutting down, false otherwise
- Since:
- 5.5
-
getHome
File getHome()
Gets the home directory of the runtime.- Returns:
- the home directory
-
getName
String getName()
Gets the name of this runtime service.- Returns:
- the runtime service name
-
getDescription
String getDescription()
Gets the description of this runtime service.- Returns:
- the runtime service description
-
getVersion
Version getVersion()
Gets the version of this runtime service.- Returns:
- the runtime service version
-
getProperties
Properties getProperties()
Gets runtime service properties.- Returns:
- the runtime properties
-
reloadProperties
void reloadProperties() throws IOException
Reread all property files loaded at startup.- Throws:
IOException
-
getProperty
String getProperty(String name)
Gets a runtime service property given its name.- Parameters:
name
- the property name- Returns:
- the property value if any or null if none
-
getProperty
String getProperty(String name, String defaultValue)
Gets a property value using a default value if the property was not set.- Parameters:
name
- the property namedefaultValue
- the default value to use when the property doesn't exists- Returns:
- the property value
-
expandVars
String expandVars(String expression)
Replaces any substring in the form${property.name}
with the corresponding runtime property value if any, otherwise leaves the substring unchanged.- Parameters:
expression
- the expression to process- Returns:
- the expanded expression
-
getComponentManager
ComponentManager getComponentManager()
Gets the component manager.- Returns:
- the component manager
-
getComponent
default Object getComponent(String name)
Gets a component given its name as a string.- Parameters:
name
- the component name as a string- Returns:
- the component
-
getComponent
Object getComponent(ComponentName name)
Gets a component given its name.- Parameters:
name
- the component name- Returns:
- the component, or null if no such component was registered
-
getComponentInstance
default ComponentInstance getComponentInstance(String name)
Gets a component implementation instance given its name as a string.- Parameters:
name
- the component name as a string- Returns:
- the component
-
getComponentInstance
ComponentInstance getComponentInstance(ComponentName name)
Gets a component implementation instance given its name.- Parameters:
name
- the component name- Returns:
- the component or null if no such component was registered
-
getContext
RuntimeContext getContext()
Gets the context of the runtime bundle.- Returns:
- the context object
-
getService
<T> T getService(Class<T> serviceClass)
Gets the service of type serviceClass if such a service was declared by a resolved runtime component.If the component is not yet activated, it will be prior to return the service.
- Type Parameters:
T
- the service type- Parameters:
serviceClass
- the service class- Returns:
- the service object
-
getMessageHandler
RuntimeMessageHandler getMessageHandler()
Gets the runtime message handler. You can add new messages or just retrieve them.Warning messages don't block server startup, but error messages do in strict mode.
- Returns:
- the message handler for runtime.
- Since:
- 9.10
-
getBundleFile
File getBundleFile(org.osgi.framework.Bundle bundle)
OSGi frameworks are using a stringBundle.getLocation()
to identify bundle locations.This method try to convert the bundle location to real file if possible. If this bundle location cannot be converted to a file (e.g. it may be a remote URL), null is returned.
This method works only for bundles that are installed as files on the host file system.
- Returns:
- the bundle file, or null
-
getBundle
org.osgi.framework.Bundle getBundle(String symbolicName)
Get an installed bundle given its symbolic name. This method is not handling versions.
-
getStatusMessage
boolean getStatusMessage(StringBuilder msg)
Computes the runtime status, adds it to the given string builder, and return true if some problems have been detected.- Returns:
- true if there are warnings/errors on current runtime.
- Since:
- 5.6
-
-