Anyone have any great ideas on how to fix broken links to the integration tests now that they were moved into a separate module? I fear my confluence-fu isn't up to the task.
Justin Begin forwarded message: > From: [email protected] > Date: June 21, 2010 9:40:00 AM EDT > To: [email protected] > Subject: [CONF] Apache Sling Website > Servlets > Reply-To: [email protected] > > Servlets > Page edited by Justin Edelson > Comment: fixing link to old testing module > > Changes (1) > ... > The > [launchpad/test-services|http://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/] > module contains test servlets that use various combinations of the above > properties. > > The > [launchpad/testing|http://svn.apache.org/repos/asf/sling/trunk/launchpad/testing/] > > [launchpad/integration-tests|http://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/]module > contains a number of tests (like > the[ExtensionServletTest|http://svn.apache.org/repos/asf/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ExtensionServletTest.java][ExtensionServletTest|http://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ExtensionServletTest.java] > for example) that verify the results. > > Such tests run as part of our continuous integration process, to demonstrate > and verify the behavior of the various servlet registration mechanisms, in a > way that's guaranteed to be in sync with the actual Sling core code. If you > have an idea for additional tests, make sure to let us know! > ... > Full Content > Servlets and Scripts > Servlets can be registered as OSGi services. The following service reference > properties are defined for Servlets defined as OSGi services of type > javax.servlet.Servlet: > > Name Description > sling.servlet.paths A list of absolute paths under which the servlet is > accessible as a Resource. The property value must either be a single String, > an array of Strings or a Vector of Strings. > sling.servlet.resourceTypes The resource type(s) supported by the servlet. > The property value must either be a single String, an array of Strings or a > Vector of Strings. This property is ignored if the sling.servlet.paths > property is set. > sling.servlet.selectors The request URL selectors supported by the > servlet. The selectors must be configured as they would be specified in the > URL that is as a list of dot-separated strings such as <em>print.a4</em>. The > property value must either be a single String, an array of Strings or a > Vector of Strings. This property is ignored if the sling.servlet.paths > property is set. > sling.servlet.extensions The request URL extensions supported by the > servlet for GET requests. The property value must either be a single String, > an array of Strings or a Vector of Strings. This property is ignored if the > sling.servlet.pathsproperty is set or other methods than GET are declared in > sling.servlet.methods. > sling.servlet.methods The request methods supported by the servlet. The > property value must either be a single String, an array of Strings or a > Vector of Strings. This property is ignored if the sling.servlet.paths > property is set. > sling.servlet.prefix The absolute prefix to make relative paths absolute. > This property is a String and is optional. If it is not set, the actual > prefix used is derived from the search path of the ResourceResolver at the > time of registration. > A SlingServletResolver will listen for Servletservices and - given the > correct service registration properties - provide the servlets as resources > in the (virtual) resource tree. Such servlets are provided as ServletResource > instances which adapt to thejavax.servlet.Servlet class. > > For a Servlet registered as an OSGi service to be used by the Sling Servlet > Resolver, the following restrictions apply: > > Either the sling.servlet.paths or the sling.servlet.resourceTypes service > reference property must be set. If neither is set, the Servlet service is > ignored. > If the sling.servlet.paths property is set, all other sling.servlet.* > properties are ignored. > Each path to be used for registration - either from the sling.servlet.paths > property or constructed from the other sling.servlet.* properties - must be > absolute. Any relative path is made absolute by prefixing it with a root > path. This prefix may be set with the sling.servlet.prefix service > registration property. If this property is not set, the first entry in the > ResourceResolver search path for the ResourceResolver.getResource(String) > method is used as the prefix. If this entry cannot be derived, a simpe slash > - / - is used as the prefix. > > Automated tests > The launchpad/test-services module contains test servlets that use various > combinations of the above properties. > > The launchpad/integration-tests module contains a number of tests (like the > ExtensionServletTest for example) that verify the results. > > Such tests run as part of our continuous integration process, to demonstrate > and verify the behavior of the various servlet registration mechanisms, in a > way that's guaranteed to be in sync with the actual Sling core code. If you > have an idea for additional tests, make sure to let us know! > > Example: Registration by Path > sling.servlet.paths = \[ "/libs/sling/sample/html", "/libs/sling/sample/txt" > \] > sling.servlet.resourceTypes = \[ "sling/unused" \] > sling.servlet.selectors = \[ "img" \] > sling.servlet.extensions = \[ "html", "txt", "json" \] > A Servlet service registered with these properties is registered under the > following paths: > > /libs/sling/sample/html > /libs/sling/sample/txt > The registration properties sling.servlet.resourceTypes, > sling.servlet.selectors and sling.servlet.extensions are ignored because the > sling.servlet.paths property is set. > > Example: Registration by Resource Type etc. > sling.servlet.resourceTypes = \[ "sling/unused" \] > sling.servlet.selectors = \[ "img", "tab" \] > sling.servlet.extensions = \[ "html", "txt", "json" \] > A Servlet service registered with these properties is registered under the > following paths: > > prefix/sling/unused/img/html > prefix/sling/unused/img/txt > prefix/sling/unused/img/json > prefix/sling/unused/tab/html > prefix/sling/unused/tab/txt > prefix/sling/unused/tab/json > As explained the Servlet is registered for each permutation of the resource > types, selectors and extension. See above For an explanation of how prefix is > defined. > > Scripts are Servlets > The Sling API defines a SlingScript interface which is used to represent > (executable) scripts inside of Sling. This interface is implemented in the > scripting/core bundle in the DefaultSlingScript class which also implements > thejavax.servlet.Servlet. > > To further simplify the access to scripts from the Resource tree, the > scripting/core bundle registers an AdapterFactory to adapt Resources to > Scripts and Servlets (the SlingScriptAdapterFactory). In fact the adapter > factory returns instances of the DefaultSlingScript class for both Scripts > and Servlets. > > From the perspective of the Servlet resolver, scripts and servlets are > handled exactly the same. In fact, internally, Sling only handles with > Servlets, whereas scripts are packed inside a Servlet wrapping and > representing the script. > > Default Servlet(s) > As explained in the Resolution Process section above, a default Servlet is > selected if no servlet (or script) for the current resource type can be > found. To make the provisioning of a default Servlet as versatile as > provisioning per resource type Servlets (or scripts), the default Servlet is > selected with just a special resource type sling/servlet/default. > > The actual Servlet or Script called as the default Servlet is resolved > exactly the same way as for any resource type. That is, also for the default > Servlet selection, the request selectors and extension or method are > considered. Also, the Servlet may be a Servlet registered as an OSGi service > or it may be a Script stored in the repository or provided by any bundle. > > Finally, if not even a registered default Servlet may be resolved for the > request, because none has been registered, the servlets/resolver bundle > provides a fall back the DefaultServlet with the following functionality: > > If an NonExistingResource was created for the request the DefaultServlet > sends a 404 (Not Found) > Otherwise the DefaultServlet sends a 500 (Internal Server Error), because > normally at least a NonExistingResource should be created > OptingServlet interface > If a registered servlet implements the OptingServlet interface, Sling uses > that servlet's accepts(SlingHttpServletRequest request) method to refine the > servlet resolution process. > > In this case, the servlet is only selected for processing the current request > if its accept method returns true. > > Error Handler Servlet(s) or Scripts > Error handling support is now described on the Errorhandling page. > > Change Notification PreferencesView Online | View Changes | Add Comment
