cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1212596 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
Date Fri, 09 Dec 2011 19:43:32 GMT
Author: dkulp
Date: Fri Dec  9 19:43:32 2011
New Revision: 1212596

URL: http://svn.apache.org/viewvc?rev=1212596&view=rev
Log:
[CXF-3901] Allow osgi services to opt-out of the global pickup

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

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java?rev=1212596&r1=1212595&r2=1212596&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java Fri
Dec  9 19:43:32 2011
@@ -218,9 +218,11 @@ public class OSGiExtensionLocator implem
                     .getServiceReferences(BusLifeCycleListener.class.getName(), null);
                 if (refs != null) {
                     for (ServiceReference ref : refs) {
-                        BusLifeCycleListener listener 
-                            = (BusLifeCycleListener)defaultContext.getService(ref);
-                        manager.registerLifeCycleListener(listener);
+                        if (allowService(ref)) {
+                            BusLifeCycleListener listener 
+                                = (BusLifeCycleListener)defaultContext.getService(ref);
+                            manager.registerLifeCycleListener(listener);
+                        }
                     }
                 }
             } catch (InvalidSyntaxException e) {
@@ -232,9 +234,11 @@ public class OSGiExtensionLocator implem
                 if (refs != null) {
                     ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
                     for (ServiceReference ref : refs) {
-                        ClientLifeCycleListener listener 
-                            = (ClientLifeCycleListener)defaultContext.getService(ref);
-                        clcm.registerListener(listener);
+                        if (allowService(ref)) {
+                            ClientLifeCycleListener listener 
+                                = (ClientLifeCycleListener)defaultContext.getService(ref);
+                            clcm.registerListener(listener);
+                        }
                     }
                 }
             } catch (InvalidSyntaxException e) {
@@ -246,15 +250,30 @@ public class OSGiExtensionLocator implem
                 if (refs != null) {
                     ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
                     for (ServiceReference ref : refs) {
-                        ServerLifeCycleListener listener 
-                            = (ServerLifeCycleListener)defaultContext.getService(ref);
-                        clcm.registerListener(listener);
+                        if (allowService(ref)) {
+                            ServerLifeCycleListener listener 
+                                = (ServerLifeCycleListener)defaultContext.getService(ref);
+                            clcm.registerListener(listener);
+                        }
                     }
                 }
             } catch (InvalidSyntaxException e) {
                 //ignore
             }
         }
+        
+        private boolean allowService(ServiceReference ref) {
+            Object o = ref.getProperty("org.apache.cxf.bus.private.extension");
+            Boolean pvt = Boolean.FALSE;
+            if (o == null) {
+                pvt = Boolean.FALSE;
+            } else if (o instanceof String) {
+                pvt = Boolean.parseBoolean((String)o);
+            } else if (o instanceof Boolean) {
+                pvt = (Boolean)o;
+            }
+            return !pvt.booleanValue();
+        }
         private Version getBundleVersion(Bundle bundle) {
             Dictionary headers = bundle.getHeaders();
             String version = (String) headers.get(Constants.BUNDLE_VERSION);



Mime
View raw message