Package org.nuxeo.runtime
Class AbstractRuntimeService
- java.lang.Object
-
- org.nuxeo.runtime.AbstractRuntimeService
-
- All Implemented Interfaces:
RuntimeService
- Direct Known Subclasses:
OSGiRuntimeService
,SimpleRuntime
,TestRuntime
public abstract class AbstractRuntimeService extends Object implements RuntimeService
Abstract implementation of the Runtime Service.Implementors are encouraged to extend this class instead of directly implementing the
RuntimeService
interface.- Author:
- Bogdan Stefanescu
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractRuntimeService.LogConfig
Configure the logging system (log4j) at runtime startup and do any cleanup is needed when the runtime is stopped
-
Field Summary
Fields Modifier and Type Field Description protected RuntimeContext
context
protected boolean
isShuttingDown
protected boolean
isStarted
protected AbstractRuntimeService.LogConfig
logConfig
protected ComponentManager
manager
protected RuntimeMessageHandlerImpl
messageHandler
Message handler for runtime.protected CryptoProperties
properties
static String
REDIRECT_JUL
Property that controls whether or not to redirect JUL to JCL.static String
REDIRECT_JUL_THRESHOLD
protected File
workingDir
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRuntimeService(DefaultRuntimeContext context)
protected
AbstractRuntimeService(DefaultRuntimeContext context, Map<String,String> properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ComponentManager
createComponentManager()
protected void
doStart()
protected void
doStop()
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.protected static URL
getBuiltinFeatureURL()
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.Object
getComponent(ComponentName name)
Gets a component given its name.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.static Thread
getErrorLoggerThread(String message)
Error logger which does its logging from a separate thread, for thread isolation.File
getHome()
Gets the home directory of the runtime.RuntimeMessageHandler
getMessageHandler()
Gets the runtime message handler.CryptoProperties
getProperties()
Gets runtime service properties.String
getProperty(String name)
Gets a runtime service property given its name.String
getProperty(String name, String defValue)
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.boolean
isShuttingDown()
Returns true if the runtime is shutting down.boolean
isStarted()
Returns true if the runtime is started.protected void
loadConfig()
void
setHome(File home)
void
setProperty(String name, Object value)
void
start()
Starts the runtime.void
stop()
Stops the runtime.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.RuntimeService
getComponent, getComponentInstance, getName, getVersion, reloadProperties
-
-
-
-
Field Detail
-
REDIRECT_JUL
public static final String REDIRECT_JUL
Property that controls whether or not to redirect JUL to JCL. By default is true (JUL will be redirected)- See Also:
- Constant Field Values
-
REDIRECT_JUL_THRESHOLD
public static final String REDIRECT_JUL_THRESHOLD
- See Also:
- Constant Field Values
-
isStarted
protected boolean isStarted
-
isShuttingDown
protected boolean isShuttingDown
-
workingDir
protected File workingDir
-
properties
protected CryptoProperties properties
-
manager
protected ComponentManager manager
-
context
protected final RuntimeContext context
-
logConfig
protected AbstractRuntimeService.LogConfig logConfig
-
messageHandler
protected final RuntimeMessageHandlerImpl messageHandler
Message handler for runtime. This handler takes care to store messages with the component manager step.- Since:
- 9.10
-
-
Constructor Detail
-
AbstractRuntimeService
protected AbstractRuntimeService(DefaultRuntimeContext context)
-
AbstractRuntimeService
protected AbstractRuntimeService(DefaultRuntimeContext context, Map<String,String> properties)
-
-
Method Detail
-
getMessageHandler
public RuntimeMessageHandler getMessageHandler()
Description copied from interface:RuntimeService
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.
- Specified by:
getMessageHandler
in interfaceRuntimeService
- Returns:
- the message handler for runtime.
- Since:
- 9.10
-
createComponentManager
protected ComponentManager createComponentManager()
-
getBuiltinFeatureURL
protected static URL getBuiltinFeatureURL()
-
start
public void start()
Description copied from interface:RuntimeService
Starts the runtime.- Specified by:
start
in interfaceRuntimeService
-
stop
public void stop()
Description copied from interface:RuntimeService
Stops the runtime.- Specified by:
stop
in interfaceRuntimeService
-
isStarted
public boolean isStarted()
Description copied from interface:RuntimeService
Returns true if the runtime is started.- Specified by:
isStarted
in interfaceRuntimeService
- Returns:
- true if the runtime is started, false otherwise
-
isShuttingDown
public boolean isShuttingDown()
Description copied from interface:RuntimeService
Returns true if the runtime is shutting down.- Specified by:
isShuttingDown
in interfaceRuntimeService
- Returns:
- true if the runtime is shutting down, false otherwise
-
loadConfig
protected void loadConfig() throws IOException
- Throws:
IOException
-
doStart
protected void doStart()
-
doStop
protected void doStop()
-
getHome
public File getHome()
Description copied from interface:RuntimeService
Gets the home directory of the runtime.- Specified by:
getHome
in interfaceRuntimeService
- Returns:
- the home directory
-
setHome
public void setHome(File home)
-
getDescription
public String getDescription()
Description copied from interface:RuntimeService
Gets the description of this runtime service.- Specified by:
getDescription
in interfaceRuntimeService
- Returns:
- the runtime service description
-
getProperties
public CryptoProperties getProperties()
Description copied from interface:RuntimeService
Gets runtime service properties.- Specified by:
getProperties
in interfaceRuntimeService
- Returns:
- the runtime properties
-
getProperty
public String getProperty(String name)
Description copied from interface:RuntimeService
Gets a runtime service property given its name.- Specified by:
getProperty
in interfaceRuntimeService
- Parameters:
name
- the property name- Returns:
- the property value if any or null if none
-
getProperty
public String getProperty(String name, String defValue)
Description copied from interface:RuntimeService
Gets a property value using a default value if the property was not set.- Specified by:
getProperty
in interfaceRuntimeService
- Parameters:
name
- the property namedefValue
- the default value to use when the property doesn't exists- Returns:
- the property value
-
setProperty
public void setProperty(String name, Object value)
- Specified by:
setProperty
in interfaceRuntimeService
-
getComponent
public Object getComponent(ComponentName name)
Description copied from interface:RuntimeService
Gets a component given its name.- Specified by:
getComponent
in interfaceRuntimeService
- Parameters:
name
- the component name- Returns:
- the component, or null if no such component was registered
-
getComponentInstance
public ComponentInstance getComponentInstance(ComponentName name)
Description copied from interface:RuntimeService
Gets a component implementation instance given its name.- Specified by:
getComponentInstance
in interfaceRuntimeService
- Parameters:
name
- the component name- Returns:
- the component or null if no such component was registered
-
getComponentManager
public ComponentManager getComponentManager()
Description copied from interface:RuntimeService
Gets the component manager.- Specified by:
getComponentManager
in interfaceRuntimeService
- Returns:
- the component manager
-
getContext
public RuntimeContext getContext()
Description copied from interface:RuntimeService
Gets the context of the runtime bundle.- Specified by:
getContext
in interfaceRuntimeService
- Returns:
- the context object
-
getService
public <T> T getService(Class<T> serviceClass)
Description copied from interface:RuntimeService
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.
- Specified by:
getService
in interfaceRuntimeService
- Type Parameters:
T
- the service type- Parameters:
serviceClass
- the service class- Returns:
- the service object
-
expandVars
public String expandVars(String expression)
Description copied from interface:RuntimeService
Replaces any substring in the form${property.name}
with the corresponding runtime property value if any, otherwise leaves the substring unchanged.- Specified by:
expandVars
in interfaceRuntimeService
- Parameters:
expression
- the expression to process- Returns:
- the expanded expression
-
getBundleFile
public File getBundleFile(org.osgi.framework.Bundle bundle)
Description copied from interface:RuntimeService
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.
- Specified by:
getBundleFile
in interfaceRuntimeService
- Returns:
- the bundle file, or null
-
getBundle
public org.osgi.framework.Bundle getBundle(String symbolicName)
Description copied from interface:RuntimeService
Get an installed bundle given its symbolic name. This method is not handling versions.- Specified by:
getBundle
in interfaceRuntimeService
-
getStatusMessage
public boolean getStatusMessage(StringBuilder msg)
Description copied from interface:RuntimeService
Computes the runtime status, adds it to the given string builder, and return true if some problems have been detected.- Specified by:
getStatusMessage
in interfaceRuntimeService
- Parameters:
msg
- summary message about all components loading status- Returns:
- true if there was no detected error, else return false
- Since:
- 5.5
-
-