Author: sergeyb
Date: Mon Oct 13 06:32:35 2008
New Revision: 704117
URL: http://svn.apache.org/viewvc?rev=704117&view=rev
Log:
Excluding system services when doing look ups
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java?rev=704117&r1=704116&r2=704117&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
Mon Oct 13 06:32:35 2008
@@ -18,6 +18,9 @@
*/
package org.apache.cxf.dosgi.dsw.hooks;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -28,10 +31,19 @@
public class CxfListenerHook extends AbstractClientHook implements
ListenerHook {
+ private static final Logger LOG =
Logger.getLogger(CxfListenerHook.class.getName());
+
+
private final static String CLASS_NAME_EXPRESSION =
".*\\(" + Constants.OBJECTCLASS + "=([a-zA-Z_0-9.]+)\\).*";
private final static Pattern CLASS_NAME_PATTERN =
Pattern.compile(CLASS_NAME_EXPRESSION);
+ private static final Set<String> SYSTEM_PACKAGES;
+
+ static {
+ SYSTEM_PACKAGES = new HashSet<String>();
+ SYSTEM_PACKAGES.add("org.osgi.service");
+ }
private ThreadLocal<Boolean> findCallsInProgress
= new ThreadLocal<Boolean>() {
@@ -75,10 +87,11 @@
return;
}
String className = getClassNameFromFilter(listener.getFilter());
- if (className == null) {
+ if (!isClassSupported(className)) {
return;
}
+
processClientDescriptions(listener.getBundleContext(),
className,
listener.getFilter(),
@@ -103,8 +116,8 @@
String filter,
boolean allServices) {
- if (className == null) {
- return;
+ if (!isClassSupported(className)) {
+ return;
}
if (isCallInProgress()) {
@@ -130,4 +143,20 @@
private void setCallCompleted() {
findCallsInProgress.set(Boolean.FALSE);
}
+
+
+
+ private static boolean isClassSupported(String className) {
+ if (className == null) {
+ return false;
+ }
+
+ for (String p : SYSTEM_PACKAGES) {
+ if (className.startsWith(p)) {
+ LOG.fine("Lookup for " + className + " is ignored");
+ return false;
+ }
+ }
+ return true;
+ }
}