Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DD2E89549 for ; Sun, 22 Apr 2012 17:20:45 +0000 (UTC) Received: (qmail 22951 invoked by uid 500); 22 Apr 2012 17:20:45 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 22889 invoked by uid 500); 22 Apr 2012 17:20:45 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 22860 invoked by uid 99); 22 Apr 2012 17:20:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Apr 2012 17:20:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Apr 2012 17:20:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 442202388B6C for ; Sun, 22 Apr 2012 17:20:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r813971 [3/11] - /websites/staging/sling/trunk/content/ Date: Sun, 22 Apr 2012 17:20:13 -0000 To: commits@sling.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120422172018.442202388B6C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/staging/sling/trunk/content/configuration.html ============================================================================== --- websites/staging/sling/trunk/content/configuration.html (original) +++ websites/staging/sling/trunk/content/configuration.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,330 @@ Home + +

+

Configuration Support

+

+

Introduction

+

Configuration in Sling is aligned with respective support by the OSGi +specification:

+
    +
  • Framework and Java system properties are available through the +BundleContext.getProperty(String) method. These properties are provided +in Sling through the Sling launcher.
  • +
  • Bundle Header values are available through the Bundle.getHeaders() +and Bundle.getHeaders(String) methods. These header values are set by +the bundle developer in the META-INF/MANIFEST.MF file. In fact, all +main manifest attributes are available through these methods.
  • +
  • Components managed by the Service Component Runtime and declared in +component descriptor files listed in the Service-Component manifest +header access configuration properties through the +ComponentContext.getProperties() method. These properties have three +sources: + # Configuration specified specifically for factory components + # Properties retrieved from the Configuration Admin Service + *# Properties set in the component descriptor
  • +
  • Configuration properties provided to ManagedService and +ManagedServiceFactory instances by the Configuration Admin Service.
  • +
+

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 Configuration

+

The 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 instance as follows (later steps may +overwrite properties defined in earlier steps) :

+
    +
  1. Load core properties from the embedded sling.properties file.
  2. +
  3. Resolve any property file inclusions. This is mainly used to resolve +the correct JRE package definitions for the JRE version used.
  4. +
  5. Overwrite with any properties provided by the main class or the Sling +Servlet.
  6. +
  7. Make sure the sling.home property is set defining a sensible +default value if missing
  8. +
  9. Load the contents of the ${sling.home}/sling.properties file
  10. +
  11. Overwrite properties with Java system properties. This step only +considers system properties of the same names as properties already +existing. That is, the system properties are not just copied into the +properties here. Additionally this step my be omitted if the +sling.ignoreSystemProperties property is set to true.
  12. +
  13. Resolve any property file inclusions. This may be used to provide more +configurability depending on the integration.
  14. +
  15. Handle OSGi boot delegation support (see below).
  16. +
  17. Resolve property references of the form ${propName}
  18. +
  19. For each property value starting with ontext:/ do the following, +assuming the value to be an URL with scheme context::
  20. +
  21. +
      +
    • Copy the application resource to ${sling.home} preserving the +URL path unless such a file already exists.
    • +
    +
  22. +
  23. +
      +
    • Replace the property value with the path to the newly created +file. The path has the form ${sling.home}/relpath.
    • +
    +
  24. +
  25. Store the properties as ${sling.home}/sling.properties to be +re-used on next startup
  26. +
  27. Setup Bundle auto installation for the Felix Framework
  28. +
+

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 Application

+

When 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:

+ + + + + + + + +
Argument Sling property Description
*-l loglevel* *org.apache.sling.osgi.log.level* The initial +loglevel (0..4, FATAL, ERROR, WARN, INFO, DEBUG)
*-f logfile* *org.apache.sling.osgi.log.file* The log file, "-" +for stdout
*-c slinghome* *sling.home* the sling context directory
*-a address* -- the interfact to bind to (use 0.0.0.0 for any) (not +supported yet)
*-p port* *org.osgi.service.http.port* the port to listen to +(default 8080)
*-h* -- Prints a simple usage message and exits.
+

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 Application

+

When 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 Inclusions

+

Twice 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:

+
    +
  1. If a resource exists at the same location as the initial +sling.properties file packaged with the application, that resource is +used
  2. +
  3. If the name is a relative file name, it is looked for in the +sling.home directory
  4. +
  5. If the name is an absolute file name, it is used as is
  6. +
+

Example

+

The packaged sling.properties file contains the following properties +file inclusion setting:

+
sling.include.jre = jre-${java.specification.version}.properties
+
+ + +

This is used to include the JRE package list to be made visible inside the +OSGi framework.

+

+

OSGi Boot Delegation Support

+

