Author: bdube Date: Sun May 1 19:13:39 2011 New Revision: 1098390 URL: http://svn.apache.org/viewvc?rev=1098390&view=rev Log: Clean up and unregister main servlet
Modified: forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServlet.java forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServletPlugin.java Modified: forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServlet.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServlet.java?rev=1098390&r1=1098389&r2=1098390&view=diff ============================================================================== --- forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServlet.java (original) +++ forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServlet.java Sun May 1 19:13:39 2011 @@ -282,4 +282,11 @@ public class ForrestServlet extends Http return path + (path.endsWith("/") ? "" : "/") + index; } + @Override + public void destroy() { + mInputPluginTracker.close(); + mOutputPluginTracker.close(); + mBundleContext = null; + } + } Modified: forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServletPlugin.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServletPlugin.java?rev=1098390&r1=1098389&r2=1098390&view=diff ============================================================================== --- forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServletPlugin.java (original) +++ forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.servlet/src/java/org/apache/forrest/http/ForrestServletPlugin.java Sun May 1 19:13:39 2011 @@ -30,6 +30,8 @@ import org.apache.forrest.log.LogPlugin. public class ForrestServletPlugin implements BundleActivator { + private static final String SERVLET_ALIAS = "/"; + private ServiceTracker mHttpTracker; private ForrestServlet mServlet; @@ -57,7 +59,7 @@ public class ForrestServletPlugin implem if (null != service) { try { - service.registerServlet("/", mServlet, null, null); + service.registerServlet(SERVLET_ALIAS, mServlet, null, null); } catch (ServletException e) { e.printStackTrace(); } catch (NamespaceException e) { @@ -72,6 +74,19 @@ public class ForrestServletPlugin implem // @Override public void stop(BundleContext context) throws Exception { LOG.debug("Servlet plugin stopping"); + + /* + * Clean up our servlet registration + * Without this, the framework would still unregister for us + * but this is the only way to have destroy() called on our + * servlet + */ + HttpService service = (HttpService) mHttpTracker.getService(); + + if (null != service) { + service.unregister(SERVLET_ALIAS); + } + mHttpTracker.close(); }