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 39E3BDA2B for ; Wed, 12 Dec 2012 09:16:04 +0000 (UTC) Received: (qmail 36417 invoked by uid 500); 12 Dec 2012 09:16:04 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 36341 invoked by uid 500); 12 Dec 2012 09:16:03 -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 36332 invoked by uid 99); 12 Dec 2012 09:16:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2012 09:16:03 +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; Wed, 12 Dec 2012 09:15:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 180962388C7D; Wed, 12 Dec 2012 09:15:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1420577 [12/30] - in /sling/site/trunk/content/site: ./ 46-line-blog.data/ authentication.data/ documentation.data/ first-steps.data/ getting-and-building-sling.data/ how-to-manage-events-in-sling.data/ index.data/ links.data/ manipulating... Date: Wed, 12 Dec 2012 09:14:44 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121212091507.180962388C7D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: sling/site/trunk/content/site/how-to-manage-events-in-sling.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/how-to-manage-events-in-sling.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/how-to-manage-events-in-sling.html (added) +++ sling/site/trunk/content/site/how-to-manage-events-in-sling.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,349 @@ + + + + + Apache Sling - How to Manage Events in Sling + + + + + +
+ +
+ + Apache + +
+
+ +
+ +

How to Manage Events in Sling

+ +

Apache Sling provides some mechanisms and support for managing events.

+ +

The event mechanism is leveraging the OSGi Event Admin Specification (OSGi Compendium 113). The OSGi API is very simple and lightweight. Sending an event is just generating the event object and calling the event admin. Receiving the event is implementing a single interface and declaring through properties which topics one is interested in.
+Sling makes a distinction between events and job events. Unlike events, job events are garanteed to be processed. In other words: someone has to do something with the job event (do the job).

+ +

For more details please refer to the following resources:

+ + + +

This page drives you through the implementation of two services that rely on the Sling eventing mechanisms. The services implement the following use case: whenever a file is uploaded to a temporary location in your web application, the file is moved to a specific location according to its MIME type.

+ +

Introduction

+ +

You will now implement the logic to listen to files posted to /tmp/dropbox and to move them to the appropriate locations depending on the MIME type:

+
    +
  • images (.png) are moved to /dropbox/images/
  • +
  • music (.mp3) are moved to /dropbox/music/
  • +
  • movies (.avi) are moved to /dropbox/movies/
  • +
  • otherwise the files are moved to /dropbox/other/
  • +
+ + +

To do that, you will implement two services. The first one, called DropBoxService:

+
    +
  • Listens to OSGI events.
  • +
  • Sends a job event if a resource has been added to /tmp/dropbox.
  • +
+ + +

The second one, called DropBoxEventHandler:

+
    +
  • Listens to the former job event.
  • +
  • Moves the file according to its extension.
  • +
+ + +

Listening to OSGI Events

+ +

To listen to the specific OSGI event "resource added":

+
    +
  • The property event.topics needs to be set to org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED in the class annotations.
  • +
+ + +
+
+ * @scr.property name="event.topics" valueRef="org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED"
+
+
+ +

You can refer to the org.apache.sling.api.SlingConstants class in the Javadocs to know about other events available in Sling.

+ +

Sending Job Events

+ +

To send an event the following code can be used:

+
+
+public void sendEvent() {
+    final Dictionary<String, Object> props = new Hashtable<String, Object>();
+    props.put(JobUtil.PROPERTY_JOB_TOPIC, JOB_TOPIC);
+    props.put("resourcePath", RESOURCE_PATH);
+    final Event myEvent = new Event(JOB_TOPIC, props);
+    eventAdmin.sendEvent(myEvent);
+} 
+
+
+ +

However, for our example, to send a job event the service needs to implement:

+
    +
  • the org.osgi.service.event.EventHandler interface.
  • +
  • the org.apache.sling.event.JobProcessor interface.
  • +
