incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1244316 - in /sling/trunk/bundles/servlets/get: ./ src/main/java/org/apache/sling/servlets/get/impl/ src/main/java/org/apache/sling/servlets/get/impl/impl/info/
Date Wed, 15 Feb 2012 02:18:33 GMT
Author: justin
Date: Wed Feb 15 02:18:33 2012
New Revision: 1244316

URL: http://svn.apache.org/viewvc?rev=1244316&view=rev
Log:
SLING-2363 - converting servlets.get to use SCR annotations

Modified:
    sling/trunk/bundles/servlets/get/pom.xml
    sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
    sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultHeadServlet.java
    sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
    sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/impl/info/SlingInfoServlet.java

Modified: sling/trunk/bundles/servlets/get/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/pom.xml?rev=1244316&r1=1244315&r2=1244316&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/pom.xml (original)
+++ sling/trunk/bundles/servlets/get/pom.xml Wed Feb 15 02:18:33 2012
@@ -107,6 +107,10 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
         <!-- Testing -->
         <dependency>
             <groupId>junit</groupId>

Modified: sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java?rev=1244316&r1=1244315&r2=1244316&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
(original)
+++ sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
Wed Feb 15 02:18:33 2012
@@ -26,6 +26,10 @@ import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
@@ -44,23 +48,20 @@ import org.slf4j.LoggerFactory;
 
 /**
  * A SlingSafeMethodsServlet that renders the current Resource as simple HTML
- *
- * @scr.component name="org.apache.sling.servlets.get.DefaultGetServlet"
- *                immediate="true" label="%servlet.get.name"
- *                description="%servlet.get.description"
- * @scr.service interface="javax.servlet.Servlet"
- *
- * @scr.property name="service.description" value="Default GET Servlet"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- *
- * Use this as a default servlet for Sling
- * @scr.property name="sling.servlet.resourceTypes"
- *               value="sling/servlet/default" private="true"
- * @scr.property name="sling.servlet.prefix" value="-1" type="Integer" private="true"
- *
- * Generic handler for all get requests
- * @scr.property name="sling.servlet.methods" value="GET" private="true"
  */
