cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1212726 - in /cxf/trunk: api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
Date Sat, 10 Dec 2011 03:57:20 GMT
Author: dkulp
Date: Sat Dec 10 03:57:20 2011
New Revision: 1212726

URL: http://svn.apache.org/viewvc?rev=1212726&view=rev
Log:
BusLifeCycleListener is usless as a global service as it doesn't get the
Bus passed in.  Introduce a new interface that can be used to get
noticed when Bus's are created and can then register additional
BusLifeCycleListeners for the finer events.

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java   (with
props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java

Added: cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java?rev=1212726&view=auto
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java (added)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java Sat Dec
10 03:57:20 2011
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.buslifecycle;
+
+import org.apache.cxf.Bus;
+
+/**
+ * The listener interface for receiving notification of when <code>Bus</code>
+ * objects are created.
+ *
+ * It's a simplified form of BusLifeCycleListener that takes the 
+ * target Bus as a parameter which is appropriate if the listener needs 
+ * to be a singleton that works with multiple Bus objects.   
+ * 
+ * A common pattern would be to register a full BusLifeCycleListener on the
+ * target Bus to receive full Bus events
+ */
+public interface BusCreationListener {
+
+    /**
+     * Invoked to create a BusLifeCycleListener.   
+     */
+    void busCreated(Bus b);
+    
+}

Propchange: cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/api/src/main/java/org/apache/cxf/buslifecycle/BusCreationListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java?rev=1212726&r1=1212725&r2=1212726&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java Sat Dec 10 03:57:20
2011
@@ -27,6 +27,7 @@ import java.util.concurrent.CopyOnWriteA
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.buslifecycle.BusCreationListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
@@ -161,6 +162,13 @@ public class CXFBusImpl extends Abstract
 
     public void initialize() {
         setState(BusState.INITIALIZING);
+        
+        Collection<? extends BusCreationListener> ls = getExtension(ConfiguredBeanLocator.class)
+            .getBeansOfType(BusCreationListener.class);
+        for (BusCreationListener l : ls) {
+            l.busCreated(this);
+        }
+        
         doInitializeInternal();
         
         BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);

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=1212726&r1=1212725&r2=1212726&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 Sat
Dec 10 03:57:20 2011
@@ -40,6 +40,7 @@ import org.apache.cxf.bus.extension.Exte
 import org.apache.cxf.bus.extension.ExtensionManagerImpl;
 import org.apache.cxf.bus.extension.ExtensionRegistry;
 import org.apache.cxf.bus.osgi.OSGiAutomaticWorkQueue.WorkQueueList;
+import org.apache.cxf.buslifecycle.BusCreationListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
@@ -215,13 +216,14 @@ public class OSGiExtensionLocator implem
             
             try {
                 ServiceReference refs[] = defaultContext
-                    .getServiceReferences(BusLifeCycleListener.class.getName(), null);
+                    .getServiceReferences(ClientLifeCycleListener.class.getName(), null);
                 if (refs != null) {
+                    ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
                     for (ServiceReference ref : refs) {
                         if (allowService(ref)) {
-                            BusLifeCycleListener listener 
-                                = (BusLifeCycleListener)defaultContext.getService(ref);
-                            manager.registerLifeCycleListener(listener);
+                            ClientLifeCycleListener listener 
+                                = (ClientLifeCycleListener)defaultContext.getService(ref);
+                            clcm.registerListener(listener);
                         }
                     }
                 }
@@ -230,36 +232,37 @@ public class OSGiExtensionLocator implem
             }
             try {
                 ServiceReference refs[] = defaultContext
-                    .getServiceReferences(ClientLifeCycleListener.class.getName(), null);
+                    .getServiceReferences(ServerLifeCycleListener.class.getName(), null);
                 if (refs != null) {
-                    ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
+                    ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
                     for (ServiceReference ref : refs) {
                         if (allowService(ref)) {
-                            ClientLifeCycleListener listener 
-                                = (ClientLifeCycleListener)defaultContext.getService(ref);
+                            ServerLifeCycleListener listener 
+                                = (ServerLifeCycleListener)defaultContext.getService(ref);
                             clcm.registerListener(listener);
                         }
                     }
                 }
+                
             } catch (InvalidSyntaxException e) {
                 //ignore
             }
             try {
                 ServiceReference refs[] = defaultContext
-                    .getServiceReferences(ServerLifeCycleListener.class.getName(), null);
+                    .getServiceReferences(BusCreationListener.class.getName(), null);
                 if (refs != null) {
-                    ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
                     for (ServiceReference ref : refs) {
                         if (allowService(ref)) {
-                            ServerLifeCycleListener listener 
-                                = (ServerLifeCycleListener)defaultContext.getService(ref);
-                            clcm.registerListener(listener);
+                            BusCreationListener listener 
+                                = (BusCreationListener)defaultContext.getService(ref);
+                            listener.busCreated(bus);
                         }
                     }
                 }
             } catch (InvalidSyntaxException e) {
                 //ignore
             }
+
         }
         
         private boolean allowService(ServiceReference ref) {



Mime
View raw message