Class Sling
- java.lang.Object
-
- org.apache.sling.launchpad.base.impl.Sling
-
public class Sling extends Object
TheSlingserves as the starting point for Sling.- The
Sling(Notifiable, Logger, LaunchpadContentProvider, Map)method launches ApacheFelixas the OSGi framework implementation we use.
Launch Configuration
The Apache
Felixframework requires configuration parameters to be specified for startup. This servlet builds the list of parameters from three locations:- The
sling.propertiesfile is read from the servlet class path. This properties file contains default settings. - Extensions of this servlet may provide additional properties to be loaded
overwriting the
loadPropertiesOverride(Map)method. - Finally, web application init parameters are added to the properties and may overwrite existing properties of the same name(s).
After loading all properties, variable substitution takes place on the property values. A variable is indicated as
${<prop-name>}where<prop-name>is the name of a system or configuration property (configuration properties override system properties). Variables may be nested and are resolved from inner-most to outer-most. For example, the property value${outer-${inner}}is resolved by first resolving${inner}and then resolving the property whose name is the catenation ofouter-and the result of resolving${inner}. - The
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_PROPERTIESThe name of the default launcher properties file to setup the environment for theFelixframework (value is "sling.properties").static StringJCR_REPO_CONFIG_FILE_URLThe name of the configuration property defining the URL of an existing repository config file (repository.xml).static StringJCR_REPO_HOMEThe name of the configuration property defining the JCR home directory (value is "sling.repository.home").protected org.apache.felix.framework.LoggerloggerThe simple logger to log messages during startup and shutdown tostatic StringOSGI_FRAMEWORK_BUNDLESThe name of the configuration property defining a properties file defining a list of bundles, which are installed into the framework when it has been launched (value is "org.apache.osgi.bundles").static StringPROP_EXTRA_CAPSstatic StringPROP_SYSTEM_PACKAGESstatic StringSLING_HOME_URLThe name of the configuration property defining the Sling home directory as an URL (value is "sling.home.url").static StringSLING_IGNORE_SYSTEM_PROPERTIESThe property to be set to ignore the system properties when building the Felix framework properties (value is "sling.ignoreSystemProperties").
-
Constructor Summary
Constructors Constructor Description Sling(Notifiable notifiable, org.apache.felix.framework.Logger logger, org.apache.sling.launchpad.api.LaunchpadContentProvider resourceProvider, Map<String,String> propOverwrite)Initializes this servlet by loading the framework configuration properties, starting the OSGi framework (Apache Felix) and exposing the system bundle context and theFelixinstance as servlet context attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroys this servlet by shutting down the OSGi framework and hence the delegatee servlet if one is set at all.org.osgi.framework.BundleContextgetBundleContext()Returns theBundleContextof the system bundle of the OSGi framework launched by this servlet.protected voidloadPropertiesOverride(Map<String,String> properties)Loads additional properties into thepropertiesobject.
-
-
-
Field Detail
-
SLING_HOME_URL
public static final String SLING_HOME_URL
The name of the configuration property defining the Sling home directory as an URL (value is "sling.home.url").The value of this property is assigned the value of
new File(${sling.home}).toURI().toString()before resolving the property variables.- See Also:
SharedConstants.SLING_HOME, Constant Field Values
-
JCR_REPO_HOME
public static final String JCR_REPO_HOME
The name of the configuration property defining the JCR home directory (value is "sling.repository.home").The value of this property could be set as a system property, init-param in web.xml or property in sling.properties.
Default value to #SLING_HOME/repository_name
- See Also:
- Constant Field Values
-
JCR_REPO_CONFIG_FILE_URL
public static final String JCR_REPO_CONFIG_FILE_URL
The name of the configuration property defining the URL of an existing repository config file (repository.xml).The value of this property could be set as a system property, init-param in web.xml or property in sling.properties.
Default value to #SLING_HOME/repository_name/repository.xml
- See Also:
- Constant Field Values
-
OSGI_FRAMEWORK_BUNDLES
public static final String OSGI_FRAMEWORK_BUNDLES
The name of the configuration property defining a properties file defining a list of bundles, which are installed into the framework when it has been launched (value is "org.apache.osgi.bundles").This configuration property is generally set in the web application configuration and may be referenced in all property files (default, user supplied and web application parameters) used to build the framework configuration.
- See Also:
- Constant Field Values
-
SLING_IGNORE_SYSTEM_PROPERTIES
public static final String SLING_IGNORE_SYSTEM_PROPERTIES
The property to be set to ignore the system properties when building the Felix framework properties (value is "sling.ignoreSystemProperties"). If this is property is set totrue(case does not matter), the system properties will not be used byloadConfigProperties(Map).- See Also:
- Constant Field Values
-
CONFIG_PROPERTIES
public static final String CONFIG_PROPERTIES
The name of the default launcher properties file to setup the environment for theFelixframework (value is "sling.properties").Extensions of this class may overwrite some or all properties in this file through Web Application parameters or other properties files.
- See Also:
- Constant Field Values
-
PROP_SYSTEM_PACKAGES
public static final String PROP_SYSTEM_PACKAGES
- See Also:
- Constant Field Values
-
PROP_EXTRA_CAPS
public static final String PROP_EXTRA_CAPS
- See Also:
- Constant Field Values
-
logger
protected final org.apache.felix.framework.Logger logger
The simple logger to log messages during startup and shutdown to
-
-
Constructor Detail
-
Sling
public Sling(Notifiable notifiable, org.apache.felix.framework.Logger logger, org.apache.sling.launchpad.api.LaunchpadContentProvider resourceProvider, Map<String,String> propOverwrite) throws org.osgi.framework.BundleException
Initializes this servlet by loading the framework configuration properties, starting the OSGi framework (Apache Felix) and exposing the system bundle context and theFelixinstance as servlet context attributes.- Parameters:
notifiable- The notifiablelogger- The loggerresourceProvider- The resource providerpropOverwrite- The properties to overwrite- Throws:
org.osgi.framework.BundleException- if the framework cannot be initialized.
-
-
Method Detail
-
destroy
public final void destroy()
Destroys this servlet by shutting down the OSGi framework and hence the delegatee servlet if one is set at all.
-
loadPropertiesOverride
protected void loadPropertiesOverride(Map<String,String> properties)
Loads additional properties into thepropertiesobject.This implementation does nothing and may be overwritten by extensions requiring additional properties to be set.
This method is called when the servlet is initialized to prepare the configuration for
Felix. Implementations may add properties from implementation specific sources. Properties added here overwrite properties loaded from the default properties file and may be overwritten by parameters set in the web application.The
propertiesobject has not undergone variable substition and properties added by this method may also contain values refererring to other properties.The properties added in this method will not be persisted in the
sling.propertiesfile in thesling.homedirectory.- Parameters:
properties- ThePropertiesobject to which custom properties may be added.
-
getBundleContext
public final org.osgi.framework.BundleContext getBundleContext()
Returns theBundleContextof the system bundle of the OSGi framework launched by this servlet. This method only returns a non-nullobject after the system bundle of the framework has been started and before it is being stopped.- Returns:
- The
BundleContextof the system bundle
-
-