cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1156224 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/
Date Wed, 10 Aug 2011 15:20:27 GMT
Author: dkulp
Date: Wed Aug 10 15:20:26 2011
New Revision: 1156224

URL: http://svn.apache.org/viewvc?rev=1156224&view=rev
Log:
Merged revisions 1156220 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1156220 | dkulp | 2011-08-10 11:17:05 -0400 (Wed, 10 Aug 2011) | 1 line
  
  [CXF-3728] Detect lifecycle listeners automatically
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
    cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java?rev=1156224&r1=1156223&r2=1156224&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientLifeCycleManagerImpl.java
Wed Aug 10 15:20:26 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/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java?rev=1156224&r1=1156223&r2=1156224&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
Wed Aug 10 15:20:26 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/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?rev=1156224&r1=1156223&r2=1156224&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ cxf/branches/2.4.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Wed
Aug 10 15:20:26 2011
@@ -70,7 +70,7 @@ import org.apache.cxf.ws.rm.soap.SoapFau
 /**
  * 
  */
-public class RMManager implements ServerLifeCycleListener, ClientLifeCycleListener {
+public class RMManager {
 
     private static final Logger LOG = LogUtils.getL7dLogger(RMManager.class);
 
@@ -527,11 +527,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