Some packages may have to be shared between bundles in an OSGi framework +and the rest of Java VM in which the framework has been launched. This is +especially true for OSGi framework instances launched in embedding such as +Servlet Containers. In the case of a Sling Application accessing a JCR +Repository launched in a different Web Application, this mainly concerns an +API packages as well as the JNDI Initial Factory package(s).

+

To cope with this sharing issue, the OSGi core specification defines two +properties, which may list packages to be used from the environment:

+
    +
  • org.osgi.framework.system.packages - This property lists package +names which are added to the list of exported packages of the system bundle +of the OSGi framework. These packages are used in the resolution process +just as any package listed in an Export-Package bundle manifest header.
  • +
  • org.osgi.framework.bootdelegation - This property lists packages, +which are always used from the environment. As such, these packages will +never be looked up in package wirings as are packages imported by listing +them in the Import-Package bundle manifest header.
  • +
+

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

+ + + +
*sling.bootdelegation.simple = com.some.package* This setting +unconditionally adds the *com.some.package* package to the +*org.osgi.framework.bootdelegation* property
*sling.bootdelegation.class.com.some.other.Main = com.some.other* +This setting checks whether the *com.some.other.Main* class is known. If +so, the *com.some.other* package is added to the +*org.osgi.framework.bootdelegation* property. Otherwise the +*com.some.other* package is not added - and therefore must be exported by +a bundle if required for use inside the framework.
+ +

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 Support

+

As 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

+ + + +
*sling.system.packages.simple = com.some.package* This setting +unconditionally adds the *com.some.package* package to the +*org.osgi.framework.system.packages* property
*sling.system.packages.class.com.some.other.Main = com.some.other* +This setting checks whether the *com.some.other.Main* class is known. If +so, the *com.some.other* package is added to the +*org.osgi.framework.system.packages* property. Otherwise the +*com.some.other* package is not added - and therefore must be exported by +a bundle if required for use inside the framework.
+ +

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 names

+

The following system property names are reserved:

+
    +
  • Names starting with org.osgi. are reserved for OSGi defined +Framework properties
  • +
  • Names starting with org.apache.felix. are reserved for the Felix +Framework
  • +
  • Names starting with sling. and org.apache.sling. are reserved +for Sling
  • +
+

To prevent property name collisions, I suggest the following convention:

+
    +
  • Use fully qualified property names for initial configuration through +Framework properties
  • +
  • Use unqualified property names for configuration through the +Configuration Admin Service
  • +
+

+

Well Known Properties

+

The following table is a collection of well known property names from +different parts of Project Sling.

+ + + + + + + + + +
Property Description
*sling.home* Defines the file system location where Project Sling +will write copies of the initial configuration. This property should also +be used to define other local file system locations such as the directory +to use for the Apache Felix Bundle Cache (*$\{sling.home}/felix* by +default). If this property is not set it defaults to +*$\{user.dir}/sling*.
*sling.home.url* Contains the Sling directory set in the +*sling.home* property as a valid URL. This property may be used in +situations where the Sling directory is required as an URL. This property +is automatically set by the Sling application and may not be modified by +configuration files.
*sling.ignoreSystemProperties* Whether to overwrite any configuration +properties with Java system properties or not. By default this property is +set to *true* by the Sling Servlet but not set by the Sling main class. +The reason to set this by default in the Sling Servlet is to not induce +values from the environment, which may not be appropriate in the Web +Application case.
*obr.repository.url* A comma-separated list of OSGi Bundle Repository +URLs. See _Important Properties_ on the page [Initial Provisioning and Startup](launch-sling.html) +.
*sling.install.bundles* A comma-separated list of start level +numbers. See _Important Properties_ on the page [Initial Provisioning and Startup](launch-sling.html) +.
*sling.install.* A comma-separated list of bundle specifications. +See _Important Properties_ on the page [Initial Provisioning and Startup](launch-sling.html) +.
*org.apache.sling.osgi.log.** Properties providing initial +configuration to the Sling Log Service. See 'Important Properties' on the +page [Initial Provisioning and Startup](launch-sling.html) +.
+ +

+

Configuration Admin Service

+

Configuration 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.

Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/contributing.html ============================================================================== --- websites/staging/sling/trunk/content/contributing.html (original) +++ websites/staging/sling/trunk/content/contributing.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,39 @@ Home
+ +

+

Contributing

+

See SLINGxSITE:Project Information + for details about the tools mentioned below.

+

Apache Sling is a volunteer effort, so there is always plenty of work that +needs to be accomplished. If you want to help support Sling, this page is +intended as a starting point for specific contribution ideas. To further +understand how the Sling community operates, refer to the Community Roles +and Processes document and/or join the mailing lists.

+

