It is seen that messenger is designed to run inside jetty with a seperate VM. But its not the case for enterprise systems. BootServlet is useless since one cannot undeploy war because it simply doesn’'t shutdown server.
Correct approach is a ServletContextListener as servlet spec says. Here it is:
evrim@evrim ~/workspace/messenger/src/java/org/jivesoftware/messenger $ cat XMPPContextListener.java
package org.jivesoftware.messenger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class XMPPContextListener implements ServletContextListener {
protected String XMPP_KEY = “XMPP_SERVER”;
public void contextInitialized(ServletContextEvent event) {
XMPPServer server = new XMPPServer();
event.getServletContext().setAttribute(XMPP_KEY, server);
}
public void contextDestroyed(ServletContextEvent event) {
XMPPServer server = (XMPPServer) event.getServletContext().getAttribute(XMPP_KEY);
if (null != server) {
server.stop();
}
}
}[/code]
To enable a context listener (as everybody knows), first disable XMPPBootServlet from web.xml:
[/code]
Ok, this listener uses XMPPServer.stop() method to stop the server but it seems it doesn’'t because it works only if its standalone. Here is the patch for stop() method:
diff
@@ -444,6 +444,18 @@
shutdownThread.setDaemon(true);
shutdownThread.start();
}
-
} else {
-
/* If stop() is called, you have to close listening socket
-
* no matter what the condition is in order to be able
-
* to be restartable inside a container.
-
*
-
* Shutdownhook thread obviosuly won''t work in appserver
-
* since VM is not closing.
-
*
-
* /evrim_at_core.gen.tr
-
*/
-
shutdownServer();
-
stopDate = new Date();
}
}[/code]
Unfortunately, I can’‘t put my code into pre tags. Forum is not a correct way to post these patches but i don’'t have any alternative since JIRA is closed to visitors. Shame on you JIVE#2!
Have a nice day.