Save This Page
Home » » » [javadoc | source]
public class: SlingServletDelegate [javadoc | source]

All Implemented Interfaces:
    Launcher, Servlet, ServletConfig, Serializable

The SlingServletDelegate serves as a basic servlet for Project Sling. The tasks of this servlet are as follows:

Request Handling

This servlet handles request by forwarding to a delegatee servlet. The delegatee servlet is automatically retrieved from the service registry by the #getDelegatee() . This method also makes sure, the such a servlet actually exits by throwing an UnvailableException if not and also makes sure the servlet is initialized.

Launch Configuration

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

  1. The is read from the servlet class path. This properties file contains default settings.
  2. Extensions of this servlet may provide additional properties to be loaded overwriting the #loadConfigProperties(String) method.
  3. Finally, web application init parameters are added to the properties and may overwrite existing properties of the same name(s).

After loading all properties, variable substitution takes place on the property values. A variable is indicated as ${<prop-name>} where <prop-name> is the name of a system or configuration property (configuration properties override system properties). Variables may be nested and are resolved from inner-most to outer-most. For example, the property value ${outer-${inner}} is resolved by first resolving ${inner} and then resolving the property whose name is the catenation of outer- and the result of resolving ${inner}.


This servlet logs through the servlet container logging mechanism by calling the GenericServlet.log methods. Bundles launched within the framework provided by this servlet may use whatever logging mechanism they choose to use. The Commons OSGI Log Bundle provides an OSGi Log Service implementation, which also provides access to Apache Commons Logging, SLF4J and Log4J logging. It is recommended that this bundle is used to setup and configure logging for systems based on this servlet.
Method from Summary:
destroy,   getDelegatee,   init,   service,   setCommandLine,   setNotifiable,   setSlingHome,   start,   stop
Methods from javax.servlet.GenericServlet:
destroy,   getInitParameter,   getInitParameterNames,   getServletConfig,   getServletContext,   getServletInfo,   getServletName,   init,   init,   log,   log,   service
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from Detail:
 public final  void destroy() 
    Destroys this servlet by shutting down the OSGi framework and hence the delegatee servlet if one is set at all.
 Servlet getDelegatee() 
 public final  void init() throws ServletException 
    Initializes this servlet by loading the framework configuration properties, starting the OSGi framework (Apache Felix) and exposing the system bundle context and the Felix instance as servlet context attributes.
 public final  void service(ServletRequest req,
    ServletResponse res) throws ServletException, IOException 
    Services the request by delegating to the delegatee servlet. If no delegatee servlet is available, a UnavailableException is thrown.
 public  void setCommandLine(Map<String, String> args) 
 public  void setNotifiable(Notifiable notifiable) 
 public  void setSlingHome(String slingHome) 
 public boolean start() 
 public  void stop()