You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2012/05/22 10:25:22 UTC
svn commit: r1341347 [12/16] - in /sling/site/trunk: ./ content/
content/tutorials-how-tos/
Modified: sling/site/trunk/content/request-processing.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/request-processing.mdtext?rev=1341347&r1=1341346&r2=1341347&view=diff
==============================================================================
--- sling/site/trunk/content/request-processing.mdtext (original)
+++ sling/site/trunk/content/request-processing.mdtext Tue May 22 08:25:18 2012
@@ -1,269 +1,111 @@
Title: Request Processing
-<a name="RequestProcessing-HTTPRequestProcessing"></a>
+
# HTTP Request Processing
{note:title=Page Status}
-2008-02-13: this page is *out of sync* with the current codebase, needs to
-be reviewed and updated.
+2008-02-13: this page is *out of sync* with the current codebase, needs to be reviewed and updated.
{note}
-One of the core problems towards understanding how Sling works is knowing
-how a Client Request is processed by Sling. This page describes the flow of
-processing requests inside Sling.
+One of the core problems towards understanding how Sling works is knowing how a Client Request is processed by Sling. This page describes the flow of processing requests inside Sling.
-<a name="RequestProcessing-CoreRequestProcessing"></a>
## Core Request Processing
-The HTTP request enters Sling in the
-{{org.apache.sling.core.ComponentRequestHandlerImpl.service(ServletRequest
-req, ServletResponse res)}} method as the *ComponentRequestHandlerImpl*
-is registered as the Servlet handling HTTP requests. This method sets up
-the initial *ComponentRequest* and *ComponentResponse* objects and
-hands the request over to the first *ComponentFilterChain*. This first
-filter chain calls all *ComponentFilter* instances registered as request
-level filters. After processing all filters in the request level filter
-chain, the request is handed over to the second *ComponentFilterChain*
-which calls all *ComponentFilter* instances registered as component level
-filters. At the end of the second filter chain the *service* method of
-the actual *Component* to which the request resolved is called.
-
-As the component is now processing the request, it may decide to dispatch
-the request to some other content such as for example a paragraph system or
-navigation component. To do this, the component will call the
-*RequestDispatcher.include* method. If the request dispatcher dispatches
-to a *Content* object Sling will hand the dispatch request over to the
-component level filter chain, which at the end will call the *service*
-method for the *Content* object to dispatched to. This process may be
-repeated at the component's discretion only limited by processing resources
-such as available memory.
-
-
-As can be seen Sling itself is absed on the Component API
-*ComponentFilter* mechanism. As such Sling provides and uses the
-following filters in the Sling Core bundle:
+The HTTP request enters Sling in the `org.apache.sling.core.ComponentRequestHandlerImpl.service(ServletRequest req, ServletResponse res)` method as the `ComponentRequestHandlerImpl` is registered as the Servlet handling HTTP requests. This method sets up the initial `ComponentRequest` and `ComponentResponse` objects and hands the request over to the first `ComponentFilterChain`. This first filter chain calls all `ComponentFilter` instances registered as request level filters. After processing all filters in the request level filter chain, the request is handed over to the second `ComponentFilterChain` which calls all `ComponentFilter` instances registered as component level filters. At the end of the second filter chain the `service` method of the actual `Component` to which the request resolved is called.
+
+As the component is now processing the request, it may decide to dispatch the request to some other content such as for example a paragraph system or navigation component. To do this, the component will call the `RequestDispatcher.include` method. If the request dispatcher dispatches to a `Content` object Sling will hand the dispatch request over to the component level filter chain, which at the end will call the `service` method for the `Content` object to dispatched to. This process may be repeated at the component's discretion only limited by processing resources such as available memory.
+
+
+As can be seen Sling itself is absed on the Component API `ComponentFilter` mechanism. As such Sling provides and uses the following filters in the Sling Core bundle:
{table:class=confluenceTable}
{tr}{th:colspan=2|class=confluenceTh} Request Level Filters {th}{tr}
-{tr}{td:class=confluenceTd} *ErrorHandlerFilter*
-{td}{td:class=confluenceTd} Handles exceptions thrown while processing the
-request as well implements the *ComponentResponse.sendError()* method
-{td}{tr}
-{tr}{td:class=confluenceTd} *AuthenticationFilter*
-{td}{td:class=confluenceTd} Implements authentication for the request and
-provides the JCR Session of the request {td}{tr}
-{tr}{td:class=confluenceTd} *BurstCacheFilter*
-{td}{td:class=confluenceTd} Checks whether the request may be handled by
-cached response data {td}{tr}
-{tr}{td:class=confluenceTd} *LocaleResolverFilter*
-{td}{td:class=confluenceTd} Provides information on the *Locale* to be
-used for request processing. This filter implements the
-*ComponentRequest.getLocale()* method {td}{tr}
-{tr}{td:class=confluenceTd} *ThemeResolverFilter*
-{td}{td:class=confluenceTd} Provides the *Theme* for the request. The
-theme is provided as a request attribute {td}{tr}
-{tr}{td:class=confluenceTd} *URLMapperFilter* {td}{td:class=confluenceTd}
-Resolves the request URL to a JCR Node which may be mapped into a
-*Content* object {td}{tr}
-{tr}{td:class=confluenceTd} *ZipFilter* {td}{td:class=confluenceTd}
-Sample filter showing how the request response might be compressed
-according to the _Accept-Encoding_ request header. This filter is not
-enabled by default. {td}{tr}
+{tr}{td:class=confluenceTd} `ErrorHandlerFilter` {td}{td:class=confluenceTd} Handles exceptions thrown while processing the request as well implements the `ComponentResponse.sendError()` method {td}{tr}
+{tr}{td:class=confluenceTd} `AuthenticationFilter` {td}{td:class=confluenceTd} Implements authentication for the request and provides the JCR Session of the request {td}{tr}
+{tr}{td:class=confluenceTd} `BurstCacheFilter` {td}{td:class=confluenceTd} Checks whether the request may be handled by cached response data {td}{tr}
+{tr}{td:class=confluenceTd} `LocaleResolverFilter` {td}{td:class=confluenceTd} Provides information on the `Locale` to be used for request processing. This filter implements the `ComponentRequest.getLocale()` method {td}{tr}
+{tr}{td:class=confluenceTd} `ThemeResolverFilter` {td}{td:class=confluenceTd} Provides the `Theme` for the request. The theme is provided as a request attribute {td}{tr}
+{tr}{td:class=confluenceTd} `URLMapperFilter` {td}{td:class=confluenceTd} Resolves the request URL to a JCR Node which may be mapped into a `Content` object {td}{tr}
+{tr}{td:class=confluenceTd} `ZipFilter` {td}{td:class=confluenceTd} Sample filter showing how the request response might be compressed according to the *Accept-Encoding* request header. This filter is not enabled by default. {td}{tr}
{table}
-Deducing from these lists of filters, the actual request processing can be
-refined into the following steps:
+Deducing from these lists of filters, the actual request processing can be refined into the following steps:
+
+1. Extract user authentication information and acquire the JCR session to access content. If the request has no user authentication data the such data may be requested from the user (for example by sending a HTTP 401 status) or an anonymous repository session might be acquired.
+1. Check whether the request may be handled by data stored in the cache. If the request is cacheable and a cache entry exists for the request URL, the request data is returned to the client and request processing may terminate. Otherwise request processing will continue and optionally ensure that any response data is entered into the cache. Of course, if the request is not cacheable, for example because there are request parameters, or if any of the `Component` instances called during request processing decide to signal non-cacheability for whatever reason, the response data will of course not cached.
+1. Extract the `java.util.Locale` from the request such that further processing may use properly translated messages. By default, the locale of the underlying Servlet request is used as the request locale. Other possibilities would be to use special cookies or some locale encoding in the path.
+1. Find the theme (or skin) to use to render the response. This step will add a `org.apache.sling.theme.Theme` object as a request parameter, which may be used by `Component`s to decide on specific rendering. For example, the theme may encapsulate information on the CSS to use for responses rendered as HTML.
+1. Resolve the request URL into a `Content` object.
-1. Extract user authentication information and acquire the JCR session to
-access content. If the request has no user authentication data the such
-data may be requested from the user (for example by sending a HTTP 401
-status) or an anonymous repository session might be acquired.
-1. Check whether the request may be handled by data stored in the cache.
-If the request is cacheable and a cache entry exists for the request URL,
-the request data is returned to the client and request processing may
-terminate. Otherwise request processing will continue and optionally ensure
-that any response data is entered into the cache. Of course, if the request
-is not cacheable, for example because there are request parameters, or if
-any of the *Component* instances called during request processing decide
-to signal non-cacheability for whatever reason, the response data will of
-course not cached.
-1. Extract the *java.util.Locale* from the request such that further
-processing may use properly translated messages. By default, the locale of
-the underlying Servlet request is used as the request locale. Other
-possibilities would be to use special cookies or some locale encoding in
-the path.
-1. Find the theme (or skin) to use to render the response. This step will
-add a *org.apache.sling.theme.Theme* object as a request parameter, which
-may be used by *Component*s to decide on specific rendering. For example,
-the theme may encapsulate information on the CSS to use for responses
-rendered as HTML.
-1. Resolve the request URL into a *Content* object.
-
-
-The default request level filter chain setup ends with finding the
-*Content* object requested by the request URL. After having found this
-object, the request is handed over to the component level filter chain,
-which is concerned with handling filtering on a single *Content*
-instance. As such, the component level filter chain is used for each
-*Content* object which is to be serviced either on behalf of the HTTP
-request or on behalf of request dispatcher. Thus the component level filter
-chain will generally called multiple times during a single request.
+
+The default request level filter chain setup ends with finding the `Content` object requested by the request URL. After having found this object, the request is handed over to the component level filter chain, which is concerned with handling filtering on a single `Content` instance. As such, the component level filter chain is used for each `Content` object which is to be serviced either on behalf of the HTTP request or on behalf of request dispatcher. Thus the component level filter chain will generally called multiple times during a single request.
{table:class=confluenceTable}
{tr}{th:colspan=2|class=confluenceTh} Component Level Filters {th}{tr}
-{tr}{td:class=confluenceTd} *CacheFilter* {td}{td:class=confluenceTd}
-Checks whether the request to the current *Content* object may be handled
-by cached response data {td}{tr}
-{tr}{td:class=confluenceTd} *ComponentResolverFilter*
-{td}{td:class=confluenceTd} Resolves the component ID returned by the
-*Content.getComponentId()* method into a *Component* instances, which
-will be called to service the request {td}{tr}
+{tr}{td:class=confluenceTd} `CacheFilter` {td}{td:class=confluenceTd} Checks whether the request to the current `Content` object may be handled by cached response data {td}{tr}
+{tr}{td:class=confluenceTd} `ComponentResolverFilter` {td}{td:class=confluenceTd} Resolves the component ID returned by the `Content.getComponentId()` method into a `Component` instances, which will be called to service the request {td}{tr}
{table}
-Again, deducing from the list of filters, the following steps are taking to
-service a given *Content* object:
+Again, deducing from the list of filters, the following steps are taking to service a given `Content` object:
+
+1. Check whether the `Content` object processing may be handled from the cache. Same as with request level cache handling, a cache entry may exist for a single `Content` instance depending on whether the request is cacheable at all and on whether a cache entry exists. If a cache entry exists and may be used, the response data is simply spooled into the response and component level processing terminates for the `Content` object. Otherwise processing continues and may optionally lead to a new cache entry for the `Content` object to be reused later.
+1. Resolve the component ID returned by the `Content.getComponentId()` method into a `Component` object. Of course it is an error, if the component ID cannot be mapped into a `Component` object.
-1. Check whether the *Content* object processing may be handled from
-the cache. Same as with request level cache handling, a cache entry may
-exist for a single *Content* instance depending on whether the request is
-cacheable at all and on whether a cache entry exists. If a cache entry
-exists and may be used, the response data is simply spooled into the
-response and component level processing terminates for the *Content*
-object. Otherwise processing continues and may optionally lead to a new
-cache entry for the *Content* object to be reused later.
-1. Resolve the component ID returned by the *Content.getComponentId()*
-method into a *Component* object. Of course it is an error, if the
-component ID cannot be mapped into a *Component* object.
-
-After resolving the *Component* object default component filter chain
-terminates and control is handed over to the *service* method of the
-*Component* object resolved in the last step. At the discretion of the
-component request dispatchers may now be acquired to render other
-*Content* objects. In this case the component level filter chain is
-simply kicked of again resulting in the *service* method of another
-*Component* being called. And so forth.
+After resolving the `Component` object default component filter chain terminates and control is handed over to the `service` method of the `Component` object resolved in the last step. At the discretion of the component request dispatchers may now be acquired to render other `Content` objects. In this case the component level filter chain is simply kicked of again resulting in the `service` method of another `Component` being called. And so forth.
-<a name="RequestProcessing-ResolvingContent"></a>
## Resolving Content
-As we have seen, the last step in the request level filter chain is the
-resolution of the request URL into a *Content* object. The URL Mapper
-Filter implementing this resolution uses an instance of the
-*org.apache.sling.content.ContentMapper* interface which is acquired by
-calling the *org.apache.sling.content.jcr.JcrContentManagerFactory* with
-the repository session acquired by the authentication filter.
-
-The URL Mapper filter then tries to apply fixed mappings from request URL
-to destination paths to support shortcut URLs. For example the root path
-*/* may be mapped into the default landing page at */default/home*. The
-list of such mappings is configurable through the Configuration Admin
-Service.
-
-Next the URL Mapper tries to apply prefix matching patterns. A list of
-patterns is iterated checking whether the prefix applies and, if so,
-replacing the prefix with another prefix and trying to resolve the result.
-This functionality enables relocation of a subtree of the repository. For
-example, all requests whose prefix is */here* might be remapped with the
-new prefix */content/there*. The result of this remapping is then
-resolved.
-
-Resolution (currently) takes place on the last path segment of the request
-URL containing at least one dot. Parts of that segment are cut off after
-dots until no more dots exist in the URL. For each resulting substring, the
-*ContentManager.load(String)* method is called. This processing
-terminates if a *Content* object is found or if there is nothing to cut
-off any more.
-
-This resolution is very simple and straight forwards. Future development
-may add support for the following features:
-
-* *Vanity URLs* - Map the request URL according to the *Host* request
-header.
-* *Dynamic Mapping* - Add support for a set of variables in path and/or
-prefix mapping. For example, a prefix mapping may contain the string
-*/content/$\{lang}/$\{user*} resulting in resolving a prefix according to
-the language of the current locale and the name of the authenticated used.
+As we have seen, the last step in the request level filter chain is the resolution of the request URL into a `Content` object. The URL Mapper Filter implementing this resolution uses an instance of the `org.apache.sling.content.ContentMapper` interface which is acquired by calling the `org.apache.sling.content.jcr.JcrContentManagerFactory` with the repository session acquired by the authentication filter.
+
+The URL Mapper filter then tries to apply fixed mappings from request URL to destination paths to support shortcut URLs. For example the root path `/` may be mapped into the default landing page at `/default/home`. The list of such mappings is configurable through the Configuration Admin Service.
+
+Next the URL Mapper tries to apply prefix matching patterns. A list of patterns is iterated checking whether the prefix applies and, if so, replacing the prefix with another prefix and trying to resolve the result. This functionality enables relocation of a subtree of the repository. For example, all requests whose prefix is `/here` might be remapped with the new prefix `/content/there`. The result of this remapping is then resolved.
+
+Resolution (currently) takes place on the last path segment of the request URL containing at least one dot. Parts of that segment are cut off after dots until no more dots exist in the URL. For each resulting substring, the `ContentManager.load(String)` method is called. This processing terminates if a `Content` object is found or if there is nothing to cut off any more.
+
+This resolution is very simple and straight forwards. Future development may add support for the following features:
+
+* *Vanity URLs* - Map the request URL according to the `Host` request header.
+* *Dynamic Mapping* - Add support for a set of variables in path and/or prefix mapping. For example, a prefix mapping may contain the string `/content/$\{lang}/$\{user`} resulting in resolving a prefix according to the language of the current locale and the name of the authenticated used.
-<a name="RequestProcessing-RegisteringComponents"></a>
## Registering Components
-The last step of the component level filter chain is resolving the
-*Component* from the component ID of the *Content* object. Sling
-implements this resolution by making use of the OSGi service registry. That
-is, each component is to be registered as a service with the name
-*org.apache.sling.component.Component*. The *ComponentResolverFilter*
-is listening for these components and registers them internally in a map
-indexed by the IDs of the component as returned by the
-*Component.getId()* method.
-
-When a component has to be resolved, the component ID returned by the
-*Content* object is simply looked up in the component map. If found, that
-component is used. Otherwise a fall back algorithm is applied which is
-described on the [Default Content Mapping and Request Rendering](default-mapping-and-rendering.html)
- page.
+The last step of the component level filter chain is resolving the `Component` from the component ID of the `Content` object. Sling implements this resolution by making use of the OSGi service registry. That is, each component is to be registered as a service with the name `org.apache.sling.component.Component`. The `ComponentResolverFilter` is listening for these components and registers them internally in a map indexed by the IDs of the component as returned by the `Component.getId()` method.
+
+When a component has to be resolved, the component ID returned by the `Content` object is simply looked up in the component map. If found, that component is used. Otherwise a fall back algorithm is applied which is described on the [Default Content Mapping and Request Rendering]({{ refs.default-mapping-and-rendering.path }}) page.
-<a name="RequestProcessing-ReqisteringFilters"></a>
## Reqistering Filters
-Just as *Component* instances used by Sling are expected to be registered
-as OSGi services, the *ComponentFilter*s to be
-used have to be registered as services under the name
-*org.apache.sling.component.ComponentFilter*. Sling picks up all
-registered component filters and adds them to the respective filter chains.
-
-Service properties set upon registration of the filter define the chain to
-which the filter belongs and the order in which the filters should be
-processed:
-
-<table>
-<tr><th> Property </th><th> Description </th></tr>
-<tr><td> *filter.scope* </td><td> Defines the chain to which the filter is added.
-Supported values are *component* for component level filters and
-*request* for request level filters. If this property is missing or set
-to an unknown value the filter is added to the request level filter chain.
-</td></tr>
-<tr><td> *filter.order* </td><td> Defines the weight of the filter to resolve the
-processing order. This property must be an *java.lang.Integer*. If not
-set or not an *Integer* the order defaults to *Integer.MAX_VALUE*. The
-lower the order number the earlier in the filter chain will the filter be
-inserted. If two filters are registered with the same order value, the
-filter with the lower *service.id* value is called first. </td></tr>
-</table>
+Just as `Component` instances used by Sling are expected to be registered as OSGi services, the `ComponentFilter`s to be
+used have to be registered as services under the name `org.apache.sling.component.ComponentFilter`. Sling picks up all registered component filters and adds them to the respective filter chains.
+
+Service properties set upon registration of the filter define the chain to which the filter belongs and the order in which the filters should be processed:
+
+| Property | Description |
+|--|--|
+| `filter.scope` | Defines the chain to which the filter is added. Supported values are `component` for component level filters and `request` for request level filters. If this property is missing or set to an unknown value the filter is added to the request level filter chain. |
+| `filter.order` | Defines the weight of the filter to resolve the processing order. This property must be an `java.lang.Integer`. If not set or not an `Integer` the order defaults to `Integer.MAX_VALUE`. The lower the order number the earlier in the filter chain will the filter be inserted. If two filters are registered with the same order value, the filter with the lower `service.id` value is called first. |
-<a name="RequestProcessing-ContentisaJavaObject"></a>
## Content is a Java Object
-It is crucial to understand that *Content* is an interface and the
-request processor of Sling does not actually care, how the *Content*
-instance comes to live as long as the is such an object and there is a
-*Component* instance capable of servicing the *Content* object.
-
-By default Sling uses the _URL Mapper_ to resolve the request URL into a
-*Content* object. When a *Component* is tasked with servicing a
-*Content* object it usually uses the *ComponentRequestDispatcher* to
-ask Sling to service another content object generally identified by a
-(relative or absolute) path to a JCR Repository Node from which the
-*Content* object is loaded.
-
-But instead of having Sling resolve a path into a *Content* object the
-component may just as well create a *Content* object and hand it over to
-the *ComponentRequestDispatcher* for service. Consider a request which is
-handled by a *PageComponent*. This component has to draw a navigation
-tree somewhere in the response. So the component could of course insist on
-having a *navigation* child node to dispatch rendering to as follows:
+It is crucial to understand that `Content` is an interface and the request processor of Sling does not actually care, how the `Content` instance comes to live as long as the is such an object and there is a `Component` instance capable of servicing the `Content` object.
+
+By default Sling uses the *URL Mapper* to resolve the request URL into a `Content` object. When a `Component` is tasked with servicing a `Content` object it usually uses the `ComponentRequestDispatcher` to ask Sling to service another content object generally identified by a (relative or absolute) path to a JCR Repository Node from which the `Content` object is loaded.
+
+But instead of having Sling resolve a path into a `Content` object the component may just as well create a `Content` object and hand it over to the `ComponentRequestDispatcher` for service. Consider a request which is handled by a `PageComponent`. This component has to draw a navigation tree somewhere in the response. So the component could of course insist on having a `navigation` child node to dispatch rendering to as follows:
@@ -272,9 +114,7 @@ having a *navigation* child node to disp
-What happens, though, if there is no *navigation* child node ? Probably,
-the request will fail with some error status. Of course the component could
-be more clever and do:
+What happens, though, if there is no `navigation` child node ? Probably, the request will fail with some error status. Of course the component could be more clever and do:
@@ -286,19 +126,16 @@ be more clever and do:
-Still, if the *navigation* child node does not exist, there is no
-navigation drawn; at least there will be now error. Since Sling does not
-actually care, how a *Content* object comes to live, the component could
-do the following:
+Still, if the `navigation` child node does not exist, there is no navigation drawn; at least there will be now error. Since Sling does not actually care, how a `Content` object comes to live, the component could do the following:
Content navigation = new Content() {
public String getPath() {
- return request.getContent().getPath() + "/navigation";
+ return request.getContent().getPath() + "/navigation";
}
public String getComponentId() {
- return NavigationComponent.getClass().getName();
+ return NavigationComponent.getClass().getName();
}
}
@@ -307,25 +144,22 @@ do the following:
-Of course, the page component now has to have knowledge about the actual
-*Component* to use.
+Of course, the page component now has to have knowledge about the actual `Component` to use.
-Finally, as a further enhancement, the Component might even decide to first
-check for a *navigation* child node. If such a node does not exist the
-navigation *Content* object is just created:
+Finally, as a further enhancement, the Component might even decide to first check for a `navigation` child node. If such a node does not exist the navigation `Content` object is just created:
Content navigation = request.getContent("navigation");
if (navigation == null) {
navigation = new Content() {
- public String getPath() {
- return request.getContent().getPath() + "/navigation";
- }
- public String getComponentId() {
- return NavigationComponent.getClass().getName();
- }
+ public String getPath() {
+ return request.getContent().getPath() + "/navigation";
+ }
+ public String getComponentId() {
+ return NavigationComponent.getClass().getName();
+ }
}
}
@@ -334,6 +168,4 @@ navigation *Content* object is just crea
-This could for example be used to fall back to a default navigation setup
-while providing for specialized navigation configuration in an optional
-*navigation* child node.
+This could for example be used to fall back to a default navigation setup while providing for specialized navigation configuration in an optional `navigation` child node.
Modified: sling/site/trunk/content/resources.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/resources.mdtext?rev=1341347&r1=1341346&r2=1341347&view=diff
==============================================================================
--- sling/site/trunk/content/resources.mdtext (original)
+++ sling/site/trunk/content/resources.mdtext Tue May 22 08:25:18 2012
@@ -1,214 +1,91 @@
Title: Resources
-<a name="Resources-Resources"></a>
+
# Resources
-{toc:minLevel=2}
+[TOC]
-<a name="Resources-WhatisaResource"></a>
## What is a Resource
-The Resource is one of the central parts of Sling. Extending from JCR's
-_Everything is Content_, Sling assumes _Everthing is a Resource_. Thus
-Sling is maintaining a virtual tree of resources, which is a merger of the
-actual contents in the JCR Repository and resources provided by so called
-resource providers. By doing this Sling fits very well in the paradigma of
-the REST architecture.
+The Resource is one of the central parts of Sling. Extending from JCR's *Everything is Content*, Sling assumes *Everthing is a Resource*. Thus Sling is maintaining a virtual tree of resources, which is a merger of the actual contents in the JCR Repository and resources provided by so called resource providers. By doing this Sling fits very well in the paradigma of the REST architecture.
-<a name="Resources-HowtogetaResource"></a>
## How to get a Resource
-To get at Resources, you need a *ResourceResolver*. This interface
-defines four kinds of methods to access resources:
-* Absolute Path Mapping Resource Resolution: The
-*resolve(HttpServletRequest, String)* and *resolve(String)* methods are
-called to apply some implementation specific path matching algorithm to
-find a Resource. These methods are mainly used to map external paths - such
-as path components of request URLs - to Resources. To support creating
-external paths usable in an URL a third method *map(String)* is defined,
-which allows for round-tripping.
-* Absolute or Relative Path Resolution (including search path): The
-*getResource(String path)* and {{getResource(Resource base, String
-path)}} methods may be used to access a resource with an absolute path
-directly. If it can't be found the path is assumed to be relative and the
-search path retrieved from *getSearchPath()* is used to retrieve the
-resource. This mechanism is similar to resolving a programm with the
-*PATH* environment variable in your favourite operating system.
-* Resource Enumeration: To enumerate resources and thus iterate the
-resource tree, the *listChildren(Resource)* method may be used. This
-method returns an *Iterator<Resource>* listing all resources whose path
-prefix is the path of the given Resource. This method will of course also
-cross boundaries of registered *ResourceProvider* instances to enable
-iterating the complete resource tree.
-* Resource Querying: Querying resources is currently only supported for JCR
-Resources through the *findResources(String query, String language)* and
-*queryResources(String query, String language)* methods. For more
-information see the section on [Querying_Resources](#querying_resources.html)
- below.
+To get at Resources, you need a `ResourceResolver`. This interface defines four kinds of methods to access resources:
+* Absolute Path Mapping Resource Resolution: The `resolve(HttpServletRequest, String)` and `resolve(String)` methods are called to apply some implementation specific path matching algorithm to find a Resource. These methods are mainly used to map external paths - such as path components of request URLs - to Resources. To support creating external paths usable in an URL a third method `map(String)` is defined, which allows for round-tripping.
+* Absolute or Relative Path Resolution (including search path): The `getResource(String path)` and `getResource(Resource base, String path)` methods may be used to access a resource with an absolute path directly. If it can't be found the path is assumed to be relative and the search path retrieved from `getSearchPath()` is used to retrieve the resource. This mechanism is similar to resolving a programm with the `PATH` environment variable in your favourite operating system.
+* Resource Enumeration: To enumerate resources and thus iterate the resource tree, the `listChildren(Resource)` method may be used. This method returns an `Iterator<Resource>` listing all resources whose path prefix is the path of the given Resource. This method will of course also cross boundaries of registered `ResourceProvider` instances to enable iterating the complete resource tree.
+* Resource Querying: Querying resources is currently only supported for JCR Resources through the `findResources(String query, String language)` and `queryResources(String query, String language)` methods. For more information see the section on [Querying*Resources]({{ refs.-querying-resources.path }}) below.
-<a name="Resources-AbsolutePathMapping"></a>
### Absolute Path Mapping
-As has been said, the absolute path mapping methods
-*resolve(HttpServletRequest, String)* and *resolve(String)* apply some
-implementation specific path matching algorithm to find a Resource. The
-difference between the two methods is that the former may take more
-properties of the *HttpServletRequest* into account when resolving the
-Resoure, while the latter just has an absolute path to work on.
+As has been said, the absolute path mapping methods `resolve(HttpServletRequest, String)` and `resolve(String)` apply some implementation specific path matching algorithm to find a Resource. The difference between the two methods is that the former may take more properties of the `HttpServletRequest` into account when resolving the Resoure, while the latter just has an absolute path to work on.
The general algorithm of the two methods is as follows:
-1. Call *HttpServletRequest.getScheme(), .getServerName(), getServerPort* to get an absolute path out of the request URL: \[scheme\](scheme\.html)
-/\[host\].\[port\]\[path\] (*resolve(HttpServletRequest, String)* method
-only, which)
-1. Check whether any virtual path matches the absolute path. If such a match
-exists, the next step is entered with the match.
-1. Apply a list of mappings in order to create a mapped path. The first
-mapped path resolving to a Resource is assumed success and the Resource
-found is returned.
-1. If no mapping created a mapped path addressing an existing Resource, the
-method fails and returns:
-
-* The *resolve(String)* and *resolve(HttpServletRequest,String)*
-methods return a *NonExistingResource*
-* The *getResource(String path)* and {{getResource(Resource base, String
-path)}} methods return null
-
-The virtual path mapping may be used to create shortcut URLs for otherwise
-long and complicated URLs. An example of such an URL might be the main
-administrative page of a CMS system. So, administrators may access the root
-of the web application and directed to the main administrative page.
-
-The path mapping functionality may be used to hide internal resource
-organization from the request URL space. For example to better control the
-structure of your repository, you might decide to store all accessible data
-inside a */content* subtree. To hide this fact from the users, a mapping
-may be defined to prefix all incoming paths with */content* to get at the
-actual Resource.
-
-The *map(String)* applies the path mapping algorithm in the reverse
-order. That is, first the path mappings are reversed and then any virtual
-mappings are checked. So, a path */content/sample* might be mapped
-*/sample* to revers the */content* prefixing. Or the main
-administrative page - say */system/admin/main.html* \- may be mapped to
-the virtual URL */*.
+1. Call `HttpServletRequest.getScheme(), .getServerName(), getServerPort` to get an absolute path out of the request URL: \[scheme\]({{ refs.scheme.path }})/\[host\].\[port\]\[path\] (`resolve(HttpServletRequest, String)` method only, which)
+1. Check whether any virtual path matches the absolute path. If such a match exists, the next step is entered with the match.
+1. Apply a list of mappings in order to create a mapped path. The first mapped path resolving to a Resource is assumed success and the Resource found is returned.
+1. If no mapping created a mapped path addressing an existing Resource, the method fails and returns:
+
+* The `resolve(String)` and `resolve(HttpServletRequest,String)` methods return a `NonExistingResource`
+* The `getResource(String path)` and `getResource(Resource base, String path)` methods return null
+
+The virtual path mapping may be used to create shortcut URLs for otherwise long and complicated URLs. An example of such an URL might be the main administrative page of a CMS system. So, administrators may access the root of the web application and directed to the main administrative page.
+
+The path mapping functionality may be used to hide internal resource organization from the request URL space. For example to better control the structure of your repository, you might decide to store all accessible data inside a `/content` subtree. To hide this fact from the users, a mapping may be defined to prefix all incoming paths with `/content` to get at the actual Resource.
+
+The `map(String)` applies the path mapping algorithm in the reverse order. That is, first the path mappings are reversed and then any virtual mappings are checked. So, a path `/content/sample` might be mapped `/sample` to revers the `/content` prefixing. Or the main administrative page - say `/system/admin/main.html` \- may be mapped to the virtual URL `/`.
-<a name="Resources-RelativePathResolution"></a>
### Relative Path Resolution
-Sometimes it is required to resolve relative paths to Resources. An example
-of such a use case is Script and Servlet resolution which starts with a
-relative path consisting of the Resource type, optional selectors and the
-request extension or method name. By scanning a search path for these
-relative paths a system provided Resource may be overwritten with some user
-defined implementation.
-
-Consider for example, the system would provide a Servlet to render Resources of type *nt:file*. This Servlet would be registered under the path */libs/nt/file/html*. For a certain web application, this default HTML rendering might not be appropriate, so a Script is created as */apps/nt/file/html.jsp* with a customized HTML rendering. By defining the search path to be _\[_ *_/apps{_}{*}_,_ *_/libs{_*} _\](_-*_/apps{_}{*}_,_-*_/libs{_*}-_\.html)
-_ the Servlet resolver would call the
-*ResourceResolver.getResource(String)* method with the relative path
-*nt/file/html* and be provided with the first matching resource -
-*/apps/nt/file/html.jsp* in this example.
+Sometimes it is required to resolve relative paths to Resources. An example of such a use case is Script and Servlet resolution which starts with a relative path consisting of the Resource type, optional selectors and the request extension or method name. By scanning a search path for these relative paths a system provided Resource may be overwritten with some user defined implementation.
+
+Consider for example, the system would provide a Servlet to render Resources of type `nt:file`. This Servlet would be registered under the path `/libs/nt/file/html`. For a certain web application, this default HTML rendering might not be appropriate, so a Script is created as `/apps/nt/file/html.jsp` with a customized HTML rendering. By defining the search path to be *\[* `*/apps{*}{`}*,* `*/libs{*`} *\]({{ refs.--apps----libs-.path }})* the Servlet resolver would call the `ResourceResolver.getResource(String)` method with the relative path `nt/file/html` and be provided with the first matching resource - `/apps/nt/file/html.jsp` in this example.
Of course the search path is not used for absolute path arguments.
-<a name="Resources-QueryingResources"></a>
### Querying Resources
-For convenience the *ResourceResolver* provides two Resource querying
-methods *findResources* and *queryResources* both methods take as
-arguments a JCR query string and a query language name. These parameters
-match the parameter definition of the {{QueryManager.createQuery(String
-statement, String language)}} method of the JCR API.
+For convenience the `ResourceResolver` provides two Resource querying methods `findResources` and `queryResources` both methods take as arguments a JCR query string and a query language name. These parameters match the parameter definition of the `QueryManager.createQuery(String statement, String language)` method of the JCR API.
The return value of these two methods differ in the use case:
-* *findResources* returns an *Iteratory<Resource>* of all Resources
-matching the query. This method is comparable to calling *getNodes()* on
-the *QueryResult* returned from executing the JCR query.
-* *queryResources* returns an *Iterator<Map<String, Object>>*. Each
-entry in the iterator is a *Map<String, Object* representing a JCR result
-*Row* in the *RowIterator* returned from executing the JCR query. The
-map is indexed by the column name and the value of each entry is the value
-of the named column as a Java Object.
-
-These methods are convenience methods to more easily post queries to the
-repository and to handle results in very straight forward way using only
-standard Java functionality.
-
-Please note, that Resource querying is currently only supported for
-repository based Resources. These query methods are not reflected in the
-*ResourceProvider* interface used to inject non-repository Resources into
-the Resource tree.
+* `findResources` returns an `Iteratory<Resource>` of all Resources matching the query. This method is comparable to calling `getNodes()` on the `QueryResult` returned from executing the JCR query.
+* `queryResources` returns an `Iterator<Map<String, Object>>`. Each entry in the iterator is a `Map<String, Object` representing a JCR result `Row` in the `RowIterator` returned from executing the JCR query. The map is indexed by the column name and the value of each entry is the value of the named column as a Java Object.
+
+These methods are convenience methods to more easily post queries to the repository and to handle results in very straight forward way using only standard Java functionality.
+
+Please note, that Resource querying is currently only supported for repository based Resources. These query methods are not reflected in the `ResourceProvider` interface used to inject non-repository Resources into the Resource tree.
-<a name="Resources-ProvidingResources"></a>
## Providing Resources
-The virtual Resource tree to which the the Resource accessor methods
-*resolve* and *getResource* provide access is implemented by a
-collection of registered *ResourceProvider* instances. The main Resource
-provider is of course the repository based *JcrResourceProvider* which
-supports Node and Property based resources. This Resource provider is
-always available in Sling. Further Resource providers may or may not exist.
-
-Each Resource provider is registered as an OSGi service with a required
-service registration property *provider.roots*. This is a multi-value
-String property listing the absolute paths Resource tree entries serving as
-roots to provided subtrees. For example, if a Resource provider is
-registered with the service registration property *provider.roots* set to
-_/some/root_, all paths starting with */some/root* are first looked up in
-the given Resource Provider.
-
-When looking up a Resource in the registered Resource providers, the
-*ResourceResolver* applies a longest prefix matching algorithm to find
-the best match. For example consider three Resource provider registered as
-follows:
-* JCR Resource provider as */*
-* Resource provider R1 as */some*
-* Resource provider R2 as */some/path*
-
-When accessing a Resource with path */some/path/resource* the Resource
-provider _R2_ is first asked. If that cannot provide the resource, Resource
-provider _R1_ is asked and finally the JCR Resource provider is asked. The
-first Resource provider having a Resource with the requested path will be
-used.
+The virtual Resource tree to which the the Resource accessor methods `resolve` and `getResource` provide access is implemented by a collection of registered `ResourceProvider` instances. The main Resource provider is of course the repository based `JcrResourceProvider` which supports Node and Property based resources. This Resource provider is always available in Sling. Further Resource providers may or may not exist.
+
+Each Resource provider is registered as an OSGi service with a required service registration property `provider.roots`. This is a multi-value String property listing the absolute paths Resource tree entries serving as roots to provided subtrees. For example, if a Resource provider is registered with the service registration property `provider.roots` set to */some/root*, all paths starting with `/some/root` are first looked up in the given Resource Provider.
+
+When looking up a Resource in the registered Resource providers, the `ResourceResolver` applies a longest prefix matching algorithm to find the best match. For example consider three Resource provider registered as follows:
+* JCR Resource provider as `/`
+* Resource provider R1 as `/some`
+* Resource provider R2 as `/some/path`
+
+When accessing a Resource with path `/some/path/resource` the Resource provider *R2* is first asked. If that cannot provide the resource, Resource provider *R1* is asked and finally the JCR Resource provider is asked. The first Resource provider having a Resource with the requested path will be used.
-<a name="Resources-JCR-basedResources"></a>
### JCR-based Resources
-JCR-based Resources are provided with the default *JcrResourceProvider*.
-This Resource provider is always available and is always asked last. That
-is Resources provided by other Resource providers may never be overruled by
-repository based Resources.
+JCR-based Resources are provided with the default `JcrResourceProvider`. This Resource provider is always available and is always asked last. That is Resources provided by other Resource providers may never be overruled by repository based Resources.
-<a name="Resources-Bundle-basedResources"></a>
### Bundle-based Resources
-Resources may by provided by OSGi bundles. Providing bundles have a Bundle
-manifest header *Sling-Bundle-Resources* containing a list of absolute
-paths provided by the bundle. The path are separated by comma or whitespace
-(SP, TAB, VTAB, CR, LF).
-
-The *BundleResourceProvider* supporting bundle-based Resources provides
-directories as Resources of type *nt:folder* and files as Resources of
-type *nt:file*. This matches the default primary node types intended to
-be used for directories and files in JCR repositories. For details see [Bundle Resource.](slingxsite:bundle-resources-(extensions.bundleresource).html)
+Resources may by provided by OSGi bundles. Providing bundles have a Bundle manifest header `Sling-Bundle-Resources` containing a list of absolute paths provided by the bundle. The path are separated by comma or whitespace (SP, TAB, VTAB, CR, LF).
+
+The `BundleResourceProvider` supporting bundle-based Resources provides directories as Resources of type `nt:folder` and files as Resources of type `nt:file`. This matches the default primary node types intended to be used for directories and files in JCR repositories. For details see [Bundle Resource.]({{ refs.slingxsite-bundle-resources-extensions-bundleresource.path }})
-<a name="Resources-ServletResources"></a>
### Servlet Resources
-Servlet Resources are registered by the Servlet Resolver bundle for
-Servlets registered as OSGi services. See [Servlet Resolution](slingxsite:servlets.html)
- for information on how Servlet Resources are provided.
+Servlet Resources are registered by the Servlet Resolver bundle for Servlets registered as OSGi services. See [Servlet Resolution]({{ refs.slingxsite-servlets.path }}) for information on how Servlet Resources are provided.
-<a name="Resources-FileSystemResources"></a>
### File System Resources
-The Filesystem Resource Provider provides access to the operating system's
-filesystem through the Sling ResourceResolver. Multiple locations may be
-mapped into the resource tree by configuring the filesystem location and
-the resource tree root path for each location to be mapped. For details see [File System Resources](slingxsite:accessing-filesystem-resources-(extensions.fsresource).html)
-.
+The Filesystem Resource Provider provides access to the operating system's filesystem through the Sling ResourceResolver. Multiple locations may be mapped into the resource tree by configuring the filesystem location and the resource tree root path for each location to be mapped. For details see [File System Resources]({{ refs.slingxsite-accessing-filesystem-resources-extensions-fsresource.path }}).
-<a name="Resources-Wrap/DecorateResources"></a>
## Wrap/Decorate Resources
-The Sling API provides an easy way to wrap or decorate a resource before
-returning. Details see [Wrap or Decorate Resources](wrap-or-decorate-resources.html)
-.
+The Sling API provides an easy way to wrap or decorate a resource before returning. Details see [Wrap or Decorate Resources]({{ refs.wrap-or-decorate-resources.path }}).
\ No newline at end of file
Added: sling/site/trunk/content/run-modes-org-apache-sling-runmode.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/run-modes-org-apache-sling-runmode.mdtext?rev=1341347&view=auto
==============================================================================
--- sling/site/trunk/content/run-modes-org-apache-sling-runmode.mdtext (added)
+++ sling/site/trunk/content/run-modes-org-apache-sling-runmode.mdtext Tue May 22 08:25:18 2012
@@ -0,0 +1,48 @@
+Title: Run Modes (org.apache.sling.runmode)
+
+{note}
+As of Sling 6 the `org.apache.sling.runmode` bundle is replaced by the new [Sling Settings (org.apache.sling.settings)]({{ refs.sling-settings-org-apache-sling-settings.path }}) Bundle. For backwards compatibility this bundle may still exist in your environment. New code should use the API of the new [Sling Settings (org.apache.sling.settings)] Bundle, though.
+{note}
+
+# Overview
+
+Run modes are meant to define different sets of configuration parameters for various Sling instances.
+
+In a web publishing environment, for example, one could use run modes like *staging, production, dev, dmz* or combinations of such values.
+
+The *[org.apache.sling.runmode]({{ refs.http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/runmode.path }})* bundle provides a simple way of defining and querying a list of run modes.
+
+# Installation
+
+The run mode service is not present in the default Sling launchpad builds, to activate it install and start the *org.apache.sling.runmode* bundle.
+
+# Configuration
+
+Run modes can only be configured using a system property, or via the *sling.properties* file.
+
+Using *-Dsling.run.modes=foo,bar* on the JVM command-line, for example, activates the *foo* and *bar* run modes.
+
+This command-line parameter takes precedence over a similar definition (*sling.run.modes=dev,staging*) that might be present in the *sling.properties* file found in the Sling home directory.
+
+# Getting the current list of run modes
+
+The [RunMode service]({{ refs.http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/runmode/src/main/java/org/apache/sling/runmode/RunMode.java.path }}) provides the current list of run modes, examples:
+
+<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>RunMode examples</B></DIV><DIV class="codeContent panelContent">
+ RunMode r = ...get from BundleContext...
+ String [] currentRunModes = r.getCurrentRunModes();
+
+ String [] expectedRunModes = { "foo", "wii" };
+ if(r.isActive(expectedRunModes)) {
+ // at least one of (foo,wii) run modes
+ // is active
+ }
+
+
+# See also
+
+The RunMode service is used by the [jcrinstall]({{ refs.jcr-installer-provider.path }}) services.
+
+# Automated tests
+
+The [RunModeImplTest class]({{ refs.http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/runmode/src/test/java/org/apache/sling/runmode/impl/RunModeImplTest.java.path }}) provides more info about run modes parsing and usage.
\ No newline at end of file
Added: sling/site/trunk/content/scheduler-service-commons-scheduler.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/scheduler-service-commons-scheduler.mdtext?rev=1341347&view=auto
==============================================================================
--- sling/site/trunk/content/scheduler-service-commons-scheduler.mdtext (added)
+++ sling/site/trunk/content/scheduler-service-commons-scheduler.mdtext Tue May 22 08:25:18 2012
@@ -0,0 +1,214 @@
+Title: Scheduler Service (commons scheduler)
+
+# The Commons Scheduler
+
+The scheduler is a service for scheduling other services/jobs (it uses the open source Quartz library). The scheduler can be used in two ways, by registering the job through the scheduler API and by leveraging the whiteboard pattern that is supported by the scheduler.
+
+## The Scheduler API
+
+The scheduler has methods to execute jobs periodically, based on a cron expression or at a given time. For more details please refer to the [javadocs]({{ refs.http://sling.apache.org/apidocs/sling5/index.html?org/apache/sling/commons/scheduler/Scheduler.html.path }}).
+
+## Examples of scheduled jobs registered through the scheduler API
+
+The following examples show you how to define and schedule a job that is registered through the scheduler api.
+
+### Defining the job
+
+The following code sample defines a *job* object that writes a message in the logs:
+
+
+ final Runnable job = new Runnable() {
+ public void run() {
+ log.info("Executing the job");
+ }
+ };
+
+
+### Scheduling with a cron expression
+
+To execute the job as defined above at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday, you can use the *addJob()* method with the following parameters:
+
+
+ String schedulingExpression = "0 15 10 ? * MON-FRI";
+ this.scheduler.addJob("myJob", job, null, schedulingExpression, true);
+
+
+Refer to http://www.docjar.com/docs/api/org/quartz/CronTrigger.html
+ to define more scheduling expressions.
+
+### Scheduling at periodic times
+
+To execute the job as defined above every 3 minutes (180 seconds), you can use the *addPeriodicJob()* method with the following parameters:
+
+
+ long period = 3*60; //the period is expressed in seconds
+ this.scheduler.addPeriodicJob("myJob", job, null, period, true);
+
+
+### Scheduling at a given time
+
+To execute the job as defined above at a specific date (on January 10th 2020), you can use the *fireJobAt()* method with the following parameters:
+
+
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
+ String date = "2020/01/10";
+ java.util.Date fireDate = formatter.parse(date);
+ this.scheduler.fireJobAt("myJob", job, null, fireDate);
+
+
+
+### A service scheduling the job based on 3 different kinds of scheduling
+
+The code implementing a service that simultaneously executes the job based on 3 different kinds of scheduling can look as follows:
+
+
+ package sling.docu.examples;
+
+ import java.io.Serializable;
+ import java.util.Date;
+ import java.util.HashMap;
+ import java.util.Map;
+
+ import org.apache.sling.commons.scheduler.Scheduler;
+ import org.osgi.service.component.ComponentContext;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+
+ /**
+ * This service executes scheduled jobs
+ *
+ * @scr.component immediate="true" metatype="false"
+ *
+ */
+ public class HelloWorldScheduledService {
+
+ /** Default log. */
+ protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ /** The scheduler for rescheduling jobs.
+ * @scr.reference */
+ private Scheduler scheduler;
+
+
+ protected void activate(ComponentContext componentContext) throws Exception {
+ //case 1: with addJob() method: executes the job every minute
+ String schedulingExpression = "0 * * * * ?";
+ String jobName1 = "case1";
+ Map<String, Serializable> config1 = new HashMap<String, Serializable>();
+ boolean canRunConcurrently = true;
+ final Runnable job1 = new Runnable() {
+ public void run() {
+ log.info("Executing job1");
+ }
+ };
+ try {
+ this.scheduler.addJob(jobName1, job1, config1, schedulingExpression, canRunConcurrently);
+ } catch (Exception e) {
+ job1.run();
+ }
+
+ //case 2: with addPeriodicJob(): executes the job every 3 minutes
+ String jobName2 = "case2";
+ long period = 180;
+ Map<String, Serializable> config2 = new HashMap<String, Serializable>();
+ final Runnable job2 = new Runnable() {
+ public void run() {
+ log.info("Executing job2");
+ }
+ };
+ try {
+ this.scheduler.addPeriodicJob(jobName2, job2, config2, period, canRunConcurrently);
+ } catch (Exception e) {
+ job2.run();
+ }
+
+ //case 3: with fireJobAt(): executes the job at a specific date (date of deployment + delay of 30 seconds)
+ String jobName3 = "case3";
+ final long delay = 30*1000;
+ final Date fireDate = new Date();
+ fireDate.setTime(System.currentTimeMillis() + delay);
+ Map<String, Serializable> config3 = new HashMap<String, Serializable>();
+ final Runnable job3 = new Runnable() {
+ public void run() {
+ log.info("Executing job3 at date: {} with a delay of: {} seconds", fireDate, delay/1000);
+ }
+ };
+ try {
+ this.scheduler.fireJobAt(jobName3, job3, config3, fireDate);
+ } catch (Exception e) {
+ job3.run();
+ }
+ }
+
+ protected void deactivate(ComponentContext componentContext) {
+ log.info("Deactivated, goodbye!");
+ }
+
+ }
+
+
+## Examples of jobs that are scheduled by leveraging the whiteboard pattern
+
+The following examples show you how to define and schedule a job by leveraging the whiteboard pattern.
+
+### Scheduling with a cron expression
+
+The following job is executed every minute by setting *scheduler.expression* to the cron expression *"0 * * * * ?"*:
+
+
+ package sling.docu.examples;
+
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+
+ /**
+ * @scr.component
+ * @scr.service interface="java.lang.Runnable"
+ * @scr.property name="scheduler.expression" value="0 * * * * ?"
+ */
+ public class ScheduledCronJob implements Runnable {
+
+ /** Default log. */
+ protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ public void run() {
+ log.info("Executing a cron job (job#1) through the whiteboard pattern");
+ }
+ //
+ }
+
+
+### Scheduling at periodic times
+
+The following job is executed every ten seconds by setting *scheduler.period* to *10*:
+
+
+ package sling.docu.examples;
+
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+
+ /**
+ * @scr.component
+ * @scr.service interface="java.lang.Runnable"
+ * @scr.property name="scheduler.period" value="10" type="Long"
+ */
+ public class ScheduledPeriodicJob implements Runnable {
+
+ /** Default log. */
+ protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ public void run() {
+ log.info("Executing a perodic job (job#2) through the whiteboard pattern");
+ }
+ //
+ }
+
+
+### Preventing concurrent execution
+
+By default, jobs can be concurrently executed. To prevent this, set the *scheduler.concurrent* property to *false*:
+
+
+ @scr.property name="scheduler.concurrent" value="false" type="Boolean"
+
Modified: sling/site/trunk/content/scriptengineintegration.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/scriptengineintegration.mdtext?rev=1341347&r1=1341346&r2=1341347&view=diff
==============================================================================
--- sling/site/trunk/content/scriptengineintegration.mdtext (original)
+++ sling/site/trunk/content/scriptengineintegration.mdtext Tue May 22 08:25:18 2012
@@ -1,24 +1,16 @@
Title: ScriptEngineIntegration
-<a name="ScriptEngineIntegration-IntegratingScriptingLanguages"></a>
+
# Integrating Scripting Languages
-This page should be extended with more concrete and detailed information.
-For now, we have the following information:
+This page should be extended with more concrete and detailed information. For now, we have the following information:
- * There will be a talk at ApacheCon US 08 in New Orleans about creating
-JSR-223 ScriptEngineFactory and ScriptEngine implementaitons as well as how
-to integrate such implementations with Sling.
+ * There will be a talk at ApacheCon US 08 in New Orleans about creating JSR-223 ScriptEngineFactory and ScriptEngine implementaitons as well as how to integrate such implementations with Sling.
* From a mail on the mailing list, this is a very condensed how-to:
- ** Create the ScriptEngine\[Factory](factory.html)
- implementations
- ** Create a bundle comprising the above implementations as well as
-the script language implementation.
- ** Create the
-*META-INF/services/javax.script.ScriptEngineFactory* file listing the
-fully qualified name of your ScriptEngineFactory implementaiton
+ ** Create the ScriptEngine\[Factory]({{ refs.factory.path }}) implementations
+ ** Create a bundle comprising the above implementations as well as the script language implementation.
+ ** Create the `META-INF/services/javax.script.ScriptEngineFactory` file listing the fully qualified name of your ScriptEngineFactory implementaiton
-<a name="ScriptEngineIntegration-NotesonScriptEngines"></a>
# Notes on ScriptEngines
-{children:sort=title|excerpt=true}
+{children:sort=title|excerpt=true}
\ No newline at end of file
Modified: sling/site/trunk/content/security.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/security.mdtext?rev=1341347&r1=1341346&r2=1341347&view=diff
==============================================================================
--- sling/site/trunk/content/security.mdtext (original)
+++ sling/site/trunk/content/security.mdtext Tue May 22 08:25:18 2012
@@ -1,48 +1,30 @@
Title: Security
-<a name="Security-ReportingNewSecurityProblemswithApacheSling"></a>
+
# Reporting New Security Problems with Apache Sling
-The Apache Software Foundation takes a very active stance in eliminating
-security problems and denial of service attacks against Apache Sling.
+The Apache Software Foundation takes a very active stance in eliminating security problems and denial of service attacks against Apache Sling.
-We strongly encourage folks to report such problems to our private security
-mailing list first, before disclosing them in a public forum.
+We strongly encourage folks to report such problems to our private security mailing list first, before disclosing them in a public forum.
-*Please note that the security mailing list should only be used for
-reporting undisclosed security vulnerabilities in Apache Sling and managing
-the process of fixing such vulnerabilities. We cannot accept regular bug
-reports or other queries at this address. All mail sent to this address
-that does not relate to an undisclosed security problem in the Apache Sling
-source code will be ignored.*
+*Please note that the security mailing list should only be used for reporting undisclosed security vulnerabilities in Apache Sling and managing the process of fixing such vulnerabilities. We cannot accept regular bug reports or other queries at this address. All mail sent to this address that does not relate to an undisclosed security problem in the Apache Sling source code will be ignored.*
-If you need to report a bug that isn't an undisclosed security
-vulnerability, please use the bug reporting page.
+If you need to report a bug that isn't an undisclosed security vulnerability, please use our [public issue tracker]({{ refs.https://issues.apache.org/jira/browse/SLING.path }}).
Questions about:
* how to configure Sling securely
-* if a vulnerability applies to your particular application
+* whether a published vulnerability applies to your particular application
* obtaining further information on a published vulnerability
* availability of patches and/or new releases
-should be addressed to the users mailing list. Please see the [Project Information](project-information.html)
- page for details of how to subscribe.
+should be addressed to our public users mailing list. Please see the [Project Information]({{ refs.project-information.path }}) page for details of how to subscribe.
+
+The private security mailing address is: [mailto:security@sling.apache.org]({{ refs.mailto-security-sling-apache-org.path }}).
-The private security mailing address is: [mailto:security@sling.apache.org](mailto:security@sling.apache.org.html)
+Note that all networked servers are subject to denial of service attacks, and we cannot promise magic workarounds to generic problems (such as a client streaming lots of data to your server, or re-requesting the same URL repeatedly). In general our philosophy is to avoid any attacks which can cause the server to consume resources in a non-linear relationship to the size of inputs.
-Note that all networked servers are subject to denial of service attacks,
-and we cannot promise magic workarounds to generic problems (such as a
-client streaming lots of data to your server, or re-requesting the same URL
-repeatedly). In general our philosophy is to avoid any attacks which can
-cause the server to consume resources in a non-linear relationship to the
-size of inputs.
-
-For more information on handling security issues at the Apache Software
-Foundation please refer to the [ASF Security Team](http://www.apache.org/security/)
- page.
+For more information on handling security issues at the Apache Software Foundation please refer to the [ASF Security Team]({{ refs.http://www.apache.org/security/.path }}) page.
-<a name="Security-Errorsandomissions"></a>
# Errors and omissions
-Please report any errors or omissions to [mailto:security@sling.apache.org](mailto:security@sling.apache.org.html)
-.
+Please report any errors or omissions to [mailto:security@sling.apache.org]({{ refs.mailto-security-sling-apache-org.path }}).
\ No newline at end of file