kwin commented on a change in pull request #15: SLING-8754 when possible use 
ServiceCache
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/15#discussion_r330159496
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
 ##########
 @@ -79,9 +82,24 @@ public Object getValue(@NotNull Object adaptable, String 
name, @NotNull Type typ
                 filterString = filter.value();
             }
         }
+        if (adaptable instanceof SlingHttpServletRequest && 
StringUtils.isBlank(filterString)) {
+            SlingHttpServletRequest request = (SlingHttpServletRequest) 
adaptable;
+            Object service = getValueFromServiceCache(request, 
type.getClass());
+            if (service != null) {
+                return service;
+            }
+        }
         return getValue(adaptable, type, filterString, callbackRegistry);
     }
 
+    private <T> Object getValueFromServiceCache(final SlingHttpServletRequest 
request, Class<T> type) {
 
 Review comment:
   SlingBindings is not really a service cache, therefore I would rather call 
this method getServiceFromBindings()

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to