+ + +
+
+public class DropBoxService implements JobProcessor, EventHandler {
+
+
+ +

To send the job event the Event Admin service needs to be referenced:

+
+
+	/** 
+	 * The OSGI event admin used for sending events 
+	 * @scr.reference
+	 */
+	private EventAdmin eventAdmin;
+
+
+ +

The job topic for dropbox job events needs to be defined:

+
+
+    /** The job topic for dropbox job events. */
+    public static final String JOB_TOPIC = "com/sling/eventing/dropbox/job";
+
+
+ +

The org.osgi.service.event.EventHandler#handleEvent(Event event) method needs to be implemented:

+
+
+	public void handleEvent(Event event) {
+	    if (EventUtil.isLocal(event)) {
+	        EventUtil.processJob(event, this);
+	    }
+	}
+
+
+ +

The org.apache.sling.event.JobProcessor#process(Event event) method needs to be implemented.

+ +

Its logic is as follows:

+
    +
  • The OSGI event is analyzed.
  • +
  • If the event is a file that has been added to /tmp/dropbox: +
      +
    • An event is created with 2 properties: +
        +
      • A property to set the event as a job event.
      • +
      • A property for the file path.
      • +
      +
    • +
    • The job event is sent to all the listeners that subscribe to the topic of the event.
    • +
    +
  • +
+ + +
+
+	public boolean process(Event event) {
+		String propPath = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
+		String propResType = (String) event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE);
+		// an event is sent if a file is added to /tmp/dropbox
+		if (propPath.startsWith("/tmp/dropbox") && propResType.equals("nt:file")) {
+			final Dictionary<String, Object> props = new Hashtable<String, Object>();
+			props.put(EventUtil.PROPERTY_JOB_TOPIC, JOB_TOPIC);
+			props.put("resourcePath", propPath);
+			Event dropboxJobEvent = new Event(EventUtil.TOPIC_JOB, props);
+			eventAdmin.sendEvent(dropboxJobEvent);
+			log.info("the dropbox job has been sent: {}", propPath);
+		}
+		return true;
+	}
+
+
+ +

The complete code for the DropBoxService service is available here.

+ +

Listening to Job Events

+ +

Now that you have implemented a service that sends a job event when a file is uploaded to /tmp/dropbox, you will implement the service DropBoxEventHandler that listens to those job events and moves the files to a location according to their MIME types.

+ +

To listen to the job events that have been defined before:

+
    +
  • The property event.topics needs to be set to mypackage.DropBoxService.JOB_TOPIC in the class annotations.
  • +
+ + +
+
+ * @scr.property name="event.topics" valueRef="mypackage.DropBoxService.JOB_TOPIC"
+
+
+ +

Handling Job Events

+ +

To move the files the service needs to implement:

+
    +
  • the org.osgi.service.event.EventHandler interface.
  • +
  • the org.apache.sling.event.JobProcessor interface.
  • +
