cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1156220 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
Date Wed, 10 Aug 2011 15:17:05 GMT
Author: dkulp
Date: Wed Aug 10 15:17:05 2011
New Revision: 1156220

URL: http://svn.apache.org/viewvc?rev=1156220&view=rev
Log:
[CXF-3728] Detect lifecycle listeners automatically

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java?rev=1156220&r1=1156219&r2=1156220&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
Wed Aug 10 15:17:05 2011
@@ -19,41 +19,50 @@
 
 package org.apache.cxf.endpoint;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.extension.BusExtension;
 
 @NoJSR250Annotations
 public class ClientLifeCycleManagerImpl implements ClientLifeCycleManager, BusExtension {
     
-    private List<ClientLifeCycleListener> listeners = new ArrayList<ClientLifeCycleListener>();

+    private CopyOnWriteArrayList<ClientLifeCycleListener> listeners 
+        = new CopyOnWriteArrayList<ClientLifeCycleListener>(); 
 
+    public ClientLifeCycleManagerImpl() {
+        
+    }
+    
+    public ClientLifeCycleManagerImpl(Bus b) {
+        Collection<? extends ClientLifeCycleListener> l = b.getExtension(ConfiguredBeanLocator.class)
+                .getBeansOfType(ClientLifeCycleListener.class);
+        if (l != null) {
+            listeners.addAll(l);
+        }
+    }
+    
     public Class<?> getRegistrationType() {
         return ClientLifeCycleManager.class;
     }
 
     public void registerListener(ClientLifeCycleListener listener) {
-        if (!listeners.contains(listener)) {
-            listeners.add(listener);
-        }
+        listeners.addIfAbsent(listener);
     }
 
     public void clientCreated(Client client) {
-        if (null != listeners) {
-            for (ClientLifeCycleListener listener : listeners) {
-                listener.clientCreated(client);
-            }
+        for (ClientLifeCycleListener listener : listeners) {
+            listener.clientCreated(client);
         }
     }
 
     public void clientDestroyed(Client client) {
-        if (null != listeners) {
-            for (ClientLifeCycleListener listener : listeners) {
-                listener.clientDestroyed(client);
-            }
-        } 
+        for (ClientLifeCycleListener listener : listeners) {
+            listener.clientDestroyed(client);
+        }
     }
 
     public void unRegisterListener(ClientLifeCycleListener listener) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java?rev=1156220&r1=1156219&r2=1156220&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
Wed Aug 10 15:17:05 2011
@@ -19,25 +19,38 @@
 
 package org.apache.cxf.endpoint;
 
-import java.util.List;
+import java.util.Collection;
 
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.extension.BusExtension;
 
 @NoJSR250Annotations
 public class ServerLifeCycleManagerImpl implements ServerLifeCycleManager, BusExtension {
     
-    private List<ServerLifeCycleListener> listeners = 
+    private CopyOnWriteArrayList<ServerLifeCycleListener> listeners = 
             new CopyOnWriteArrayList<ServerLifeCycleListener>();
 
+    public ServerLifeCycleManagerImpl() {
+        
+    }
+    public ServerLifeCycleManagerImpl(Bus b) {
+        Collection<? extends ServerLifeCycleListener> l = b.getExtension(ConfiguredBeanLocator.class)
+                .getBeansOfType(ServerLifeCycleListener.class);
+        if (l != null) {
+            listeners.addAll(l);
+        }
+    }
     public Class<?> getRegistrationType() {
         return ServerLifeCycleManager.class;
     }
 
+    
     public synchronized void registerListener(ServerLifeCycleListener listener) {
-        listeners.add(listener);
+        listeners.addIfAbsent(listener);
     }
 
     public void startServer(Server server) {

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?rev=1156220&r1=1156219&r2=1156220&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Wed Aug 10 15:17:05
2011
@@ -75,7 +75,7 @@ import org.apache.cxf.ws.rmp.v200502.RMA
 /**
  * 
  */
-public class RMManager implements ServerLifeCycleListener, ClientLifeCycleListener {
+public class RMManager {
     
     /**
      * Message contextual property giving WS-ReliableMessaging namespace.
@@ -628,11 +628,25 @@ public class RMManager implements Server
         }
         ServerLifeCycleManager slm = bus.getExtension(ServerLifeCycleManager.class);
         if (null != slm) {
-            slm.registerListener(this);
+            slm.registerListener(new ServerLifeCycleListener() {
+                public void startServer(Server server) {
+                    RMManager.this.startServer(server);
+                }
+                public void stopServer(Server server) {
+                    RMManager.this.stopServer(server);
+                }
+            });
         }
         ClientLifeCycleManager clm = bus.getExtension(ClientLifeCycleManager.class);
         if (null != clm) {
-            clm.registerListener(this);
+            clm.registerListener(new ClientLifeCycleListener() {
+                public void clientCreated(Client client) {
+                    RMManager.this.clientCreated(client);
+                }
+                public void clientDestroyed(Client client) {
+                    RMManager.this.clientDestroyed(client);
+                }
+            });
         }
     }
 



Mime
View raw message