This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-models-provider.git
commit c132ee9da9f06054572868d0bb617199eca70bc8 Author: Radu Cotescu <[email protected]> AuthorDate: Mon Oct 10 15:39:09 2016 +0000 SLING-6125 - Switch HTL to OSGi R6 annotations * removed maven-scr-plugin and configured maven-bundle-plugin to generate SCR metadata * replaced Felix SCR annotations with OSGi Component + Metatype annotations * removed unused dependencies git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1764122 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 18 +++++-- .../models/impl/SlingModelsUseProvider.java | 59 ++++++++++++---------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index e633d0a..c77fe20 100644 --- a/pom.xml +++ b/pom.xml @@ -56,12 +56,22 @@ <plugins> <plugin> <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> + <executions> + <execution> + <id>scr-metadata</id> + <goals> + <goal>manifest</goal> + </goals> + </execution> + </executions> + <configuration> + <exportScr>true</exportScr> + <instructions> + <Require-Capability>io.sightly; filter:="(&(version>=1.0)(!(version>=2.0)))"</Require-Capability> + </instructions> + </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java b/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java index 1de27bf..2cbee26 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java +++ b/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java @@ -22,11 +22,6 @@ import java.util.regex.Pattern; import javax.script.Bindings; import javax.servlet.ServletRequest; -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.Reference; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.scripting.SlingBindings; @@ -36,6 +31,11 @@ import org.apache.sling.scripting.sightly.render.RenderContext; import org.apache.sling.scripting.sightly.use.ProviderOutcome; import org.apache.sling.scripting.sightly.use.UseProvider; import org.osgi.framework.Constants; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,29 +58,36 @@ import org.slf4j.LoggerFactory; * </p> */ @Component( - metatype = true, - label = "Apache Sling Scripting HTL Sling Models Use Provider", - description = "The Sling Models Use Provider is responsible for instantiating Sling Models to be used with Sightly's Use-API." + service = UseProvider.class, + configurationPid = "org.apache.sling.scripting.sightly.models.impl.SlingModelsUseProvider", + property = { + /** + * Must have a higher priority than {@link org.apache.sling.scripting.sightly.impl.engine.extension.use.JavaUseProvider} but lower + * than {@link org.apache.sling.scripting.sightly.impl.engine.extension.use.RenderUnitProvider} to kick in before the + * JavaUseProvider but after the RenderUnitProvider. + */ + Constants.SERVICE_RANKING + ":Integer=95" + } +) +@Designate( + ocd = SlingModelsUseProvider.Configuration.class ) -@Service -@Properties({ - @Property( - name = Constants.SERVICE_RANKING, - label = "Service Ranking", - description = - "The Service Ranking value acts as the priority with which this Use Provider is queried to return an Use-object. A higher " + - "value represents a higher priority.", - /** - * Must have a higher priority than {@link org.apache.sling.scripting.sightly.impl.engine.extension.use.JavaUseProvider} but lower - * than {@link org.apache.sling.scripting.sightly.impl.engine.extension.use.RenderUnitProvider} to kick in before the - * JavaUseProvider but after the RenderUnitProvider. - */ - intValue = 95, - propertyPrivate = false - ) -}) public class SlingModelsUseProvider implements UseProvider { + @ObjectClassDefinition( + name = "Apache Sling Scripting HTL Sling Models Use Provider Configuration", + description = "HTL Sling Models Use Provider configuration options" + ) + @interface Configuration { + + @AttributeDefinition( + name = "Service Ranking", + description = "The Service Ranking value acts as the priority with which this Use Provider is queried to return an " + + "Use-object. A higher value represents a higher priority." + ) + int service_ranking() default 95; + } + private static final Logger LOGGER = LoggerFactory.getLogger(SlingModelsUseProvider.class); private static final Pattern JAVA_PATTERN = Pattern.compile( "([[\\p{L}&&[^\\p{Lu}]]_$][\\p{L}\\p{N}_$]*\\.)*[\\p{Lu}_$][\\p{L}\\p{N}_$]*"); @@ -145,7 +152,7 @@ public class SlingModelsUseProvider implements UseProvider { } private Map<String, Object> setRequestAttributes(final ServletRequest request, final Bindings arguments) { - Map<String, Object> overrides = new HashMap<String, Object>(); + Map<String, Object> overrides = new HashMap<>(); for (Map.Entry<String, Object> entry : arguments.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
