You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "kwin (via GitHub)" <gi...@apache.org> on 2023/05/26 16:33:08 UTC
[GitHub] [sling-org-apache-sling-engine] kwin commented on a diff in pull request #35: Explicitly call request listeners on synthetic resources
kwin commented on code in PR #35:
URL: https://github.com/apache/sling-org-apache-sling-engine/pull/35#discussion_r1207046502
##########
src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java:
##########
@@ -308,9 +330,37 @@ public void processRequest(final HttpServletRequest servletRequest,
} else {
servletRequest.removeAttribute(ParameterSupport.MARKER_IS_SERVICE_PROCESSING);
}
+ requestListenersForSyntheticRequest.forEach(l -> l.requestDestroyed(event));
+ requestListenerServiceReferencesForSyntheticRequest.forEach(bundleContext::ungetService);
+ }
+ }
+
+ private Collection<ServiceReference<ServletRequestListener>> getRequestListenersForSyntheticRequest(HttpServletRequest servletRequest) {
+ if (!isSyntheticRequest(servletRequest)) {
+ return Collections.emptyList();
+ } else {
+ return Stream.of(getSlingServletContextDTO().listenerDTOs)
+ .filter(l -> Arrays.stream(l.types).anyMatch(ServletRequestListener.class.getName()::equals))
+ .map(l -> {
+ try {
+ return bundleContext.getServiceReferences(ServletRequestListener.class, "(service.id=" + l.serviceId + ")").iterator().next();
+ } catch (InvalidSyntaxException e) {
+ // should not happen
+ throw new IllegalStateException(e);
+ }
+ })
+ .collect(Collectors.toSet());
}
}
+ private boolean isSyntheticRequest(HttpServletRequest servletRequest) {
+ return servletRequest.getServletContext().getClass().getName().equals(ServletContextImpl.class.getName());
Review Comment:
This needs some tweaking probably
--
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.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org