+ + +
+
+public class DropBoxEventHandler implements JobProcessor, EventHandler {
+
+
+ +

Some class fields need to be defined for:

+
    +
  • The default log.
  • +
  • The references to the SlingRepository and the JcrResourceResolverFactory services, which are used in the implementation.
  • +
  • The destination paths of the files.
  • +
+ + +
+
+   /** Default log. */
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    /** @scr.reference */
+    private SlingRepository repository;
+    
+    /**
+     * @scr.reference
+     */
+    private JcrResourceResolverFactory resolverFactory;
+    
+    private final static String IMAGES_PATH = "/dropbox/images/";
+    private final static String MUSIC_PATH = "/dropbox/music/";
+    private final static String MOVIES_PATH = "/dropbox/movies/";
+    private final static String OTHER_PATH = "/dropbox/other/";
+
+
+ +

The org.osgi.service.event.EventHandler#handleEvent(Event event) method needs to be implemented:

+
+
+	public void handleEvent(Event event) {
+	    if (EventUtil.isLocal(event)) {
+	        EventUtil.processJob(event, this);
+	    }
+	}
+
+
+ +

The org.apache.sling.event.JobProcessor#process(Event event) method needs to be implemented.

+ +

Its logic is as follows:

+
    +
  • The resource path is extracted from the job event property.
  • +
  • The resource is obtained from the resource path.
  • +
  • If the resource is a file, the destination path is defined based on the file MIME type.
  • +
  • The file is moved to the new location.
  • +
+ + +
+
+	public boolean process(Event event) {
+		Session adminSession = null;
+		try {
+			String resourcePath = (String) event.getProperty("resourcePath");
+			String resourceName = resourcePath.substring(resourcePath.lastIndexOf("/") + 1);
+        	adminSession = repository.loginAdministrative(null);
+	        ResourceResolver resourceResolver = resolverFactory.getResourceResolver(adminSession);
+	        Resource res = resourceResolver.getResource(resourcePath);
+	        if (ResourceUtil.isA(res, "nt:file")) {
+	        	String mimeType = res.getResourceMetadata().getContentType();
+	        	String destDir;
+	        	if (mimeType.equals("image/png")) {
+	        		destDir = IMAGES_PATH;
+	        	}
+	        	else if (mimeType.equals("audio/mpeg")) {
+	        		destDir = MUSIC_PATH;
+	        	}
+	        	else if (mimeType.equals("video/x-msvideo")) {
+	        		destDir = MOVIES_PATH;
+	        	}
+	        	else {
+	        		destDir = OTHER_PATH;
+	        	}
+        		adminSession.move(resourcePath, destDir + resourceName);
+	        	adminSession.save();
+	        	log.info("The file {} has been moved to {}", resourceName, destDir);
+	        }
+	        return true;
+		} catch (RepositoryException e) {
+			log.error("RepositoryException: " + e);
+			return false;
+        } finally {
+            if (adminSession != null && adminSession.isLive()) {
+            	adminSession.logout();
+            	adminSession = null;
+            }
+        }
+	}
+
+
+ +

The complete code for the DropBoxEventHandler service is available here.

+
+Last modified by jck on Mon Jun 25 08:26:46 EDT 2012 +
+
+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. +
+
+ + + Propchange: sling/site/trunk/content/site/how-to-manage-events-in-sling.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/how-to-manage-events-in-sling.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/how-to-manage-events-in-sling.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/incubator-status-report-february-2008.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/incubator-status-report-february-2008.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/incubator-status-report-february-2008.html (added) +++ sling/site/trunk/content/site/incubator-status-report-february-2008.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,84 @@ + + + + + Apache Sling - Incubator Status Report (February 2008) + + + + + +
+ +
+ + Apache Incubator + +
+
+ +
+

Sling is a framework to develop content centric web applications based on the idea of modularizing the rendering of HTTP resources.

+ +

Sling entered incubation on September 5th, 2007.

+ +

Community

+ + + + +

Software

+ +
    +
  • The Sling API has been finalized and the project migrated to the new API.
  • +
  • Creation of the Sling Launchpad, based on the former microsling module, provides a ready to run configuration of Sling.
  • +
  • General stabilization of the API and implementation, should lead to a first release soon.
  • +
  • No export control notifications are needed for Apache Sling.
  • +
+ + +

Issues before graduation

+ +
    +
  • Make an incubating Sling release.
  • +
  • Grow a more diverse community (so far commits mostly from Day employees).
  • +
+ + +

Licensing and other issues

+ +
    +
  • none
  • +
+ +
+ + + Propchange: sling/site/trunk/content/site/incubator-status-report-february-2008.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/incubator-status-report-february-2008.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/incubator-status-report-february-2008.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/incubator-status-report-may-2008.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/incubator-status-report-may-2008.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/incubator-status-report-may-2008.html (added) +++ sling/site/trunk/content/site/incubator-status-report-may-2008.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,80 @@ + + + + + Apache Sling - Incubator Status Report (May 2008) + + + + + +
+ +
+ + Apache Incubator + +
+
+ +
+

Sling is a framework to develop content centric web applications based on the idea of modularizing the rendering of HTTP resources.

+ +

Sling entered incubation on September 5th, 2007.

+ +

Community

+ +
    +
  • ...
  • +
+ + +

Software

+ +
    +
  • ...
  • +
+ + +

Issues before graduation

+ +
    +
  • Make an incubating Sling release.
  • +
  • Grow a more diverse community (so far commits mostly from Day employees).
  • +
+ + +

Licensing and other issues

+ +
    +
  • none
  • +
+ +
+ + + Propchange: sling/site/trunk/content/site/incubator-status-report-may-2008.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/incubator-status-report-may-2008.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/incubator-status-report-may-2008.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/incubator-status-report-november-2007.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/incubator-status-report-november-2007.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/incubator-status-report-november-2007.html (added) +++ sling/site/trunk/content/site/incubator-status-report-november-2007.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,82 @@ + + + + + Apache Sling - Incubator Status Report (November 2007) + + + + + +
+ +
+ + Apache Incubator + +
+
+ +
+

Sling is a framework to develop content centric web applications based on the idea of modularizing the rendering of HTTP resources.

+ +

Sling entered incubation on September 5th, 2007.

+ +

Community

+ +
    +
  • We had a very active month with adding microsling and based on this project developping and voting the new Sling API replacing the form Component API. Currently we are migrating the project sources to the new API.
  • +
  • Sling present at ApacheCon US 07 with a FeatherTalk and a BOF
  • +
+ + +

Software

+ +
    +
  • microsling added to Sling as simple entry level framework exhibiting the mechanisms of Sling. microsling was also used as a proof of concept for the new Sling API and greatly influenced its evolution.
  • +
  • Two contributions of the community added to microsling and Sling: Freemarker support by Padraic Hannon and Ruby integration by Shawn Anderson.
  • +
+ + +

Issues before graduation

+ +
    +
  • Make an incubating Sling release
  • +
  • Grow a more diverse community (so far only commits from Day employees)
  • +
+ + +

Licensing and other issues

+ +
    +
  • none
  • +
+ +
+ + + Propchange: sling/site/trunk/content/site/incubator-status-report-november-2007.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/incubator-status-report-november-2007.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/incubator-status-report-november-2007.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/incubator-status-report-october-2007.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/incubator-status-report-october-2007.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/incubator-status-report-october-2007.html (added) +++ sling/site/trunk/content/site/incubator-status-report-october-2007.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,80 @@ + + + + + Apache Sling - Incubator Status Report (October 2007) + + + + + +
+ +
+ + Apache Incubator + +
+
+ +
+

Sling is a framework to develop content centric web applications based on the idea of modularizing the rendering of HTTP resources.

+ +

Sling entered incubation on September 5th, 2007.

+ +

Community

+
    +
  • Proper wiki/web page created by Felix Meschberger based on the Apache Felix setup by Marcel Offermans and Ronald Spierenburg.
  • +
  • Juan's committer account has been setup
  • +
  • Apache Sling will be present at the ApacheCon US 07 with a Feather Talk.
  • +
  • Upcoming will be a discussion on when we should cut a first release.
  • +
+ + +

Software

+
    +
  • Discusssion is taking place to simplify the current "Component API" and to remove interfaces which are more or less duplicate to the Servlet API used and extended by Sling.
  • +
  • A "sample" project has been added to show some features of Sling.
  • +
+ + +

Issues before graduation

+
    +
  • Make an incubating Sling release
  • +
  • Grow a more diverse community (so far only commits from Day employees)
  • +
+ + +

Licensing and other issues

+
    +
  • none
  • +
+ +
+ + + Propchange: sling/site/trunk/content/site/incubator-status-report-october-2007.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/incubator-status-report-october-2007.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/incubator-status-report-october-2007.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/index.data/ApacheConUS07_FFT_Sling.pdf URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/index.data/ApacheConUS07_FFT_Sling.pdf?rev=1420577&view=auto ============================================================================== Binary file - no diff available. Propchange: sling/site/trunk/content/site/index.data/ApacheConUS07_FFT_Sling.pdf ------------------------------------------------------------------------------ svn:mime-type = application/pdf Added: sling/site/trunk/content/site/index.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/index.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/index.html (added) +++ sling/site/trunk/content/site/index.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,185 @@ + + + + + Apache Sling - Apache Sling + + + + + +
+ +
+ + Apache + +
+
+ +
+ +

Apache Sling - Bringing Back the Fun

+ +

Apache SlingTM + is an innovative web framework that is intended to bring back the fun to web development.

+ +

Discussions about Sling happen on our mailing lists, see the Project Information page for more info.

+ +

Apache Sling in five bullets points

+ +
    +
  • REST based web framework
  • +
  • Content-driven, using a JCR content repository
  • +
  • Powered by OSGi
  • +
  • Scripting inside, multiple languages (JSP, server-side javascript, Scala, etc.)
  • +
  • Apache Open Source project
  • +
+ + +

Apache Sling in a hundred words

+ +

Apache Sling is a web framework that uses a Java Content Repository, such as Apache Jackrabbit, to store and manage content.

+ +

Sling applications use either scripts or Java servlets, selected based on simple name conventions, to process HTTP requests in a RESTful way.

+ +

The embedded Apache Felix OSGi framework and console provide a dynamic runtime environment, where code and content bundles can be loaded, unloaded and reconfigured at runtime.

+ +

As the first web framework dedicated to JSR-170 Java Content Repositories, Sling makes it very simple to implement simple applications, while providing an enterprise-level framework for more complex applications.

+ +

News

+ +

    +
  • New Release: Apache Sling Servlet Resolver 2.2.2 (December 10th, 2012)
  • +
  • New Releases: Apache Sling Settings 1.2.2, Apache Sling Auth Core 1.1.0, Apache Sling Commons Logservice 1.0.2, Apache Sling Installer Core 3.4.2, Apache Sling Scripting JSP 2.0.26, Apache Sling Commons Compiler 2.1.0, Apache Sling JCR Compiler 2.1.0, Apache Sling I18n 2.2.4, Apache Sling JCR Classloader 3.1.10, Apache Sling JCR Webdav 2.1.2, Apache Sling JCR Davex 1.1.0 (November 30th, 2012)
  • +
  • New Releases: Apache Sling Maven Launchpad Plugin 2.2.0, Apache Sling Commons OSGi 2.2.0, Apache Sling Launchpad Installer 1.2.0, Apache Sling Rewriter 1.0.4, Apache Sling Settings 1.2.0 (November 19th, 2012)
  • +
  • New Releases: Apache Sling API 2.3.0, Apache Sling Bundle Resource Provider 2.1.0, Apache Sling File System Resource Provider 1.1.0, Apache Sling JCR Resource 2.2.0, Apache Sling Resource Resolver 1.0.0, Apache Sling Servlets Get 2.1.4, Apache Sling Servlets Post 2.2.0, Apache Sling Servlets Resolver 2.2.0, Apache Sling Adapter 2.1.0, Apache Sling Commons Testing 2.0.12 (November 15th, 2012)
  • +
  • New Release: Apache Sling JSP Taglib 2.1.8, Apache Sling Installer Core 3.4.0, Apache Sling Installer API 1.0.0, Apache Sling Installer Console 1.0.0, Apache Sling JCR Wrapper 2.0.0 (October 29th, 2012)
  • +
  • New Releases: Apache Sling Installer Core 3.3.8, Apache Sling Launchpad Installer 1.1.4, and Apache Sling Maven Launchpad Plugin 2.1.2 (August 19th, 2012)
  • +
+

+ + + +

History

+ +

Sling started as an internal project at Day Software, and entered the Apache Incubator in September 2007. As of June, 17th, 2009 Apache Sling is a top level project of the Apache Software Foundation.

+ +

The name "Sling" has been proposed by Roy Fielding who explained it like this:

+ +
+

[The name is] Biblical in nature. The story of David: the weapon he uses to slay the giant Goliath is a sling. Hence, our David's [David Nuescheler, CTO of Day Software] favorite weapon.

+ +

It is also the simplest device for delivering content very fast.

+ + +

Who uses Sling?

+ +

See Who is using Sling on our public wiki.

+ +

Getting started

+ +

If you prefer doing rather than reading, please proceed to Discover Sling in 15 minutes or read through the recommended links in the Getting Started section, where you can quickly get started on your own instance of Sling.

+ +

Contents

+ + + + + +

Use Cases for Sling

+ + +

Wiki

+ +

Day built a Wiki system on Sling. Each Wiki page is a node (with optional child nodes) in the repository. As a page is requested, the respective node is accessed and through the applying Component is rendered.

+ +

Thanks to the JCR Mapping and the resolution of the Component from the mapped Content, the system does not care for what actual node is addressed as long as there is a Content mapping and a Component capable of handling the Content.

+ +

Thus in the tradition of REST, the attachement of a Wiki page, which happens to be in a node nested below the wiki page node is easily accessed using the URL of the wiki page attaching the relative path of the attachement ode. The system resolves the URL to the attachement Content and just calls the attachement's Component to spool the attachement.

+ + + +

Digital Asset Management

+ +

Day has implemented a Digital Asset Management (DAM) Application based on Sling. Thanks to the flexibility of the Content/Component combo as well as the service registration/access functionality offered by OSGi, extending DAM for new content type is merely a matter of implementing one or two interfaces and registering the respective service(s).

+ +

Again, the managed assets may be easily spooled by directly accessing them.

+ + + +

Web Content Management

+ +

Last but not least, Sling offers itself very well to implementing a Web Content Management system. Thanks to the flexibility of rendering the output - remember: the system does not care what to render, as long as the URL resolves to a Content object for which a Component exists, which is called to render the Content - providing support for Web Content authors (not PHP programmers but users out in the field) to build pages to their likings can easily be done.

+ + +

References

+ + +

Apache Jackrabbit

+ +

The main purpose of Sling is to develop a content-centric Web Application framework for Java Content Repository (JCR) based data stores. Sling is implemented - with the notable exception of JCR Node Type management - purely in terms of the JCR API and as such may use any JCR compliant repository. The default implementation for Apache Jackrabbit is provided out of the box.

+ +

OSGi

+ +

Sling is implemented as a series of OSGi Bundles and makes extensive use of the OSGi functionality, such as lifecycle management and the service layer. In addition, Sling requires several OSGi compendium services to be available, such as the Log Service, Http Service, Configuration Admin Service, Metatype Service, and Declarative Services.

+ +

Apache Felix

+ +

While Sling does not require a specific OSGi framework implementation to run in, Sling is being developed using Apache Felix as the OSGi framework implementation. It has not been tested yet, but it is expected that Sling also operates perfectly inside other OSGi frameworks such as Equinox and Knopflerfish.

+
+Last modified by bdelacretaz on 2012-04-03 11:06:05.0 +
+
+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. +
+
+ + + Propchange: sling/site/trunk/content/site/index.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/index.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/index.html ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: sling/site/trunk/content/site/installing-and-upgrading-bundles.html URL: http://svn.apache.org/viewvc/sling/site/trunk/content/site/installing-and-upgrading-bundles.html?rev=1420577&view=auto ============================================================================== --- sling/site/trunk/content/site/installing-and-upgrading-bundles.html (added) +++ sling/site/trunk/content/site/installing-and-upgrading-bundles.html Wed Dec 12 09:13:50 2012 @@ -0,0 +1,145 @@ + + + + + Apache Sling - Installing and Upgrading Bundles + + + + + +
+ +
+ + Apache + +
+
+ +
+ +

Installing and Upgrading Bundles

+ +
We recommend to use the Apache Felix Web Console. The documentation below describes the old Sling Management Console, which isn't in use any more. Please refer to the documentation of the Apache Felix Web Console.
+ + + +

OSGi bundles installed in the OSGi framework, which is provided by Sling, may be upgraded or removed and new bundles may be installed by using the Sling Management Console. This page is about using the Sling Management Console for those tasks.

+ +

Basically, you have two choices to install and upgrade bundles: Upload the bundle files or install them from a Bundle Repository.

+ + + +

Sling Management Console

+ +

The Sling Management Console is installed by default when Sling is running and may be reached at on the page /system/console in the Sling Context by default. For example if you installed the Sling Web Application in the /sample context of the Servlet Container running at http://somehost:4402, you would access the Sling Management Console at http://somehost:4402/sample/system/console.

+ +

You will be prompted for a user name and password to access the Sling Management Console. This password is preset to be admin for the user name and admin for the password.

+ +

NB: Both the username and password and the location of the Sling Management Console inside the Web Application Context is configurable in the Sling Management Console configuration on the Configuration page.

+ + + +

Installing and upgrading bundles by Upload

+ +

To install a new bundle or upgrade an already installed bundle, go to the Bundles page in the Sling Management Console. At the top and the bottom of the page you have a form to specify and upload a bundle as a file :

+ +
    +
  • Select the bundle file to upload
  • +
  • Click the Start checkbox, if you want to start the bundle after installation. If the bundle is upgraded, this checkbox is ignored.
  • +
  • Specify the start level of the bundle in the Start Level field. This must be a number higher than 0 and is ignored for bundles, which are already installed. Most of the time, you will use the default value.
  • +
  • Click the Install or Update button
  • +
+ + +

After clicking the button, the bundle file will be uploaded. If a bundle with the same bundle symbolic name is already installed, the respective bundle will be updated with the new bundle file. Otherwise the bundle file will be installed as a new bundle and its start level is set as defined. Additionally the bundle will optionally be started.

+ +

After having updated a bundle, you should also refresh the packages by clicking on the Refresh Packages button. The reson for this is, that the old version of the bundle is still used by other bundles even after upgrading to a new version. Only when the packages are refreshed any users of the bundle will be relinked to use the new bundle version. As this might be a somewhat lengthy operation, which also stops and restarts using bundles, this operation has to be executed explicitly.

+ +

Also, if you plan to upgrade multiple bundles, you may wish to upgrade all bundles before repackaging the using bundles.

+ + + +

Installing and upgrading bundles from the Bundle Repository

+ +

The OSGi Bundle Repository is a repository of bundles, from which Sling may download and install or upgrade bundles very easily. Unlike the installation of bundles by file upload, the OSGi Bundle Repository has the functionality to resolve and dependencies of bundles to be installed.

+ +

Say you wish to install bundle X which depends on packages provided by bundle Y. When uploading bundle X as a file it will not resolve, that is Sling (the OSGi framework actually) is not able to ensure proper operation of bundle X and thus prevents the bundle from being started and used. You will have to manually upload bundle Y yourself. When using the OSGi Bundle Repository, you just select bundle X for installation and the bundle repository will find out, that bundle Y is also required and will automatically download and install it along with bundle X.

+ + +

The Bundle Repository page

+ +

Installation or update of bundles may be done on the Bundle Repository page of the Sling Management Console. In the upper part of the page, you will see a list (usually just a single entry) of OSGi Bundle Repositories known to Sling. In the lower part of the list you see the bundles available from these repositories. To install or update bundles, just check the respective button and click on the Deploy Selected or Deploy and Start Selected button at the bottom of the page depending on whether you want to start the bundle(s) after installation or not.

+ +

See below for more information on OSGi Bundle Repository management.

+ + + +

The Bundles page

+ +

You may also want to upgrade already installed bundles from the Bundles page of the Sling Management Console. For each bundle listed in this page, there is an Upgrade button. If there is an upgrade to the installed bundle available in the OSGi Bundle Repository, the button is enabled and clicking on the button will upgrade the respective bundle. If no upgrade is available from the OSGi Bundle Repository, this button is disabled.

+ + + +

Managing OSGi Bundle Repositories

+ +

Currently management of known OSGi Bundle Repositories is very simple. If a configured bundle repository is not available on startup, it will be marked as being inactive. If you know the repository is now available, you may click on the Refresh button, to activate it. Similarly, the contents of the repository may be modified by for example adding new bundles or updating bundles in the repository, these changes will be made known to Sling by clicking the Refresh button.

+ +

There exists no GUI functionality yet to add a new repository to the list of known repositories. Instead you may submit a request with parameters action whose value must be refreshOBR and repository whose value must be the URL to the repository descriptor file generally called repository.xml.

+ +

For example, if you run Sling on http://localhost:7402/sample with default location of the Sling Management Console, the following request would add a repository at /tmp/repo/repository.xml in the filesystem:

+ +
+
http://localhost:7402/sample/system/console/bundlerepo?action=refreshOBR&repository=file:///tmp/repo/repository.xml
+
+
+ +

Note: Only use file: URLs if you know Sling has access to the named file !

+
+Last modified by mykee on 2009-06-01 07:34:34.0 +
+
+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. +
+
+ + + Propchange: sling/site/trunk/content/site/installing-and-upgrading-bundles.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/site/trunk/content/site/installing-and-upgrading-bundles.html ------------------------------------------------------------------------------ svn:keywords = Id Propchange: sling/site/trunk/content/site/installing-and-upgrading-bundles.html ------------------------------------------------------------------------------ svn:mime-type = text/plain