+@Component(immediate=true, metatype=true, name="org.apache.sling.servlets.get.DefaultGetServlet",
label="%servlet.get.name", description="%servlet.get.description")
+@Service(Servlet.class)
+@Properties({
+    @Property(name="service.description", value="Default GET Servlet"),
+    @Property(name="service.vendor", value="The Apache Software Foundation"),
+    
+    // Use this as a default servlet for Sling
+    @Property(name="sling.servlet.resourceTypes", value="sling/servlet/default", propertyPrivate=true),
+    @Property(name="sling.servlet.prefix", intValue=-1, propertyPrivate=true),
+    
+    // Generic handler for all get requests
+    @Property(name="sling.servlet.methods", value="GET", propertyPrivate=true)
+})
 public class DefaultGetServlet extends SlingSafeMethodsServlet {
 
     private static final long serialVersionUID = -5815904221043005085L;
@@ -71,41 +72,41 @@ public class DefaultGetServlet extends S
 
     private Servlet streamerServlet;
 
-    /** @scr.property */
+    @Property
     private static final String ALIAS_PROPERTY = "aliases";
 
-    /** @scr.property valueRef="DEFAULT_INDEX_PROPERTY" type="Boolean" */
-    private static final String INDEX_PROPERTY = "index";
-
     private static final boolean DEFAULT_INDEX_PROPERTY = false;
 
-    /** @scr.property valueRef="DEFAULT_INDEX_FILES_PROPERTY" */
-    private static final String INDEX_FILES_PROPERTY = "index.files";
+    @Property(boolValue=DEFAULT_INDEX_PROPERTY)
+    private static final String INDEX_PROPERTY = "index";
 
     private static final String[] DEFAULT_INDEX_FILES_PROPERTY = { "index",
         "index.html" };
 
+    @Property(value={ "index", "index.html" })
+    private static final String INDEX_FILES_PROPERTY = "index.files";
+
     /** Default value for renderer selection (value is "true"). */
     private static final boolean DEFAULT_RENDERER_PROPERTY = true;
 
-    /** @scr.property valueRef="DEFAULT_RENDERER_PROPERTY" type="Boolean" */
+    @Property(boolValue=DEFAULT_RENDERER_PROPERTY)
     private static final String HTML_RENDERER_PROPERTY = "enable.html";
 
-    /** @scr.property valueRef="DEFAULT_RENDERER_PROPERTY" type="Boolean" */
+    @Property(boolValue=DEFAULT_RENDERER_PROPERTY)
     private static final String TXT_RENDERER_PROPERTY = "enable.txt";
 
-    /** @scr.property valueRef="DEFAULT_RENDERER_PROPERTY" type="Boolean" */
+    @Property(boolValue=DEFAULT_RENDERER_PROPERTY)
     private static final String JSON_RENDERER_PROPERTY = "enable.json";
 
-    /** @scr.property valueRef="DEFAULT_RENDERER_PROPERTY" type="Boolean" */
+    @Property(boolValue=DEFAULT_RENDERER_PROPERTY)
     private static final String XML_RENDERER_PROPERTY = "enable.xml";
     
-    /** @scr.property valueRef="DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS" type="Integer" */
-    public static final String JSON_RENDERER_MAXIMUM_RESULTS_PROPERTY = "json.maximumresults";
-    
     /** Default value for the maximum amount of results that should be returned by the jsonResourceWriter
*/
     public static final int DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS = 200;
     
+    @Property(intValue=DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS)
+    public static final String JSON_RENDERER_MAXIMUM_RESULTS_PROPERTY = "json.maximumresults";
+    
     private int jsonMaximumResults;
     
     /** Additional aliases. */

Modified: sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultHeadServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultHeadServlet.java?rev=1244316&r1=1244315&r2=1244316&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultHeadServlet.java
(original)
+++ sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultHeadServlet.java
Wed Feb 15 02:18:33 2012
@@ -23,9 +23,15 @@ import java.io.PrintWriter;
 import java.io.Writer;
 
 import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
@@ -41,18 +47,16 @@ import org.slf4j.LoggerFactory;
  * output which does not really write to the client and the forwards to the same
  * requested URL (resource actually) acting as if the request was placed with a
  * <i>GET</i> method.
- *
- * @scr.component immediate="true" metatype="no" policy="ignore"
- * @scr.service interface="javax.servlet.Servlet"
- * @scr.property name="service.description" value="Default HEAD Servlet"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- *               Use this as a default servlet for Sling
- * @scr.property name="sling.servlet.resourceTypes"
- *               value="sling/servlet/default"
- * @scr.property name="sling.servlet.prefix" value="-1" type="Integer" Generic
- *               handler for all get requests
- * @scr.property name="sling.servlet.methods" value="HEAD"
  */
+@Component(immediate=true, policy=ConfigurationPolicy.IGNORE)
+@Service(Servlet.class)
+@Properties({
+    @Property(name="service.description", value="Default HEAD Servlet"),
+    @Property(name="service.vendor", value="The Apache Software Foundation"),
+    @Property(name="sling.servlet.resourceTypes", value="sling/servlet/default"),
+    @Property(name="sling.servlet.prefix", intValue=-1),
+    @Property(name="sling.servlet.methods", value="HEAD")    
+})
 public class DefaultHeadServlet extends SlingSafeMethodsServlet {
 
     private static final long serialVersionUID = 7416222678552027044L;

Modified: sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java?rev=1244316&r1=1244315&r2=1244316&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
(original)
+++ sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/RedirectServlet.java
Wed Feb 15 02:18:33 2012
@@ -25,6 +25,10 @@ import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
@@ -54,16 +58,17 @@ import org.slf4j.LoggerFactory;
  * status is sent where the target is the relative URL from the current resource
  * to the target resource. Selectors, extension, suffix and query string are
  * also appended to the redirect URL.
- *
- * @scr.component immediate="true"
- * @scr.service interface="javax.servlet.Servlet"
- * @scr.property name="service.description" value="Request Redirect Servlet"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.property name="sling.servlet.resourceTypes" value="sling:redirect"  private="true"
- * @scr.property name="sling.servlet.methods" value="GET" private="true"
- * @scr.property name="sling.servlet.prefix" value="-1" type="Integer"
- *               private="true"
  */
+@SuppressWarnings("serial")
+@Component(immediate=true, metatype=true)
+@Service(Servlet.class)
+@Properties({
+    @Property(name="service.description", value="Request Redirect Servlet"),
+    @Property(name="service.vendor", value="The Apache Software Foundation"),
+    @Property(name="sling.servlet.resourceTypes", value="sling:redirect", propertyPrivate=true),
+    @Property(name="sling.servlet.methods", value="GET", propertyPrivate=true),
+    @Property(name="sling.servlet.prefix", intValue=-1, propertyPrivate=true)   
+})
 public class RedirectServlet extends SlingSafeMethodsServlet {
 
     /** The name of the target property */
@@ -77,12 +82,12 @@ public class RedirectServlet extends Sli
 
     private Servlet jsonRendererServlet;
 
-    /** @scr.property valueRef="DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS" type="Integer" */
-    public static final String JSON_RENDERER_MAXIMUM_RESULTS_PROPERTY = "json.maximumresults";
-
     /** Default value for the maximum amount of results that should be returned by the jsonResourceWriter
*/
     public static final int DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS = 200;
 
+    @Property(intValue=DEFAULT_JSON_RENDERER_MAXIMUM_RESULTS)
+    public static final String JSON_RENDERER_MAXIMUM_RESULTS_PROPERTY = "json.maximumresults";
+
     private int jsonMaximumResults;
 
     protected void activate(ComponentContext ctx) {

Modified: sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/impl/info/SlingInfoServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/impl/info/SlingInfoServlet.java?rev=1244316&r1=1244315&r2=1244316&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/impl/info/SlingInfoServlet.java
(original)
+++ sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/impl/info/SlingInfoServlet.java
Wed Feb 15 02:18:33 2012
@@ -24,8 +24,13 @@ import java.io.Writer;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.servlet.Servlet;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@@ -35,13 +40,15 @@ import org.osgi.service.component.Compon
 
 /**
  * The <code>SlingInfoServlet</code> TODO
- *
- * @scr.service interface="javax.servlet.Servlet"
- * @scr.component immediate="true" metatype="no"
- * @scr.property name="service.description" value="Sling Info Servlet"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.property name="sling.servlet.paths" value="/system/sling/info"
  */
+@SuppressWarnings("serial")
+@Component(immediate=true)
+@Service(Servlet.class)
+@Properties({
+    @Property(name="service.description", value="Sling Info Servlet"),
+    @Property(name="service.vendor", value="The Apache Software Foundation"),
+    @Property(name="sling.servlet.paths", value="/system/sling/info")
+})
 public class SlingInfoServlet extends SlingSafeMethodsServlet {
     
     /**



Mime
View raw message