The Sling project organizes its "to do" list using the JIRA issue tracking +system. Specific items from Sling's JIRA issue tracking system are +highlighted on this page, but are not limited to it. The purpose of the +list here is to highlight issues that are either more important or serve as +good entry points for new contributors.

+

It is important to point out that you do not need to be a programmer to +contribute to Sling. As such, we will break out the list of issues below +for non-programmers and programmers.

+

+

Non-Programmers

+
* Improve web site or documentation (e.g., create/propose FAQ entries).
+
+ +

There is no specific JIRA issue for this task, but any contributions could +be posted as new JIRA issues for the Documentation component.

+

+

Programmers

+
* Implement support for various rendering technologies in Sling.
+
+ + +

Examples coming to mind are JSF and Wicket.

Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/default-mapping-and-rendering.html ============================================================================== --- websites/staging/sling/trunk/content/default-mapping-and-rendering.html (original) +++ websites/staging/sling/trunk/content/default-mapping-and-rendering.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,10 @@ Home
- + +

This page contained obsolete content, moved it to +http://cwiki.apache.org/confluence/display/SLING/Default+Mapping+and+Rendering+%28OBSOLETE%29 +in case it is useful to someone.

Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/dependency-management.html ============================================================================== --- websites/staging/sling/trunk/content/dependency-management.html (original) +++ websites/staging/sling/trunk/content/dependency-management.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,94 @@ Home
+ +

+

Dependency Management

+

{excerpt}This page is about how we do and don't do dependency management in +the Sling project.{excerpt}

+

{toc:minLevel=2}

+

+

Introduction

+

Maven provides projects with a nice feature called dependency management. +In Sling we currently use this feature to declare the non-Sling +dependencies of modules in the parent POM.

+

After working with this some time and trying to upgrade various +dependencies we came to the conclusion, that using Maven dependency +management is not going to work out in the Sling scenario.

+

Why ? Maven's dependency management is aimed at traditional applicaitons, +which are glued together statically during the build process. For this +environment, dependency management is a great thing, since it guarantees a +consistent application setup.

+

In a dynamic application setup as provided by an OSGi framework the static +dependency management of Maven does not help. Actually it even causes +problematic results with respect to backwards compatibility when using the +Maven Bundle plugin.

+

Why's that ? The Maven Bundle plugin is constructs the bundle manifest and +will generally automatically create the Import-Package header. If the +providing library (from maven's dependency list) has Export-Package +headers with version numbers, the Maven Bundle plugin will insert the +respective version numbers for the Import-Package header. This makes +perfect sense, because it is expected, that the artifact required at least +the given package version.

+

When using Maven dependency management, upgrading any dependencies in the +parent POM may automatically increse the version numbers in the +Import-Package headers and hence may cause any such bundle to fail +resolution if deployed - even though the bundle did not change and does not +really require a new version of the dependency.

+

So, in the case of OSGi deployment, Maven's dependency management actually +interferes with the OSGi framework dependency management.

+

As a consequence, I suggest we drop dependency management in the parent pom +(almost) completely and state the followin.

+

+

Dependency Management

+

The parent pom only does dependency management for build time dependencies +and a very limited number of API dependencies used Sling wide. These +dependencies are:

+
    +
  • All plugin dependencies. That is PluginManagement is still used. +Maven plugins are actualy build time dependencies and therefore have no +influence on the actual deployment.
  • +
  • Dependencies on commonly used testing environment helpers. Test helper +classes are also build time dependencies used to run the unit and +integration tests. As such, they may well be managed.
  • +
  • Sling makes a small number of assumptions about the environment, which +we codify in the dependency management: The minimum version number of the +OSGi specificaiton used, the servlet API version and the JCR API version.
  • +
+

The element currently contains the following +managed dependencies:

+ + + + + + + + + + +
Group ID Artifact ID Version Scope
org.apache.felix org.osgi.core 1.2.0 provided
org.apache.felix org.osgi.compendium 1.2.0 provided
javax.servlet servlet-api 2.4 provided
javax.jcr jcr 1.0 provided
org.slf4j slf4j-api 1.5.2 provided
junit junit 4.3 test
org.jmock jmock-junit4 2.2.0 test
org.slf4j slf4j-simple 1.5.2 test
+

All dependencies per module are fully described in terms of version, scope, +and classifier by the respective project.

+

The version of the module dependency should be selected according to the +following rule: The lowest version providing the functionality required by +the module (or bundle). By required functionality we bascially mean +provided API.

+

Generally there is a constant flow of releases of dependent libraries. In +general this should not cause the dependency version number of a using +module to be increased. There is one exception though: If the fixed library +version contains a bug fix, which has an influence on the operation of the +module, an increase in the version number is indicated and should also be +applied.

