This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch http-4.x
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/http-4.x by this push:
new b6b69ee8d8 FELIX-6683 : Reduce requests to service registry
b6b69ee8d8 is described below
commit b6b69ee8d8b2f55e54e674496f557e475f321c59
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Sat Jan 20 15:53:24 2024 +0100
FELIX-6683 : Reduce requests to service registry
---
.../internal/whiteboard/WhiteboardManager.java | 72 ++++++++++------------
http/bridge/pom.xml | 2 +-
http/jetty/pom.xml | 2 +-
3 files changed, 34 insertions(+), 42 deletions(-)
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
index 5dcab3dc0c..cad571882a 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
@@ -511,51 +511,43 @@ public final class WhiteboardManager
/**
* Find the list of matching contexts for the whiteboard service
*/
- private List<WhiteboardContextHandler> getMatchingContexts(final
WhiteboardServiceInfo<?> info)
- {
+ private List<WhiteboardContextHandler> getMatchingContexts(final
WhiteboardServiceInfo<?> info) {
final List<WhiteboardContextHandler> result = new ArrayList<>();
- for(final List<WhiteboardContextHandler> handlerList :
this.contextMap.values())
- {
+ for(final List<WhiteboardContextHandler> handlerList :
this.contextMap.values()) {
final WhiteboardContextHandler h = handlerList.get(0);
- // check whether the servlet context helper is visible to the
whiteboard bundle
- // see chapter 140.2
- boolean visible = h.getContextInfo().getServiceId() < 0; //
internal ones are always visible
- if ( !visible )
- {
- final String filterString = "(" + Constants.SERVICE_ID + "=" +
String.valueOf(h.getContextInfo().getServiceId()) + ")";
- try
- {
- final Collection<ServiceReference<ServletContextHelper>>
col =
info.getServiceReference().getBundle().getBundleContext().getServiceReferences(ServletContextHelper.class,
filterString);
- if ( !col.isEmpty() )
- {
- visible = true;
- }
- }
- catch ( final InvalidSyntaxException ise )
- {
- // we ignore this and treat it as an invisible service
- }
+
+ // check if the context matches
+ boolean matches = false;
+
+ if ( h.getContextInfo().getServiceReference() != null ) {
+ matches =
info.getContextSelectionFilter().match(h.getContextInfo().getServiceReference());
+ } else {
+ final Map<String, String> props = new HashMap<>();
+
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME,
h.getContextInfo().getName());
+
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH,
h.getContextInfo().getPath());
+
props.put(HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY,
h.getContextInfo().getName());
+
+ matches = info.getContextSelectionFilter().matches(props);
}
- if ( visible )
- {
- if ( h.getContextInfo().getServiceReference() != null )
- {
- if (
info.getContextSelectionFilter().match(h.getContextInfo().getServiceReference())
)
- {
- result.add(h);
- }
- }
- else
- {
- final Map<String, String> props = new HashMap<>();
-
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME,
h.getContextInfo().getName());
-
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH,
h.getContextInfo().getPath());
-
props.put(HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY,
h.getContextInfo().getName());
- if ( info.getContextSelectionFilter().matches(props) )
- {
- result.add(h);
+ if (matches) {
+ // check whether the servlet context helper is visible to the
whiteboard bundle
+ // see chapter 140.2
+ boolean visible = h.getContextInfo().getServiceId() < 0; //
internal ones are always visible
+ if ( !visible ) {
+ final String filterString = "(" + Constants.SERVICE_ID +
"=" + String.valueOf(h.getContextInfo().getServiceId()) + ")";
+ try {
+ final
Collection<ServiceReference<ServletContextHelper>> col =
info.getServiceReference().getBundle().getBundleContext().getServiceReferences(ServletContextHelper.class,
filterString);
+ if ( !col.isEmpty() ) {
+ visible = true;
+ }
}
+ catch ( final InvalidSyntaxException ise ) {
+ // we ignore this and treat it as an invisible service
+ }
+ }
+ if ( visible ) {
+ result.add(h);
}
}
}
diff --git a/http/bridge/pom.xml b/http/bridge/pom.xml
index cfc5d28afb..8b38a533e3 100644
--- a/http/bridge/pom.xml
+++ b/http/bridge/pom.xml
@@ -145,7 +145,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>4.2.12</version>
+ <version>4.2.13-SNAPSHOT</version>
</dependency>
</dependencies>
diff --git a/http/jetty/pom.xml b/http/jetty/pom.xml
index bbe9e7769d..b70f58812a 100644
--- a/http/jetty/pom.xml
+++ b/http/jetty/pom.xml
@@ -401,7 +401,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>4.2.12</version>
+ <version>4.2.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>