This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.thymeleaf-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-thymeleaf.git
commit 04caf7d306fd008ce39e79768122b52842b33e4f Author: Oliver Lietz <[email protected]> AuthorDate: Thu Jun 23 19:08:23 2016 +0000 SLING-5075 Upgrade Thymeleaf to 3.0 tweak names, descriptions and messages git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/org.apache.sling.scripting.thymeleaf@1749977 13f79535-47bb-0310-9956-ffa450edef68 --- README.md | 2 +- ...tternSpecTemplateModeProviderConfiguration.java | 76 ---------------------- ...vider.java => PatternTemplateModeProvider.java} | 22 +++---- .../PatternTemplateModeProviderConfiguration.java | 76 ++++++++++++++++++++++ .../internal/ResourceBundleMessageResolver.java | 6 +- ...ResourceBundleMessageResolverConfiguration.java | 4 +- .../internal/SlingResourceTemplateResolver.java | 6 +- ...SlingResourceTemplateResolverConfiguration.java | 6 +- .../internal/ThymeleafScriptEngineFactory.java | 16 +++-- .../ThymeleafScriptEngineFactoryConfiguration.java | 21 +++--- 10 files changed, 119 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index 1a66c23..a85fb29 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Features * Supporting all of Thymeleaf's extension points: _TemplateResolver_s, _MessageResolver_s, _Dialect_s, _LinkBuilder_s, _DecoupledTemplateLogicResolver_, _CacheManager_ and _EngineContextFactory_ * `SlingResourceTemplateResolver` customizable through `TemplateModeProvider` * `ResourceBundleMessageResolver` backed by `ResourceBundleProvider` from `org.apache.sling.i18n` customizable through optional `AbsentMessageRepresentationProvider` -* `PatternSpecTemplateModeProvider` supporting `PatternSpec` configurations for all template modes (`HTML`, `XML`, `TEXT`, `JAVASCRIPT`, `CSS` and `RAW`) +* `PatternTemplateModeProvider` supporting `Pattern` configurations for all template modes (`HTML`, `XML`, `TEXT`, `JAVASCRIPT`, `CSS` and `RAW`) * `SlingDialect` * Thymeleaf's `TemplateEngine` registered as OSGi Service for direct use diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProviderConfiguration.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProviderConfiguration.java deleted file mode 100644 index e79c18f..0000000 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProviderConfiguration.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.sling.scripting.thymeleaf.internal; - -import org.osgi.service.metatype.annotations.AttributeDefinition; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; - -@ObjectClassDefinition( - name = "Apache Sling Scripting Thymeleaf “PatternSpec TemplateMode Provider”", - description = "PatternSpec TemplateMode Provider for Sling Scripting Thymeleaf" -) -@interface PatternSpecTemplateModeProviderConfiguration { - - @AttributeDefinition( - name = "patterns for Template Mode HTML", - description = "the template patterns (regular expressions) which should be handled by Template Mode HTML (e.g. *.html - NOTE: extension needs to be enabled for this script engine)" - ) - String[] htmlPatterns() default { - "*.html" - }; - - @AttributeDefinition( - name = "patterns for Template Mode XML", - description = "the template patterns (regular expressions) which should be handled by Template Mode XML (e.g. *.xml - NOTE: extension needs to be enabled for this script engine)" - ) - String[] xmlPatterns() default { - "*.xml" - }; - - @AttributeDefinition( - name = "patterns for Template Mode TEXT", - description = "the template patterns (regular expressions) which should be handled by Template Mode TEXT (e.g. *.txt - NOTE: extension needs to be enabled for this script engine)" - ) - String[] textPatterns() default { - "*.txt" - }; - - @AttributeDefinition( - name = "patterns for Template Mode JAVASCRIPT", - description = "the template patterns (regular expressions) which should be handled by Template Mode JAVASCRIPT (e.g. *.js - NOTE: extension needs to be enabled for this script engine)" - ) - String[] javascriptPatterns() default { - "*.js" - }; - - @AttributeDefinition( - name = "patterns for Template Mode CSS", - description = "the template patterns (regular expressions) which should be handled by Template Mode CSS (e.g. *.css - NOTE: extension needs to be enabled for this script engine)" - ) - String[] cssPatterns() default { - "*.css" - }; - - @AttributeDefinition( - name = "patterns for Template Mode RAW", - description = "the template patterns (regular expressions) which should be handled by Template Mode RAW (e.g. *.raw - NOTE: extension needs to be enabled for this script engine)" - ) - String[] rawPatterns(); - -} diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProvider.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProvider.java similarity index 85% rename from src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProvider.java rename to src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProvider.java index 568bad5..07c3c58 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternSpecTemplateModeProvider.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProvider.java @@ -38,14 +38,14 @@ import org.thymeleaf.util.PatternSpec; @Component( immediate = true, property = { - Constants.SERVICE_DESCRIPTION + "=PatternSpec TemplateMode Provider for Sling Scripting Thymeleaf", + Constants.SERVICE_DESCRIPTION + "=Pattern TemplateMode Provider for Sling Scripting Thymeleaf", Constants.SERVICE_VENDOR + "=The Apache Software Foundation" } ) @Designate( - ocd = PatternSpecTemplateModeProviderConfiguration.class + ocd = PatternTemplateModeProviderConfiguration.class ) -public class PatternSpecTemplateModeProvider implements TemplateModeProvider { +public class PatternTemplateModeProvider implements TemplateModeProvider { private final PatternSpec htmlPatternSpec = new PatternSpec(); @@ -59,29 +59,29 @@ public class PatternSpecTemplateModeProvider implements TemplateModeProvider { private final PatternSpec rawPatternSpec = new PatternSpec(); - private final Logger logger = LoggerFactory.getLogger(PatternSpecTemplateModeProvider.class); + private final Logger logger = LoggerFactory.getLogger(PatternTemplateModeProvider.class); - public PatternSpecTemplateModeProvider() { + public PatternTemplateModeProvider() { } @Activate - private void activate(final PatternSpecTemplateModeProviderConfiguration configuration) { - logger.debug("activate"); + private void activate(final PatternTemplateModeProviderConfiguration configuration) { + logger.debug("activating"); configure(configuration); } @Modified - private void modified(final PatternSpecTemplateModeProviderConfiguration configuration) { - logger.debug("modified"); + private void modified(final PatternTemplateModeProviderConfiguration configuration) { + logger.debug("modifying"); configure(configuration); } @Deactivate private void deactivate() { - logger.debug("deactivate"); + logger.debug("deactivating"); } - private void configure(final PatternSpecTemplateModeProviderConfiguration configuration) { + private void configure(final PatternTemplateModeProviderConfiguration configuration) { // HTML setPatterns(configuration.htmlPatterns(), htmlPatternSpec); logger.debug("configured HTML patterns: {}", htmlPatternSpec.getPatterns()); diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProviderConfiguration.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProviderConfiguration.java new file mode 100644 index 0000000..7098d48 --- /dev/null +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/PatternTemplateModeProviderConfiguration.java @@ -0,0 +1,76 @@ +/* + * 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.sling.scripting.thymeleaf.internal; + +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; + +@ObjectClassDefinition( + name = "Apache Sling Scripting Thymeleaf “Pattern TemplateMode Provider”", + description = "pattern template mode provider for Sling Scripting Thymeleaf" +) +@interface PatternTemplateModeProviderConfiguration { + + @AttributeDefinition( + name = "patterns for template mode HTML", + description = "The template patterns (regular expressions) for templates which should be processed with template mode HTML (e.g. *.html - NOTE: extension needs to be enabled for this script engine)." + ) + String[] htmlPatterns() default { + "*.html" + }; + + @AttributeDefinition( + name = "patterns for template mode XML", + description = "The template patterns (regular expressions) for templates which should be processed with template mode XML (e.g. *.xml - NOTE: extension needs to be enabled for this script engine)." + ) + String[] xmlPatterns() default { + "*.xml" + }; + + @AttributeDefinition( + name = "patterns for template mode TEXT", + description = "The template patterns (regular expressions) for templates which should be processed with template mode TEXT (e.g. *.txt - NOTE: extension needs to be enabled for this script engine)." + ) + String[] textPatterns() default { + "*.txt" + }; + + @AttributeDefinition( + name = "patterns for template mode JAVASCRIPT", + description = "The template patterns (regular expressions) for templates which should be processed with template mode JAVASCRIPT (e.g. *.js - NOTE: extension needs to be enabled for this script engine)." + ) + String[] javascriptPatterns() default { + "*.js" + }; + + @AttributeDefinition( + name = "patterns for template mode CSS", + description = "The template patterns (regular expressions) for templates which should be processed with template mode CSS (e.g. *.css - NOTE: extension needs to be enabled for this script engine)." + ) + String[] cssPatterns() default { + "*.css" + }; + + @AttributeDefinition( + name = "patterns for template mode RAW", + description = "The template patterns (regular expressions) for templates which should be processed with template mode RAW (e.g. *.raw - NOTE: extension needs to be enabled for this script engine)." + ) + String[] rawPatterns(); + +} diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolver.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolver.java index 14b5171..65298bf 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolver.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolver.java @@ -99,19 +99,19 @@ public class ResourceBundleMessageResolver implements IMessageResolver { @Activate private void activate(final ResourceBundleMessageResolverConfiguration configuration) { - logger.debug("activate"); + logger.debug("activating"); configure(configuration); } @Modified private void modified(final ResourceBundleMessageResolverConfiguration configuration) { - logger.debug("modified"); + logger.debug("modifying"); configure(configuration); } @Deactivate private void deactivate() { - logger.debug("deactivate"); + logger.debug("deactivating"); } private void configure(final ResourceBundleMessageResolverConfiguration configuration) { diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolverConfiguration.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolverConfiguration.java index fac3d1c..bc7f54b 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolverConfiguration.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ResourceBundleMessageResolverConfiguration.java @@ -35,13 +35,13 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; @AttributeDefinition( name = "order", - description = "property for ordering message resolvers inside the Thymeleaf template engine" + description = "Property for ordering message resolvers inside the Thymeleaf template engine." ) int order() default 0; @AttributeDefinition( name = "absent message representation type", - description = "if no AbsentMessageRepresentationProvider is present, empty (''), blank (' ') or the message key can represent an absent message" + description = "If no AbsentMessageRepresentationProvider is present, empty (''), blank (' ') or the message key can represent an absent message." ) AbsentMessageRepresentationType absentMessageRepresentationType() default AbsentMessageRepresentationType.KEY; diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolver.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolver.java index e28d42f..fe1a6e0 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolver.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolver.java @@ -83,19 +83,19 @@ public class SlingResourceTemplateResolver implements ITemplateResolver { @Activate private void activate(final SlingResourceTemplateResolverConfiguration configuration) { - logger.debug("activate"); + logger.debug("activating"); this.configuration = configuration; } @Modified private void modified(final SlingResourceTemplateResolverConfiguration configuration) { - logger.debug("modified"); + logger.debug("modifying"); this.configuration = configuration; } @Deactivate private void deactivate() { - logger.debug("deactivate"); + logger.debug("deactivating"); } @Override diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolverConfiguration.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolverConfiguration.java index a50e41e..6168d3a 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolverConfiguration.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/SlingResourceTemplateResolverConfiguration.java @@ -22,20 +22,20 @@ import org.osgi.service.metatype.annotations.AttributeDefinition; import org.osgi.service.metatype.annotations.ObjectClassDefinition; @ObjectClassDefinition( - name = "Apache Sling Scripting Thymeleaf “Sling resource Template Resolver”", + name = "Apache Sling Scripting Thymeleaf “Sling Resource TemplateResolver”", description = "Sling resource template resolver for Sling Scripting Thymeleaf" ) @interface SlingResourceTemplateResolverConfiguration { @AttributeDefinition( name = "order", - description = "property for ordering template resolvers inside the Thymeleaf template engine" + description = "Property for ordering template resolvers inside the Thymeleaf template engine." ) int order() default 0; @AttributeDefinition( name = "use decoupled logic", - description = "" // TODO + description = "Setting for 'use decoupled logic' in template resolution." ) boolean useDecoupledLogic() default true; diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactory.java index 3ac5358..03c2634 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactory.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactory.java @@ -138,6 +138,8 @@ public final class ThymeleafScriptEngineFactory extends AbstractScriptEngineFact private final Object lock = new Object(); + private final String THYMELEAF_PROPERTIES = "/org/thymeleaf/thymeleaf.properties"; + private final Logger logger = LoggerFactory.getLogger(ThymeleafScriptEngineFactory.class); public ThymeleafScriptEngineFactory() { @@ -271,7 +273,7 @@ public final class ThymeleafScriptEngineFactory extends AbstractScriptEngineFact @Activate private void activate(final ThymeleafScriptEngineFactoryConfiguration configuration, final BundleContext bundleContext) { - logger.debug("activate"); + logger.debug("activating"); this.configuration = configuration; this.bundleContext = bundleContext; configure(configuration); @@ -281,14 +283,14 @@ public final class ThymeleafScriptEngineFactory extends AbstractScriptEngineFact @Modified private void modified(final ThymeleafScriptEngineFactoryConfiguration configuration) { - logger.debug("modified"); + logger.debug("modifying"); this.configuration = configuration; configure(configuration); } @Deactivate private void deactivate() { - logger.debug("deactivate"); + logger.debug("deactivating"); unregisterTemplateEngine(); templateEngine = null; bundleContext = null; @@ -309,17 +311,17 @@ public final class ThymeleafScriptEngineFactory extends AbstractScriptEngineFact public String getLanguageVersion() { try { final Properties properties = new Properties(); - properties.load(getClass().getResourceAsStream("/org/thymeleaf/thymeleaf.properties")); + properties.load(getClass().getResourceAsStream(THYMELEAF_PROPERTIES)); return properties.getProperty("version"); } catch (Exception e) { - logger.error("error reading version from thymeleaf.properties", e); + logger.error("error reading version from " + THYMELEAF_PROPERTIES, e); return ""; // null breaks output of web console } } @Override public ScriptEngine getScriptEngine() { - logger.debug("get script engine for Thymeleaf"); + logger.debug("getting script engine for Thymeleaf"); return new ThymeleafScriptEngine(this); } @@ -388,7 +390,7 @@ public final class ThymeleafScriptEngineFactory extends AbstractScriptEngineFact } final Dictionary<String, String> properties = new Hashtable<>(); properties.put(Constants.SERVICE_DESCRIPTION, "Thymeleaf TemplateEngine"); - properties.put(Constants.SERVICE_VENDOR, "Thymeleaf"); + properties.put(Constants.SERVICE_VENDOR, "The Thymeleaf Team"); logger.info("registering {} as service {} with properties {}", templateEngine, ITemplateEngine.class.getName(), properties); serviceRegistration = bundleContext.registerService(ITemplateEngine.class, templateEngine, properties); } diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactoryConfiguration.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactoryConfiguration.java index 783afff..47f1960 100644 --- a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactoryConfiguration.java +++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafScriptEngineFactoryConfiguration.java @@ -29,13 +29,13 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; @AttributeDefinition( name = "service ranking", - description = "service property for identifying the service's ranking number" + description = "Service property for identifying the service's ranking number." ) int service_ranking() default 0; @AttributeDefinition( name = "extensions", - description = "extensions" + description = "The extensions this script engine is registered for." ) String[] extensions() default { "html" @@ -43,7 +43,7 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; @AttributeDefinition( name = "mime types", - description = "mime types" + description = "The MIME (content) types this script engine is registered for." ) String[] mimeTypes() default { "text/html" @@ -51,45 +51,46 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; @AttributeDefinition( name = "names", - description = "names" + description = "The names under which this script engine is registered." ) String[] names() default { + "Thymeleaf", "thymeleaf" }; @AttributeDefinition( name = "use standard message resolver", - description = "" // TODO + description = "Enables Thymeleaf's standard message resolver and uses it also." ) boolean useStandardMessageResolver() default true; @AttributeDefinition( name = "use standard link builder", - description = "" // TODO + description = "Enables Thymeleaf's standard link builder and uses it also." ) boolean useStandardLinkBuilder() default true; @AttributeDefinition( name = "use standard dialect", - description = "" // TODO + description = "Enables Thymeleaf's standard dialect and uses it also." ) boolean useStandardDialect() default true; @AttributeDefinition( name = "use standard decoupled template logic resolver", - description = "" // TODO + description = "Enables Thymeleaf's standard decoupled template logic resolver and uses it exclusively." ) boolean useStandardDecoupledTemplateLogicResolver() default true; @AttributeDefinition( name = "use standard cache manager", - description = "" // TODO + description = "Enables Thymeleaf's standard cache manager and uses it exclusively." ) boolean useStandardCacheManager() default true; @AttributeDefinition( name = "use standard engine context factory", - description = "" // TODO + description = "Enables Thymeleaf's standard engine context factory and uses it exclusively." ) boolean useStandardEngineContextFactory() default true; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
