felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r938334 - in /felix/trunk: scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/ scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/
Date Tue, 27 Apr 2010 07:02:24 GMT
Author: cziegeler
Date: Tue Apr 27 07:02:23 2010
New Revision: 938334

URL: http://svn.apache.org/viewvc?rev=938334&view=rev
Log:
FELIX-2303 : Add annotation for a Sling servlet filter

Added:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
  (with props)
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
  (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
  (with props)
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
  (with props)
Modified:
    felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java

Added: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java?rev=938334&view=auto
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
(added)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
Tue Apr 27 07:02:23 2010
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.annotations.sling;
+
+import java.lang.annotation.*;
+
+/**
+ * Marks servlet classes as SCR component, and allows to add a
+ * filter to Sling's processing.
+ * This annotation generates to private properties for the
+ * order and the scope.
+ * By default it also generates a component and a service tag,
+ * but this generation can be overriden.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+@Documented
+public @interface SlingFilter {
+
+    /**
+     * The order of the filter.
+     * This value is used to sort the filters. Filters with a lower order
+     * are executed before a filter with a higher order. If two filters
+     * have the same order, they are executed in an undefined order.
+     */
+    int order();
+
+    /**
+     * The scope of a filter.
+     * If the filter has request scope, it is run once for a request.
+     * If the filter has component scope, it is run once for every included
+     * component (rendering).
+     */
+    SlingFilterScope scope() default SlingFilterScope.REQUEST;
+
+    /**
+     * Whether to generate a default SCR component tag with. If
+     * set to false, a {@link org.apache.felix.scr.annotations.Component}
+     * annotation can be added manually with defined whatever configuration
+     * needed.
+     */
+    boolean generateComponent() default true;
+
+    /**
+     * Whether to generate a default SCR service tag with
+     * "interface=javax.servlet.Filter". If set to false, a
+     * {@link org.apache.felix.scr.annotations.Service} annotation can be added
+     * manually with defined whatever configuration needed.
+     */
+    boolean generateService() default true;
+
+    /**
+     * Defines the Component name also used as the PID for the Configuration
+     * Admin Service. Default value: Fully qualified name of the Java class.
+     */
+    String name() default "";
+
+    /**
+     * Whether Metatype Service data is generated or not. If this parameter is
+     * set to true Metatype Service data is generated in the
+     * <code>metatype.xml</code> file for this component. Otherwise no Metatype
+     * Service data is generated for this component.
+     */
+    boolean metatype() default false;
+
+    /**
+     * This is generally used as a title for the object described by the meta
+     * type. This name may be localized by prepending a % sign to the name.
+     * Default value: %&lt;name&gt;.name
+     */
+    String label() default "";
+
+    /**
+     * This is generally used as a description for the object described by the
+     * meta type. This name may be localized by prepending a % sign to the name.
+     * Default value: %&lt;name&gt;.description
+     */
+    String description() default "";
+}

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java?rev=938334&view=auto
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
(added)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
Tue Apr 27 07:02:23 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.annotations.sling;
+
+/**
+ * The possible scopes for the {@link SlingFilter#scope()} annotation.
+ */
+public enum SlingFilterScope {
+
+    REQUEST("request"),
+
+    COMPONENT("component");
+
+    private final String scope;
+
+    private SlingFilterScope(final String scope) {
+        this.scope = scope;
+    }
+
+    /**
+     * @return String representation of the scope
+     */
+    public String getScope() {
+        return this.scope;
+    }
+}

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingFilterScope.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java?rev=938334&r1=938333&r2=938334&view=diff
==============================================================================
--- felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
(original)
+++ felix/trunk/scr-annotations/src/main/java/org/apache/felix/scr/annotations/sling/SlingServlet.java
Tue Apr 27 07:02:23 2010
@@ -18,15 +18,11 @@
  */
 package org.apache.felix.scr.annotations.sling;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
 /**
- * Marks servlet classes as felix SCR component, and allows to configure sling
- * resource resolving mapping.
+ * Marks servlet classes as SCR component, and allows to configure
+ * Sling's resource resolver mapping.
  */
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.SOURCE)
@@ -42,7 +38,7 @@ public @interface SlingServlet {
     boolean generateComponent() default true;
 
     /**
-     * Whether to generate a default SCR service tag with with
+     * Whether to generate a default SCR service tag with
      * "interface=javax.servlet.Servlet". If set to false, a
      * {@link org.apache.felix.scr.annotations.Service} annotation can be added
      * manually with defined whatever configuration needed.

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java?rev=938334&r1=938333&r2=938334&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingAnnotationTagProvider.java
Tue Apr 27 07:02:23 2010
@@ -21,7 +21,7 @@ package org.apache.felix.scrplugin.tags.
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.felix.scr.annotations.sling.SlingServlet;
+import org.apache.felix.scr.annotations.sling.*;
 import org.apache.felix.scrplugin.tags.JavaField;
 import org.apache.felix.scrplugin.tags.JavaTag;
 import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
@@ -33,56 +33,109 @@ import org.apache.felix.scrplugin.tags.a
  */
 public class SlingAnnotationTagProvider implements AnnotationTagProvider {
 
-    public List<JavaTag> getTags(com.thoughtworks.qdox.model.Annotation annotation,
-            AnnotationJavaClassDescription description, JavaField field) {
-        List<JavaTag> tags = new ArrayList<JavaTag>();
-
-        if (annotation.getType().getJavaClass().getFullyQualifiedName().equals(SlingServlet.class.getName()))
{
+    /**
+     * @see org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider#getTags(com.thoughtworks.qdox.model.Annotation,
org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription, org.apache.felix.scrplugin.tags.JavaField)
+     */
+    public List<JavaTag> getTags(final com.thoughtworks.qdox.model.Annotation annotation,
+            final AnnotationJavaClassDescription description,
+            final JavaField field)
+   {
+        final String annotationName = annotation.getType().getJavaClass().getFullyQualifiedName();
+        final List<JavaTag> tags = new ArrayList<JavaTag>();
+
+        // SlingServlet annotation
+        if (annotationName.equals(SlingServlet.class.getName()))
+        {
 
             // generate @Component tag if required
             boolean generateComponent = Util.getBooleanValue(annotation, "generateComponent",
SlingServlet.class);
-            if (generateComponent) {
+            if (generateComponent)
+            {
                 tags.add(new SlingServletComponentTag(annotation, description));
             }
 
             // generate @Service tag if required
             boolean generateService = Util.getBooleanValue(annotation, "generateService",
SlingServlet.class);
-            if (generateService) {
+            if (generateService)
+            {
                 tags.add(new SlingServletServiceTag(annotation, description));
             }
 
             // generate @Property tags
             // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_PATHS}
             String[] paths = Util.getStringValues(annotation, description, "paths");
-            if (paths != null && paths.length != 0) {
+            if (paths != null && paths.length != 0)
+            {
                 tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.paths", paths,
description));
             }
 
             // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES}
             String[] resourceTypes = Util.getStringValues(annotation, description, "resourceTypes");
-            if (resourceTypes != null && resourceTypes.length != 0) {
+            if (resourceTypes != null && resourceTypes.length != 0)
+            {
                 tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.resourceTypes",
resourceTypes, description));
             }
 
             // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_SELECTORS}
             String[] selectors = Util.getStringValues(annotation, description, "selectors");
-            if (selectors != null && selectors.length != 0) {
+            if (selectors != null && selectors.length != 0)
+            {
                 tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.selectors",
selectors, description));
             }
 
             // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_EXTENSIONS}
             String[] extensions = Util.getStringValues(annotation, description, "extensions");
-            if (extensions != null && extensions.length != 0) {
+            if (extensions != null && extensions.length != 0)
+            {
                 tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.extensions",
extensions, description));
             }
 
             // {@see org.apache.sling.servlets.resolver.internal.ServletResolverConstants.SLING_SERVLET_METHODS}
             String[] methods = Util.getStringValues(annotation, description, "methods");
-            if (methods != null && methods.length != 0) {
+            if (methods != null && methods.length != 0)
+            {
                 tags.add(new SlingServletPropertyTag(annotation, "sling.servlet.methods",
methods, description));
             }
 
         }
+        // Filter annotation
+        else if ( annotationName.equals(SlingFilter.class.getName()) )
+        {
+            // generate @Component tag if required
+            boolean generateComponent = Util.getBooleanValue(annotation, "generateComponent",
SlingFilter.class);
+            if (generateComponent)
+            {
+                String name = Util.getStringValue(annotation, description, "name", SlingFilter.class);
+                if ( name != null && name.trim().length() == 0 ) {
+                    name = null;
+                }
+                String label = Util.getStringValue(annotation, description, "label", SlingFilter.class);
+                if ( label != null && label.trim().length() == 0 ) {
+                    label = null;
+                }
+                String desc = Util.getStringValue(annotation, description, "description",
SlingFilter.class);
+                if ( desc != null && desc.trim().length() == 0 ) {
+                    desc = null;
+                }
+                final boolean createMetatype = Util.getBooleanValue(annotation, "metatype",
SlingFilter.class);
+                tags.add(new SlingFilterComponentTag(annotation, description, createMetatype,
name, label, desc));
+            }
+
+            // generate @Service tag if required
+            boolean generateService = Util.getBooleanValue(annotation, "generateService",
SlingFilter.class);
+            if (generateService)
+            {
+                tags.add(new SlingFilterServiceTag(annotation, description));
+            }
+
+            // property order
+            final int order = Util.getIntValue(annotation, "order", SlingFilter.class);
+            tags.add(new SlingServletPropertyTag(annotation, "filter.order",String.valueOf(order),
description, "Integer", true));
+
+            // property scope
+            final SlingFilterScope scope = Util.getEnumValue(annotation, "scope", SlingFilterScope.class,
SlingFilter.class);
+            tags.add(new SlingServletPropertyTag(annotation, "filter.scope",scope.getScope(),
description, null, true));
+        }
 
         return tags;
     }

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java?rev=938334&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
(added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
Tue Apr 27 07:02:23 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.sling;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.defaulttag.AbstractTag;
+
+import com.thoughtworks.qdox.model.Annotation;
+
+/**
+ * Description of a java tag for components.
+ */
+public class SlingFilterComponentTag extends AbstractTag {
+
+    private final boolean createMetatype;
+    private final String name;
+    private final String label;
+    private final String description;
+
+    /**
+     * @param desc Description
+     */
+    public SlingFilterComponentTag(final Annotation annotation,
+            final JavaClassDescription desc,
+            final boolean createMetatype,
+            final String name,
+            final String label,
+            final String description) {
+        super(annotation, desc, null);
+        this.createMetatype = createMetatype;
+        this.name = name;
+        this.label = label;
+        this.description = description;
+    }
+
+    @Override
+    public String getName() {
+        return Constants.COMPONENT;
+    }
+
+    @Override
+    public Map<String, String> createNamedParameterMap() {
+        final Map<String, String> params = new HashMap<String, String>();
+        if ( this.name != null ) {
+            params.put(Constants.COMPONENT_NAME, this.name);
+        }
+        if ( this.label != null ) {
+            params.put(Constants.COMPONENT_LABEL, this.label);
+        }
+        if ( this.description != null ) {
+            params.put(Constants.COMPONENT_DESCRIPTION, this.description);
+        }
+        params.put(Constants.COMPONENT_METATYPE, String.valueOf(this.createMetatype));
+        return params;
+    }
+
+}

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterComponentTag.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java?rev=938334&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
(added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
Tue Apr 27 07:02:23 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.sling;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.servlet.Filter;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.defaulttag.AbstractTag;
+
+import com.thoughtworks.qdox.model.Annotation;
+
+/**
+ * Description of a java tag for components.
+ */
+public class SlingFilterServiceTag extends AbstractTag {
+
+    private static final Map<String, String> INTERFACE_MAP =
+        Collections.singletonMap(Constants.SERVICE_INTERFACE, Filter.class.getName());
+
+    /**
+     * @param desc Description
+     */
+    public SlingFilterServiceTag(Annotation annotation, JavaClassDescription desc) {
+        super(annotation, desc, null);
+    }
+
+    @Override
+    public String getName() {
+        return Constants.SERVICE;
+    }
+
+    @Override
+    public Map<String, String> createNamedParameterMap() {
+        return INTERFACE_MAP;
+    }
+
+}

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingFilterServiceTag.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java?rev=938334&r1=938333&r2=938334&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletComponentTag.java
Tue Apr 27 07:02:23 2010
@@ -18,7 +18,7 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.sling;
 
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.Map;
 
 import org.apache.felix.scrplugin.Constants;
@@ -32,6 +32,9 @@ import com.thoughtworks.qdox.model.Annot
  */
 public class SlingServletComponentTag extends AbstractTag {
 
+    private static final Map<String, String> IMMEDIATE_MAP =
+            Collections.singletonMap(Constants.COMPONENT_IMMEDIATE, String.valueOf(true));
+
     /**
      * @param desc Description
      */
@@ -46,11 +49,7 @@ public class SlingServletComponentTag ex
 
     @Override
     public Map<String, String> createNamedParameterMap() {
-        final Map<String, String> map = new HashMap<String, String>();
-
-        map.put(Constants.COMPONENT_IMMEDIATE, String.valueOf(true));
-
-        return map;
+        return IMMEDIATE_MAP;
     }
 
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java?rev=938334&r1=938333&r2=938334&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletPropertyTag.java
Tue Apr 27 07:02:23 2010
@@ -18,9 +18,7 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.sling;
 
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.*;
 
 import org.apache.felix.scrplugin.Constants;
 import org.apache.felix.scrplugin.helper.StringUtils;
@@ -30,12 +28,14 @@ import org.apache.felix.scrplugin.tags.a
 import com.thoughtworks.qdox.model.Annotation;
 
 /**
- * Description of a java tag for components.
+ * A property tag.
  */
 public class SlingServletPropertyTag extends AbstractTag {
 
     protected final String name;
     protected final String[] values;
+    protected final String type;
+    protected final Boolean isPrivate;
 
     /**
      * @param name Property name
@@ -46,6 +46,26 @@ public class SlingServletPropertyTag ext
         super(annotation, desc, null);
         this.name = name;
         this.values = values;
+        this.type = null;
+        this.isPrivate = null;
+    }
+
+    /**
+     * @param name Property name
+     * @param value Property value
+     * @param desc Description
+     */
+    public SlingServletPropertyTag(final Annotation annotation,
+            final String name,
+            final String value,
+            final JavaClassDescription desc,
+            final String type,
+            final boolean isPrivate) {
+        super(annotation, desc, null);
+        this.name = name;
+        this.values = new String[] {value};
+        this.type = type;
+        this.isPrivate = isPrivate;
     }
 
     @Override
@@ -71,6 +91,13 @@ public class SlingServletPropertyTag ext
             }
         }
 
+        if ( this.type != null ) {
+            map.put(Constants.PROPERTY_TYPE, type);
+        }
+        if ( this.isPrivate != null ) {
+            map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.isPrivate));
+        }
+
         return map;
     }
 

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java?rev=938334&r1=938333&r2=938334&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/sling/SlingServletServiceTag.java
Tue Apr 27 07:02:23 2010
@@ -18,7 +18,7 @@
  */
 package org.apache.felix.scrplugin.tags.annotation.sling;
 
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.Map;
 
 import javax.servlet.Servlet;
@@ -34,6 +34,9 @@ import com.thoughtworks.qdox.model.Annot
  */
 public class SlingServletServiceTag extends AbstractTag {
 
+    private static final Map<String, String> INTERFACE_MAP =
+        Collections.singletonMap(Constants.SERVICE_INTERFACE, Servlet.class.getName());
+
     /**
      * @param desc Description
      */
@@ -48,11 +51,7 @@ public class SlingServletServiceTag exte
 
     @Override
     public Map<String, String> createNamedParameterMap() {
-        final Map<String, String> map = new HashMap<String, String>();
-
-        map.put(Constants.SERVICE_INTERFACE, Servlet.class.getName());
-
-        return map;
+        return INTERFACE_MAP;
     }
 
 }



Mime
View raw message