+

+

References

+
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/development.html ============================================================================== --- websites/staging/sling/trunk/content/development.html (original) +++ websites/staging/sling/trunk/content/development.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,47 @@ Home
+ +

+

Development

+

Welcome to the wonderful world of extending Sling. Refer to these pages to +find out how we envision the extension of Sling and how to do it.

+

+

Using Sling as your Development Framework

+

Look here for more information on developper support when your are using +Sling to build your own applications.

+
* [Getting and Building Sling](getting-and-building-sling.html)
+* [Embedding Sling](embedding-sling.html)
+* [Logging](logging.html)
+* [Client Request Logging](client-request-logging.html)
+* [Monitoring Requests](monitoring-requests.html)
+* [Repository Based Development](repository-based-development.html)
+* [Sling Testing Tools](sling-testing-tools.html)
+
+ +

+

Maven 2 stuff

+

Sling is using Apache Maven as it build system. Over time we have created a +number of Maven 2 Plugins and gathered a whole range of knowledge about +using Maven.

+
* [Maven Tips & Tricks](maventipsandtricks.html)
+* [Maven Sling Plugin](sling.html)
+* [Maven JspC Plugin](jspc.html)
+* [Maven Launchpad Plugin](maven-launchpad-plugin.html)
+* [Maven Archetypes](maven-archetypes.html)
+
+ + +

+

Sling Development

+

Last but not least, here is some more information on how we ourselves are +working on Sling

+
* [Dependency Management](dependency-management.html)
+* [Version Policy](version-policy.html)
+* [Issue Tracker](issue-tracker.html)
+* [Release Management](release-management.html)
+
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/discover-sling-in-15-minutes.html ============================================================================== --- websites/staging/sling/trunk/content/discover-sling-in-15-minutes.html (original) +++ websites/staging/sling/trunk/content/discover-sling-in-15-minutes.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,244 @@ Home
+ +

+

Discover Sling in 15 minutes - the Sling Launchpad

+

The Sling Launchpad is a ready-to-run Sling configuration, providing an +embedded JCR content repository and web server, a selection of Sling +components, documentation and examples. The Launchpad makes it easy to get +started with Sling and to develop script-based applications.

+

This page will help you get started with the Launchpad. Fifteen minutes +should be enough to get an overview of what Sling does.

+

While simple to run and understand, the Launchpad is a full-featured +instance of Sling, an example configuration that we have created with the +most common modules and configurations. The full functionality of Sling is +available by loading additional Sling (or custom) OSGi bundles as needed, +using the Launchpad's web-based OSGi management console.

+

+

See Also

+

Example applications and mini-applications for Sling can be found under +http://svn.apache.org/repos/asf/sling/trunk/samples/ (each application has +a README.txt file, see these for more details).

+

Once you grok the basic examples of this page, we recommend studying the +espblog and webloader samples for more complete examples. The +javashell sample is useful to play with JCR java code (or any java code, +for that matter) interactively.

+

+

Prerequisites

+

We'll start with the self-runnable jar from the Sling distribution, you +only need a Java 5 JDK. Download the latest release from the Sling Downloads + page or by clicking this link: [org.apache.sling.launchpad-6-standalone.jar|http://www.apache.org/dyn/closer.cgi/sling/org.apache.sling.launchpad-6-standalone.jar] +. Alternatively you can deploy the [Sling Web application|http://www.apache.org/dyn/closer.cgi/sling/org.apache.sling.launchpad-6.war] + into any decent Servlet Container such as Jetty or Tomcat or you can [build the current source yourself|Getting and Building Sling] +.

+

To show the simplicity of the REST-style approach taken by Sling the +examples below will be using cURL +. Any HTTP client would do, but cURL is the easiest to document in a +reproducible way.

+

A WebDAV client makes editing server-side scripts much more convenient, but +to make our examples easy to reproduce, we're using cURL below to create +and update files in the JCR repository, via the Sling WebDAV server.

+

+

Start the Launchpad

+

After downloading the Sling Launchpad self-runnable jar just start it as +follows:

+
$ java -jar org.apache.sling.launchpad-6-standalone.jar
+
+ +

This starts the Sling embedded Web Server on port 8080 and writes +application files into the sling folder found in the current working +directory.

+

Once started, look at http://localhost:8080/system/console/bundles + with your browser. Use admin with password admin if Sling asks you for +a login. Sling then displays the Felix Web Management Console page.

+

On the bundles page, all bundles should be marked Active. They're all OSGi + bundles powered by [Apache Felix|http://felix.apache.org] +, but that doesn't really matter to us right now.

+

