Save This Page
Home » org.apache.sling.launchpad.base-2.2.0-source-release » org.apache.sling.launchpad.base.impl » [javadoc | source]
org.apache.sling.launchpad.base.impl
public class: Sling [javadoc | source]
java.lang.Object
   org.apache.sling.launchpad.base.impl.Sling

All Implemented Interfaces:
    org.osgi.framework.BundleActivator

Direct Known Subclasses:
    SlingBridge

The Sling serves as the starting point for Sling.

Launch Configuration

The Apache Felix framework requires configuration parameters to be specified for startup. This servlet builds the list of parameters from three locations:

  1. The sling.properties file is read from the servlet class path. This properties file contains default settings.
  2. Extensions of this servlet may provide additional properties to be loaded overwriting the #loadPropertiesOverride(Map) method.
  3. 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 of outer- and the result of resolving ${inner}.

Field Summary
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.

    Also see:
    SharedConstants#SLING_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 

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 

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. 

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 to true (case does not matter), the system properties will not be used by #loadConfigProperties(Map)
public static final  String CONFIG_PROPERTIES    The name of the default launcher properties file to setup the environment for the Felix framework (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. 

public static final  String PROP_SYSTEM_PACKAGES     
protected final  Logger logger    The simple logger to log messages during startup and shutdown to 
Constructor:
 public Sling(Notifiable notifiable,
    Logger logger,
    ResourceProvider resourceProvider,
    Map<String, String> propOverwrite) throws BundleException 
    Initializes this servlet by loading the framework configuration properties, starting the OSGi framework (Apache Felix) and exposing the system bundle context and the Felix instance as servlet context attributes.
    Throws:
    BundleException - if the framework cannot be initialized.
Method from org.apache.sling.launchpad.base.impl.Sling Summary:
destroy,   doStartBundle,   doStopBundle,   getBundleContext,   loadPropertiesOverride,   start,   stop
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.sling.launchpad.base.impl.Sling Detail:
 public final  void destroy() 
    Destroys this servlet by shutting down the OSGi framework and hence the delegatee servlet if one is set at all.
 protected  void doStartBundle() throws Exception 
    Executes additional startup tasks and is called by the #start(BundleContext) method.

    This implementation does nothing and may be overwritten by extensions requiring additional startup tasks.

 protected  void doStopBundle() 
    Executes additional shutdown tasks and is called by the #stop(BundleContext) method.

    This implementation does nothing and may be overwritten by extensions requiring additional shutdown tasks.

    When overwriting this method, it must be made sure, that no exception may be thrown, otherwise unexpected behaviour may result.

 protected final BundleContext getBundleContext() 
    Returns the BundleContext of the system bundle of the OSGi framework launched by this servlet. This method only returns a non-null object after the system bundle of the framework has been started and before it is being stopped.
 protected  void loadPropertiesOverride(Map<String, String> properties) 
    Loads additional properties into the properties object.

    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 properties object 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.properties file in the sling.home directory.

 public final  void start(BundleContext bundleContext) throws Exception 
    Called when the OSGi framework is being started. This implementation registers as a service listener for the javax.servlet.Servlet class and calls the #doStartBundle() method for implementations to execute more startup tasks. Additionally the context URL protocol handler is registered.
 public final  void stop(BundleContext bundleContext) 
    Called when the OSGi framework is being shut down. This implementation first calls the #doStopBundle() method method before unregistering as a service listener and ungetting an servlet delegatee if one has been acquired.