cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1569383 - /cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java
Date Tue, 18 Feb 2014 15:27:10 GMT
Author: sergeyb
Date: Tue Feb 18 15:27:10 2014
New Revision: 1569383

URL: http://svn.apache.org/r1569383
Log:
[CXF-5568] Optionally disabling the selection of bean services

Modified:
    cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java

Modified: cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java?rev=1569383&r1=1569382&r2=1569383&view=diff
==============================================================================
--- cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java (original)
+++ cxf/trunk/core/src/main/java/org/apache/cxf/bus/osgi/OSGiBeanLocator.java Tue Feb 18 15:27:10
2014
@@ -24,18 +24,26 @@ import java.util.List;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
 public class OSGiBeanLocator implements ConfiguredBeanLocator {
     private static final Logger LOG = LogUtils.getL7dLogger(OSGiBeanLocator.class);
+    private static final String COMPATIBLE_LOCATOR_PROP = "org.apache.cxf.bus.osgi.locator";
+    private static final String COMPATIBLE_LOCATOR_PROP_CHECK = COMPATIBLE_LOCATOR_PROP +
".check";
     
     final ConfiguredBeanLocator cbl;
     final BundleContext context;
+    private boolean checkCompatibleLocators; 
+    
     public OSGiBeanLocator(ConfiguredBeanLocator c, BundleContext ctx) {
         cbl = c;
         context = ctx;
+        
+        Object checkProp = context.getProperty(COMPATIBLE_LOCATOR_PROP_CHECK);
+        checkCompatibleLocators = checkProp == null || PropertyUtils.isTrue(checkProp); 

     }
     public <T> T getBeanOfType(String name, Class<T> type) {
         return cbl.getBeanOfType(name, type);
@@ -56,6 +64,10 @@ public class OSGiBeanLocator implements 
             ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
             if (refs != null) {
                 for (ServiceReference r : refs) {
+                    if (checkCompatibleLocators 
+                        && !PropertyUtils.isTrue(r.getProperty(COMPATIBLE_LOCATOR_PROP)))
{
+                        continue;
+                    }
                     list.add(type.cast(context.getService(r)));
                 }
             }



Mime
View raw message