{tip:title=Log files} +If things go wrong, have a look at the sling/logs/error.log log file - +that's where Sling writes any error messages. +{tip}

+

+

Create some content

+

Until we have ready-to-test forms, you can create content with cURL, or you +can create an HTML form that posts to the specified URL.

+

To create a content node (nodes are a JCR + concept, a unit of storage) with cURL, use:

+
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some title"
+
+ + +

http://localhost:8080/content/mynode

+

The resulting node can be seen at http://localhost:8080/content/mynode.html +, or as json format under [http://localhost:8080/content/mynode.json|http://localhost:8080/content/mynode.json] +. Lets try with cURL:

+
$ curl http://localhost:8080/content/mynode.json
+{"title":"some
+
+ + +

title","sling:resourceType":"foo/bar","jcr:primaryType":"nt:unstructured"}

+

This returns the properties of the /content/mynode in JSON format as we +have created it above. The additional property jcr:primaryType is a +special JCR property indicating the JCR primary node type.

+

{tip:title=Monitoring requests} +Sling provides a simple tool (an OSGi console plugin) to monitor HTTP +requests, which helps understand how things work internally. See the Monitoring Requests + page for details. +{tip}

+

+

Render your content using server-side javascript (ESP)

+

Sling uses scripts or servlets to render and process content.

+

Several scripting languages are available as additional Sling modules +(packaged as OSGi bundles that can be installed via the Sling management +console), but the launchpad currently includes the ESP (server-side +ECMAscript), JSP (Java Server Pages), and Groovy language modules by +default.

+

To select a script, Sling uses the node's sling:resourceType property, if +it is set.

+

That is the case in our example, so the following script will be used by +Sling to render the node in HTML, if the script is found at +/apps/foo/bar/html.esp in the repository.

+

html.esp
+ + +

<%= currentNode.title %>

+ +

+

To select the script, Sling: + looks under /apps and appends the sling:resourceType value of our node ( which is +foo/bar ) +* and appends html.esp, as the extension of our URL is html and the +language of our script is esp.

+

Store this script under /apps/foo/bar/html.esp, either using a WebDAV +client (connected to http://admin:admin@localhost:8080/ +), or using cURL as shown here, after creating the html.esp script in the +current directory on your system:

+
curl -X MKCOL -u admin:admin http://localhost:8080/apps/foo
+curl -X MKCOL -u admin:admin http://localhost:8080/apps/foo/bar
+
+ + +

create a local file html.esp and copy above content.

+
curl -u admin:admin -T html.esp http://localhost:8080/apps/foo/bar/html.esp
+
+ + +

The HTML rendering of your node, at http://localhost:8080/content/mynode.html +, is now created by this ESP script. You should see the node's title alone +as an

element in that page.

+

A script named POST.esp instead of html.esp would be called for a POST +request, DELETE.esp for DELETE, xml.esp for a GET request with a .xml +extension, etc. See URL to Script Resolution + on the Sling wiki for more info.

+

Servlets can also be easily "wired" to handle specific resource types, +extensions, etc., in the simplest case by using SCR annotations in the +servlet source code. Servlets and scripts are interchangeable when it comes +to processing Sling requests.

+

+

What next?

+

These simple examples show how Sling uses scripts to work with JCR data, +based on sling:resourceType or node types.

+

There's much more to Sling of course - you'll find some additional simple +examples below, and above in the see also section.

+

We are working on debugging features to help trace the way Sling processes +requests. Have a look at SLING-3 + to see what's possible already.

+

+

Additional examples

+

+

Let Sling generate the path of a newly created node.

+

To create a node with a unique path at a given location, end the URL of the +POST request with /.

+

In this case, the Sling response redirects to the URL of the created node.

+

Start by creating a new /blog folder:

+
curl -X POST -u admin:admin "http://localhost:8080/content/blog"
+
+ + +

And create a node with a Sling-generated name under it:

+
curl -D - -u admin:admin -F"title=Adventures with Sling"
+
+ + +

"http://localhost:8080/content/blog/"

+

Using cURL's -D option shows the full HTTP response, which includes a +Location header to indicate where the new node was created:

+
Location: /blog/adventures_with_slin
+
+ + +

The actual node name might not be adventures_with_slin - depending on +existing content in your repository, Sling will find a unique name for this +new node, based on several well-know property values like title, +description, etc. which are used for this if provided.

+

So, in our case, our new node can be displayed in HTML via the http://localhost:8080/blog/adventures_with_slin.html + URL.

+

Note that we didn't set a sling:resourceType property on our node, so if +you want to render that node with a script, you'll have to store the script +under /apps/nt/unstructured/html.esp.

+

+

Add a page header with sling.include

+

The sling.include function can be called from scripts to include the +rendered result of another node.

+

In this example, we create a node at /content/header, rendered with a +logo using an html.esp script, then use that header at the top of the +html.esp script that we created previously for the foo/bar resource +type.

+

Start by checking that http://localhost:8080/content/mynode.html + is rendered using the html.esp script created above.

+

Create this script and name it header.esp:

+

header.esp
+
+

+ + <%= currentNode.headline %> +

+

+

Upload it so that it is used to render resources having +sling:resourceType=foo/header:

+
curl -X MKCOL -u admin:admin http://localhost:8080/apps/foo/header/
+curl -u admin:admin -T header.esp
+
+ + +

http://localhost:8080/apps/foo/header/html.esp

+

Create the header node:

+
curl -u admin:admin -F"sling:resourceType=foo/header" -F"headline=Hello,
+
+ + +

Sling world" http://localhost:8080/content/header

+

Upload the logo that the script uses (using sling.jpg or another logo in +the current directory):

+
curl -X MKCOL -u admin:admin http://localhost:8080/images/
+curl -u admin:admin -T sling.jpg http://localhost:8080/images/sling.jpg
+
+ + +

And check that the header is rendered with the logo at http://localhost:8080/content/header.html +.

+

Now, update the html.esp script that we created for our first example +above, to include the header:

+

html.esp
+ + + +

<%= currentNode.title %>

+ +

+

And upload it again to replace the previous version:

+
curl -u admin:admin -T html.esp http://localhost:8080/apps/foo/bar/html.esp
+
+ + +

The http://localhost:8080/content/mynode.html +, once refreshed, now shows the blue headline and logo, and this layout +also applies to any node created with sling:resourceType=foo/bar.

Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/dispatching-requests.html ============================================================================== --- websites/staging/sling/trunk/content/dispatching-requests.html (original) +++ websites/staging/sling/trunk/content/dispatching-requests.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,202 @@ Home
+ +

+

Request Processing

+

+

Main process

+

The following steps should give you an overview how a request is processed +in Sling. Details can be found under provided links.

+

+

Step 1

+

The client sends the request

+

+

Step 2

+

This step applies only if a Servlet Container is installed and Sling is +embedded: +Servlet Container gets request and forwards to OSGi HttpService

+

+

Step 3

+

OSGi HttpService looks for responsible registered Servlet or resource (see +102.4 of the OSGi compendium)

+

+

Step 4

+

OSGi HttpService calls handleSecurity of the HttpContext associated +with the servlet/resource. In case of Sling this calls into +SlingMainServlet.handleSecurity and then into +SlingAuthenticator.authenticate

+

+

Step 4a

+

SlingAuthenticator selects an authentication handler for the request and +forwards the authenticate call. On success a javax.jcr.Session is +created, the request attributes required by the HTTP Service spec are set +(like org.osgi.service.http.authentication.remote.user and +org.osgi.service.http.authentication.typeand also the +javax.jcr.Session which is used later is set in the request attributes. +On success, continue with step 5.

+

+

Step 4b

+

If authentication fails either an anonymous session is acquired (if +anonymous is allowed per configuration) or the login method is called. +If anonymous is allowed, continue with step 5.

+

+

Step 4c

+

The login method selects an AuthenticationHandler and forwards the login +call to the AuthenticationHandler.requestAuthentication method to cause the +client to authenticate. Request processing stops here +(SlingMainServlet.handleSecurity returns false).

+

+

Step 5

+

After getting a response the HttpService either terminates the request (if +authentication failed and SlingMainServlet.handleSecurity returned +false) or continues by either spooling the resource or in the case of Sling +calling the SlingMainServlet.service method.

+

+

Step 6

+

The SlingMainServlet.service method is the entry point into the Sling +proper. This method sets up the request: + Wraps the HttpServletRequest and the HttpServletResponse into the +SlingHttpServletRequest and the SlingHttpServletResponse + Checks if Sling is ready for processing the request (checks at the moment +for an existing ResourceResolverFactory service, a ServletResolver service +and a MimeTypeService) + Create the ResourceResolver based on the Session (by default creates a +JcrResourceResolver2) + Locate the Resource + on the basis of the request by calling ResourceResovler.resolve +through RequestData.initResource (see also [URL decomposition] +) + Locate the servlet or script (see Servlets +) by calling ServletResolver.resolveServlet through +RequestData.initServlet*

+

+

Step 7

+

After this setup, the request level filters are called (the ones registered +as javax.servlet.Filter with the property filter.scope=request, see Filters + for details). +If any called filter doesn't call FilterChain.doFilter at the end of +the Filter.doFilter method request processing stops here.

+

+

Step 8

+

After having called all request level filters, the component level filters +(registered with the property filter.scope=component, see Filters + for details) are called.

+

+

Step 9

+

After having called the component level filters, the request servlet or +script is finally called to process the request.

+

+

Include/Forward

+

If a servlet or script is including another resource for processing through +the RequestDispatcher.include or RequestDispatcher.forward (or any +JSP or feature of another scripting language which relies on one of this +two methods) the following processing takes place:

+

+

Step 1

+

Code in the processing servlet or script calls +RequestDispatcher.include or RequestDispatcher.forward.

+

+

Step 2

+

The resource is resolved though ResourceResolver.getResource (if the +RequestDispatcher has not been created with a resource already)

+

+

Step 3

+

The servlet or script to handle the resource is resolved calling the +ServletResolver.resolverServlet method.

+

+

Step 4

+

The component level filters (registered with the property +filter.scope=component) are called again (see Filters + for details).

+

+

Step 5

+

The servlet or script is called to process the request.

+

Note that these steps are processed for every include or forward call.

+

+

Included Request Attributes

+

When servlet or script is called as a result of +RequestDispatcher.include the following request attributes are set:

+ + +Attribute Type | Description | + +*javax.servlet.Servlet* | The name of the request attribute containing +the *Servlet* which included the servlet currently being active. | + +*org.apache.sling.api.resource.Resource* | The name of the request +attribute containing the *Resource* underlying the *Servlet* which +included the servlet currently being active. | + +*org.apache.sling.api.request.RequestPathInfo* | The name of the request +attribute containing the *RequestPathInfo* underlying the *Servlet* +which included the servlet currently being active | + +*String* | The name of the request attribute containing the +*HttpServletRequest.getRequestURI()* of the request which included the +servlet currently being active underlying the *Servlet* which included +the servlet currently being active. +*Note:* In Sling, the *HttpServletRequest.getRequestURI()* method will +always return the same result regardless of whether it is called from the +client request processing servlet or script or from an included servlet or +script. This request attribute is set for compatibility with the Servlet +API specification. | + +*String* | The name of the request attribute containing the +*HttpServletRequest.getContextPath()* of the request which included the +servlet currently being active underlying the *Servlet* which included +the servlet currently being active. +*Note:* In Sling, the *HttpServletRequest.getContextPath()* method will +always return the same result regardless of whether it is called from the +client request processing servlet or script or from an included servlet or +script. This request attribute is set for compatibility with the Servlet +API specification. | + +*String* | The name of the request attribute containing the +*HttpServletRequest.getServletPath()* of the request which included the +servlet currently being active underlying the *Servlet* which included +the servlet currently being active. +*Note:* In Sling, the *HttpServletRequest.getServletPath()* method will +always return the same result regardless of whether it is called from the +client request processing servlet or script or from an included servlet or +script. This request attribute is set for compatibility with the Servlet +API specification. | + +*String* | The name of the request attribute containing the +*HttpServletRequest.getPathInfo()* of the request which included the +servlet currently being active underlying the *Servlet* which included +the servlet currently being active. +*Note:* In Sling, the *HttpServletRequest.getPathInfo()* method will +always return the same result regardless of whether it is called from the +client request processing servlet or script or from an included servlet or +script. This request attribute is set for compatibility with the Servlet +API specification. + +*String* | The name of the request attribute containing the +*HttpServletRequest.getQueryString()* of the request which included the +servlet currently being active underlying the *Servlet* which included +the servlet currently being active. +*Note:* In Sling, the *HttpServletRequest.getQueryString()* method will +always return the same result regardless of whether it is called from the +client request processing servlet or script or from an included servlet or +script. This request attribute is set for compatibility with the Servlet +API specification. | +
Attribute Name +
*org.apache.sling.api.include.servlet* +
*org.apache.sling.api.include.resource* +
*org.apache.sling.api.include.request_path_info* +
*javax.servlet.include.request_uri* +
*javax.servlet.include.context_path* +
*javax.servlet.include.servlet_path* +
*javax.servlet.include.path_info* +
*javax.servlet.include.query_string* +
+

Constants are defined in the org.apache.sling.api.SlingConstants class +for these request attributes.

+

Note: These request attributes are not set if the servlet or script is +called to handle the request or as a result of +RequestDispatcher.forward.

Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. Modified: websites/staging/sling/trunk/content/documentation.html ============================================================================== --- websites/staging/sling/trunk/content/documentation.html (original) +++ websites/staging/sling/trunk/content/documentation.html Sun Apr 22 17:20:11 2012 @@ -82,7 +82,142 @@ Home
+ +

+

Documentation

+

The documentation is split into different parts:

+ +

+

How can you contribute

+

We're on the way to improve the documentation, but it's a long way. If you +would like to contribute to the documentation you are very welcome. Please +directly post your proposals to the public wiki + or post your suggestions to the mailing list.

+

+

How is the documentation generated

+

The basic documentation of Sling is made up of four parts:

+
    +
  1. The Sling Site at http://sling.apache.org/ (you are here)
  2. +
  3. The Public Wiki at http://cwiki.apache.org/SLING
  4. +
  5. The JavaDoc
  6. +
  7. The Bundle documentation
  8. +
+

This page is about how this documentation is maintained and who is allowed +to do what.

+

+

The Sling Site

+

+

Main Site

+

The main Sling Site is maintained in the Confluence Wiki Space +SLINGxSITE. The content of this space is automatically synchronized with +the web server with a simple shell script ^sling.sh + which is called regularly as per the following crontab entry:

+
# sync wiki autoexport to Sling site
+1 * * * * (/home/fmeschbe/sling.sh)
+
+ +

Thus, after editing the site source in the Wiki, the rest happens +automatically, it just takes some time -- in the order 2 hours or so -- +before the changes are visible at http://sling.apache.org/.

+

Everybody is allowed to read the SLINGxSITE wiki and to add comments; but +only committers of the Apache Sling project are allowed to edit the content +and to manage the comments.

+

The main site is located in the site folder below the Site URL http://sling.apache.org/ + to which users are redirected automatically.

+

+

Secondary Site

+

The Sling site contains secondary site parts that are maintained in the +Apache SVN repository at http://svn.apache.org/repos/asf/sling/site +. Updates to secondary parts of the site have to be done in the following +steps:

+
    +
  1. +

    Checkout or update the site + tree form SVN.

    +

    $ svn checkout https://svn.apache.org/repos/asf/sling/site

    +
  2. +
  3. +

    Apply your changes.

    +
  4. +
  5. +

    Commit the changes back into SVN.

    +

    $ svn commit -m""

    +
  6. +
  7. +

    Login to people.apache.org

    +

    $ ssh people.apache.org

    +
  8. +
  9. +

    Go to the location from where infrastructure mirroring is getting the +actual sites and update from SVN.

    +

    $ cd /x1/www/sling.apache.org +$ svn update

    +
  10. +
+

After some time, the updates will be synchronized to the web servers and +can be accessed.

+

+

The Public Wiki

+

The public wiki of Sling is available at http://cwiki.apache.org/SLING and +is maintained in the Confluence space SLING. This is a public wiki, in +that after self-registration, everybody is allowed to edit content.

+

+

The JavaDoc

+

Up until now the JavaDoc of the Sling Bundles has not been published.

+

I just polished the JavaDoc generation setup of Sling a bit, so that I +could generate a first shot of aggregate JavaDocs. This draft can currently +be found on my site at +http://people.apache.org/~fmeschbe/slingdocs.762729/. This JavaDoc has been +generated as follows:

+
$ svn export -r 762729
+
+ + +

http://svn.apache.org/repos/asf/incubator/sling/trunk sling + $ mvn -DexcludePackageNames=".impl:.internal:.jsp:sun.misc:.juli" +org.apache.maven.plugins:maven-javadoc-plugin:2.5:aggregate

+

I am still unsure whether it makes sense to generate aggregate JavaDoc for +all (or part of) the bundles of Sling. See also below regarding the Sites.

+

+

The Bundle Documentation

+

Apart from the documentation of Sling on the Site and in the Wiki, it would +also be thinkable that we accompany the source modules with some +documentation and generate this using the Maven Site plugin. My tests so +far for generating a multi-module site have not been very successful. But +generating the site in a module-by-module manner might be a good thing, at +least to get the per-module JavaDoc and some more code-oriented information +like Surefire Reports, fixed bugs, etc.

+

To prepare such Bundle Documentation I added a first shot at site +generation setup to the parent project. For now, this includes the module's +JavaDoc (of course), the Surefire reports and a report on the issues fixed +(or open) with respect to some version. This site generation setup can be +configured per module with two properties:

+ + + +
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Property Description
*site.jira.version.id* The ID of the JIRA version whose bugs are to +be listed in the JIRA report. This is a number, such as 12313306 (Sling API +version 2.0.4).
*site.javadoc.exclude* The Java packages to not include with the +JavaDoc generation. By default all packages containing *impl* or +*internal* in their name are excluded. To add more packages for +exclusion, list them in the format suitable for the [*excludePackageNames*](http://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#excludePackageNames) + property of the Maven JavaDoc plugin. For example, to exclude any *jsp* +and *juli* packages (see the _scripting/jsp_ bundle), this property would +be set to *\*.jsp:\*.juli*.