Package org.nuxeo.runtime.osgi
Class OSGiRuntimeService
- java.lang.Object
-
- org.nuxeo.runtime.AbstractRuntimeService
-
- org.nuxeo.runtime.osgi.OSGiRuntimeService
-
- All Implemented Interfaces:
EventListener,RuntimeService,org.osgi.framework.FrameworkListener
- Direct Known Subclasses:
OSGiRuntimeTestService
public class OSGiRuntimeService extends AbstractRuntimeService implements org.osgi.framework.FrameworkListener
The default implementation of NXRuntime over an OSGi compatible environment.- Author:
- Bogdan Stefanescu, Florent Guillaume
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.nuxeo.runtime.AbstractRuntimeService
AbstractRuntimeService.LogConfig
-
-
Field Summary
Fields Modifier and Type Field Description static ComponentNameFRAMEWORK_STARTED_COMPstatic StringNAMEstatic StringPROP_CONFIG_DIRThe OSGi application config directory.static StringPROP_HOME_DIRCan be used to change the runtime home directorystatic StringPROP_HOST_ADAPTERThe host adapter.static StringPROP_INSTALL_DIRThe OSGi application install directory.static StringPROP_NUXEO_BIND_ADDRESSprotected static Comparator<String>PROPERTIES_FILE_FIRSTstatic VersionVERSION-
Fields inherited from class org.nuxeo.runtime.AbstractRuntimeService
context, isShuttingDown, isStarted, logConfig, manager, messageHandler, properties, REDIRECT_JUL, REDIRECT_JUL_THRESHOLD, workingDir
-
-
Constructor Summary
Constructors Constructor Description OSGiRuntimeService(OSGiRuntimeContext runtimeContext, org.osgi.framework.BundleContext context)OSGiRuntimeService(org.osgi.framework.BundleContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RuntimeContextcreateContext(org.osgi.framework.Bundle bundle)protected voiddeployFrameworkStartedComponent()voiddestroyContext(org.osgi.framework.Bundle bundle)protected voiddoStart()protected voiddoStop()StringexpandVars(String expression)Overrides the default method to be able to include OSGi properties.org.osgi.framework.BundlefindHostBundle(org.osgi.framework.Bundle bundle)voidframeworkEvent(org.osgi.framework.FrameworkEvent event)org.osgi.framework.BundlegetBundle(String symbolicName)Get an installed bundle given its symbolic name.org.osgi.framework.BundleContextgetBundleContext()FilegetBundleFile(org.osgi.framework.Bundle bundle)OSGi frameworks are using a stringBundle.getLocation()to identify bundle locations.Map<String,org.osgi.framework.Bundle>getBundlesMap()ComponentPersistencegetComponentPersistence()static StringgetComponentsList(org.osgi.framework.Bundle bundle)RuntimeContextgetContext(String symbolicName)RuntimeContextgetContext(org.osgi.framework.Bundle bundle)StringgetName()Gets the name of this runtime service.StringgetProperty(String name, String defValue)Overrides the default method to be able to include OSGi properties.VersiongetVersion()Gets the version of this runtime service.static booleanisJBoss4(Environment env)protected static booleanisPropertiesFile(String name)protected voidloadComponents(org.osgi.framework.Bundle bundle, RuntimeContext ctx, boolean isFragment)protected voidloadConfig()protected booleanloadConfigurationFromProvider()protected voidloadDefaultConfig()Loads default properties.voidloadProperties(File file)voidloadProperties(InputStream in)voidloadProperties(URL url)voidreloadProperties()Reread all property files loaded at startup.protected voidstartComponents()-
Methods inherited from class org.nuxeo.runtime.AbstractRuntimeService
createComponentManager, getBuiltinFeatureURL, getComponent, getComponentInstance, getComponentManager, getContext, getDescription, getErrorLoggerThread, getHome, getMessageHandler, getProperties, getProperty, getService, getStatusMessage, isShuttingDown, isStarted, setHome, setProperty, start, stop, 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
-
-
-
-
Field Detail
-
FRAMEWORK_STARTED_COMP
public static final ComponentName FRAMEWORK_STARTED_COMP
-
PROP_HOME_DIR
public static final String PROP_HOME_DIR
Can be used to change the runtime home directory- See Also:
- Constant Field Values
-
PROP_INSTALL_DIR
public static final String PROP_INSTALL_DIR
The OSGi application install directory.- See Also:
- Constant Field Values
-
PROP_CONFIG_DIR
public static final String PROP_CONFIG_DIR
The OSGi application config directory.- See Also:
- Constant Field Values
-
PROP_HOST_ADAPTER
public static final String PROP_HOST_ADAPTER
The host adapter.- See Also:
- Constant Field Values
-
PROP_NUXEO_BIND_ADDRESS
public static final String PROP_NUXEO_BIND_ADDRESS
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
VERSION
public static final Version VERSION
-
PROPERTIES_FILE_FIRST
protected static final Comparator<String> PROPERTIES_FILE_FIRST
-
-
Constructor Detail
-
OSGiRuntimeService
public OSGiRuntimeService(org.osgi.framework.BundleContext context)
-
OSGiRuntimeService
public OSGiRuntimeService(OSGiRuntimeContext runtimeContext, org.osgi.framework.BundleContext context)
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:RuntimeServiceGets the name of this runtime service.- Specified by:
getNamein interfaceRuntimeService- Returns:
- the runtime service name
-
getVersion
public Version getVersion()
Description copied from interface:RuntimeServiceGets the version of this runtime service.- Specified by:
getVersionin interfaceRuntimeService- Returns:
- the runtime service version
-
getBundleContext
public org.osgi.framework.BundleContext getBundleContext()
-
getBundle
public org.osgi.framework.Bundle getBundle(String symbolicName)
Description copied from interface:RuntimeServiceGet an installed bundle given its symbolic name. This method is not handling versions.- Specified by:
getBundlein interfaceRuntimeService- Overrides:
getBundlein classAbstractRuntimeService
-
getComponentPersistence
public ComponentPersistence getComponentPersistence()
-
createContext
public RuntimeContext createContext(org.osgi.framework.Bundle bundle)
-
destroyContext
public void destroyContext(org.osgi.framework.Bundle bundle)
-
getContext
public RuntimeContext getContext(org.osgi.framework.Bundle bundle)
-
getContext
public RuntimeContext getContext(String symbolicName)
-
doStart
protected void doStart()
- Overrides:
doStartin classAbstractRuntimeService
-
doStop
protected void doStop()
- Overrides:
doStopin classAbstractRuntimeService
-
loadComponents
protected void loadComponents(org.osgi.framework.Bundle bundle, RuntimeContext ctx, boolean isFragment)
-
getComponentsList
public static String getComponentsList(org.osgi.framework.Bundle bundle)
-
loadConfigurationFromProvider
protected boolean loadConfigurationFromProvider() throws IOException- Throws:
IOException
-
loadConfig
protected void loadConfig() throws IOException- Overrides:
loadConfigin classAbstractRuntimeService- Throws:
IOException
-
reloadProperties
public void reloadProperties() throws IOExceptionDescription copied from interface:RuntimeServiceReread all property files loaded at startup.- Specified by:
reloadPropertiesin interfaceRuntimeService- Throws:
IOException
-
loadDefaultConfig
protected void loadDefaultConfig()
Loads default properties.Used for backward compatibility when adding new mandatory properties
-
loadProperties
public void loadProperties(File file) throws IOException
- Throws:
IOException
-
loadProperties
public void loadProperties(URL url) throws IOException
- Throws:
IOException
-
loadProperties
public void loadProperties(InputStream in) throws IOException
- Throws:
IOException
-
getProperty
public String getProperty(String name, String defValue)
Overrides the default method to be able to include OSGi properties.- Specified by:
getPropertyin interfaceRuntimeService- Overrides:
getPropertyin classAbstractRuntimeService- Parameters:
name- the property namedefValue- the default value to use when the property doesn't exists- Returns:
- the property value
-
expandVars
public String expandVars(String expression)
Overrides the default method to be able to include OSGi properties.- Specified by:
expandVarsin interfaceRuntimeService- Overrides:
expandVarsin classAbstractRuntimeService- Parameters:
expression- the expression to process- Returns:
- the expanded expression
-
startComponents
protected void startComponents()
-
frameworkEvent
public void frameworkEvent(org.osgi.framework.FrameworkEvent event)
- Specified by:
frameworkEventin interfaceorg.osgi.framework.FrameworkListener
-
deployFrameworkStartedComponent
protected void deployFrameworkStartedComponent()
-
findHostBundle
public org.osgi.framework.Bundle findHostBundle(org.osgi.framework.Bundle bundle)
-
getBundleFile
public File getBundleFile(org.osgi.framework.Bundle bundle)
Description copied from interface:RuntimeServiceOSGi 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:
getBundleFilein interfaceRuntimeService- Overrides:
getBundleFilein classAbstractRuntimeService- Returns:
- the bundle file, or null
-
isJBoss4
public static boolean isJBoss4(Environment env)
-
isPropertiesFile
protected static boolean isPropertiesFile(String name)
-
-