mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1084371 - in /mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp: modules/DefaultModule.java modules/Module.java server/XMPPServer.java
Date Tue, 22 Mar 2011 21:53:34 GMT
Author: ngn
Date: Tue Mar 22 21:53:34 2011
New Revision: 1084371

URL: http://svn.apache.org/viewvc?rev=1084371&view=rev
Log:
Add close method to modules to allow for releasing resources (VYSPER-277)

Modified:
    mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/DefaultModule.java
    mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/Module.java
    mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/DefaultModule.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/DefaultModule.java?rev=1084371&r1=1084370&r2=1084371&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/DefaultModule.java
(original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/DefaultModule.java
Tue Mar 22 21:53:34 2011
@@ -59,4 +59,8 @@ public abstract class DefaultModule impl
     public void initialize(ServerRuntimeContext serverRuntimeContext) {
         // empty default implementation
     }
+
+    public void close() {
+        // empty default implementation
+    }
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/Module.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/Module.java?rev=1084371&r1=1084370&r2=1084371&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/Module.java
(original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/Module.java
Tue Mar 22 21:53:34 2011
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.vysper.xmpp.protocol.HandlerDictionary;
 import org.apache.vysper.xmpp.server.ServerRuntimeContext;
+import org.apache.vysper.xmpp.server.XMPPServer;
 
 /**
  * a module plugs new functionality into the server, most probably an implementation for
a XEP.
@@ -69,4 +70,10 @@ public interface Module {
      * first one.
      */
     void initialize(ServerRuntimeContext serverRuntimeContext);
+    
+    /**
+     * Allow for the module to release any resources held, for example database connections.
The method
+     * will be called by {@link XMPPServer#stop()}.
+     */
+    void close();
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java?rev=1084371&r1=1084370&r2=1084371&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
(original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
Tue Mar 22 21:53:34 2011
@@ -157,6 +157,14 @@ public class XMPPServer {
             endpoint.stop();
         }
         
+        for(Module module : serverRuntimeContext.getModules()) {
+            try {
+                module.close();
+            } catch(RuntimeException e) {
+                // ignore
+            }
+        }
+        
         serverRuntimeContext.getServerConnectorRegistry().close();
     }
 



Mime
View raw message