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 bb9ba996673a962c7d4dfb7f35ccb2d334693161
Author: Oliver Lietz <[email protected]>
AuthorDate: Tue Apr 19 19:14:31 2016 +0000

    SLING-5663 Make Thymeleaf TemplateEngine available as service
    
    check for at least one TemplateResolver, MessageResolver and Dialect before 
registering to avoid unnecessary un-/registration calls
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/org.apache.sling.scripting.thymeleaf@1739985
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../thymeleaf/internal/ThymeleafScriptEngineFactory.java    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

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 3ef0d09..03f0387 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
@@ -264,13 +264,14 @@ public final class ThymeleafScriptEngineFactory extends 
AbstractScriptEngineFact
     }
 
     private void registerTemplateEngine() {
-        if (bundleContext != null) {
-            final Dictionary<String, String> properties = new Hashtable<>();
-            properties.put(Constants.SERVICE_DESCRIPTION, "Thymeleaf 
TemplateEngine");
-            properties.put(Constants.SERVICE_VENDOR, "Thymeleaf");
-            logger.info("{}, {}, {}", bundleContext, templateEngine, 
properties);
-            serviceRegistration = 
bundleContext.registerService(ITemplateEngine.class, templateEngine, 
properties);
+        if (templateEngine.getTemplateResolvers().size() == 0 || 
templateEngine.getMessageResolvers().size() == 0 || 
templateEngine.getDialects().size() == 0) {
+            return;
         }
+        final Dictionary<String, String> properties = new Hashtable<>();
+        properties.put(Constants.SERVICE_DESCRIPTION, "Thymeleaf 
TemplateEngine");
+        properties.put(Constants.SERVICE_VENDOR, "Thymeleaf");
+        logger.info("registering {} as service {} with properties {}", 
templateEngine, ITemplateEngine.class.getName(), properties);
+        serviceRegistration = 
bundleContext.registerService(ITemplateEngine.class, templateEngine, 
properties);
     }
 
     private void unregisterTemplateEngine() {

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to