|
Page Edited :
SLINGxSITE :
Configuration
Configuration has been edited by Mike Mueller (Apr 13, 2008). Change summary: Fix property names (SLING-379) Configuration SupportIntroductionConfiguration in Sling is aligned with respective support by the OSGi specification:
For the discussion to follow we differentiate between intial configuration provided by Framework and system properties and managed configuration provided by the Configuration Admin Service. Components managed by the Service Component Runtime are generally configured (as listed above) through the descriptor properties and configuration set by Configuration Admin Service configuration. The descriptor property values may be seen as configuration default values set by the component developer, which may be overwritten by user configuration through the Configuration Admin Service. Components may but are not required to make use of Framework properties by accessing the BundleContext through the ComponentContext given to the activate(ComponentContext) method of the component. Initial ConfigurationThe lifecycle of the OSGi framework implemented by an instance of the org.apache.felix.framework.Felix class is managed by the Sling launcher class org.apache.sling.launcher.Sling. This class is used by the standalone main class (org.apache.sling.launcher.main.Main) and the Sling Servlet (org.apache.sling.launcher.servlet.SlingServlet) to control the lifecycle. The Sling launcher is responsible to provide the Framework properties to the OSGi framework. The properties are prepared as a java.util.Map<String, String> instance as follows (later steps may overwrite properties defined in earlier steps) :
Using file system copies of the initial configuration and referred files, it is easy to modify this configuration without the need to unpack and repackage the web application archive. The only property really required is actually the sling.home property, which defines the file system location where runtime files will be placed. The default if this property is missing will be sling in the current working directory as defined the user.dir system property. Standalone ApplicationWhen launching Sling as a standalone application the sling-app.jar file is used. This is an executable JAR File. The sling.properties file as well as the sling_install.properties and JRE specific properties files are located at the root of the JAR file hierarchy. The standalone application currently sets properties for the third step of the configuration setup to ensure the HTTP Servlet integration is using the Apache Felix http.jetty bundle. Additionally system properties may be set using the -D command line switch of the Java binary. In addition the following command line arguments are accepted:
The standalone application exits with status code 0 (zero) if Sling terminates normally, that is if the OSGi framework is stopped or if just the usage note has been displayed. If any error occurrs during command line parsing, the cause is printed to the error output and the application exists with status code 1 (one). If the OSGi framework fails to start, the cause is printed to the error output and the application exists with status code 2. Web ApplicationWhen launching Sling as a web application using the sling-servlet.war or any derived Web Application archive file, the sling.properties file is located in the WEB-INF folder along with the sling_install.properties and JRE specific properties files. The Sling Servlet uses the Servlet Context and Servlet init-param configurations to prepare the properties for the third step of the configuration setup. If the OSGi framework fails to startup for any reason a javax.servlet.UnavailableException. Property File InclusionsTwice in the configuration setup (second and seventh step) any property file inclusions will be handled. Property files may be included by defining one or more properties containing a comma-separated list of properties files to include. Property file inclusion looks at the sling.include property and any other property whose prefix is sling.include.. When such properties exist, the files listed in those properties are included. The order of handling the property file inclusion properties is defined as natural sort order of the actual property names. So the properties of the files listed in the sling.include.first property will be loaded before the files listed in the sling.include.second but after the files listed in the sling.include.a property. Any file which does not exist is silently ignored. The names of the files are resolved as follows:
Example The packaged sling.properties file contains the following properties file inclusion setting: sling.include.jre = jre-${java.specification.version}.properties
Sometimes, especially in the Servlet Container case, it is important to use the shared classes from the container and not resolve using standard OSGi resolution. In such cases, the packages of these shared classes must be listed in the org.osgi.framework.bootdelegation property. Sling provides a mechanism to extend the default setting of the org.osgi.framework.bootdelegation property by adding properties prefixed with sling.bootdelegation.. The value of each of these prefixed properties is conditionally appended to the org.osgi.framework.bootdelegation property. Conditionally means, that the property name may contain the fully qualified name of a class, which is checked to see whether to add the property value or not. Examples
Note Even though packages listed in the org.osgi.framework.bootdelegation property will always be loaded from the environment, any bundles using these packages must still import them (through Import-Package or DynamicImport-Package) and the bundles must resolve for being usable. OSGi System Packages SupportAs listed in the above section on OSGi Boot Delegation Support, the org.osgi.framework.system.packages property may be used to extend the export list of the system bundle. Similar to the support for extending the boot delegation packages list, Sling supports extending the system packages list. The mechanism to extend the default setting of the org.osgi.framework.system.packages property by adding properties prefixed with sling.system.packages.. The value of each of these prefixed properties is conditionally appended to the org.osgi.framework.system.packages property. Conditionally means, that the property name may contain the fully qualified name of a class, which is checked to see whether to add the property value or not. Examples
Note Packages listed in the org.osgi.framework.system.packages required by any bundles must be imported by those bundles by listing them in the Import-Package or DynamicImport-Package manifest header. Recommendations for property namesThe following system property names are reserved:
To prevent property name collisions, I suggest the following convention:
Well Known PropertiesThe following table is a collection of well known property names from different parts of Project Sling.
Configuration Admin ServiceConfiguration of the system entities, such as services and components, by the system administrator is supported the Configuration Admin Service. The Configuration Admin Service acts as the center for the management of the configuration data, to which GUI-based tools will connect to retrieve and update configuration data. The Configuration Admin Service is responsible for persisting the configuration data and for providing configuration consumers with the configuration data. Specifically services registered with the ManagedService or ManagedServiceFactory interfaces are updated with the configuration upon updated. The Service Component Runtime on the other hand recognizes updated configuration and provides it to the managed components as defined in the OSGi Declarative Services Specification. By default the Configuration Admin Service is installed when Sling is started for the first time. This service is used by the Service Component Runtime launching the OSGi components declared in the bundles with configuration values. The Sling Management Console provides a simple GUI to manage these configuration elements on the 'Configuration' page. For more information on the Configuration Admin Service refer to the OSGi Configuration Admin Service Specification in the OSGi Service Platform Service Compendium book. |
Unsubscribe or edit your notifications preferences
