Changeset 6629


Ignore:
Timestamp:
Nov 27, 2014, 8:41:11 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1893: Starting and stopping BASE in Tomcat is not implemented correctly

Also nullify several static propertis in Application class.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/web.xml

    r6497 r6629  
    6060 
    6161  <!--
    62     BASE startup and shutdown servlet;
    63     should be configured to load on startup as the first servlet
     62    Listener implementation that start and stop BASE
     63    when the Tomcat is starting/stopping.
    6464  -->
    65   <servlet>
     65  <listener>
    6666    <description>Starts and stops BASE when Tomcat is starting and stopping</description>
    6767    <display-name>BASE Start/Stop servlet</display-name>
    68     <servlet-name>BASE</servlet-name>
    69     <servlet-class>net.sf.basedb.clients.web.servlet.StartStopServlet</servlet-class>
    70     <load-on-startup>1</load-on-startup>
    71   </servlet>
     68    <listener-class>net.sf.basedb.clients.web.servlet.StartStopServlet</listener-class>
     69  </listener>
    7270 
    7371  <!-- The View servlet used to download files in view mode -->
     
    218216  <servlet>
    219217    <description>
    220       Starts up the extensions system in the web client and handles request for
    221       servlets inside extensions.
     218      Handles request for servlets inside extensions.
    222219    </description>
    223220    <display-name>Web client extensions manager</display-name>
    224221    <servlet-name>ExtensionsServlet</servlet-name>
    225222    <servlet-class>net.sf.basedb.clients.web.servlet.ExtensionsServlet</servlet-class>
    226     <load-on-startup>2</load-on-startup>
    227223  </servlet>
    228224  <servlet-mapping>
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/ExtensionsServlet.java

    r5606 r6629  
    2525import java.util.regex.Pattern;
    2626
    27 import javax.servlet.ServletConfig;
    28 import javax.servlet.ServletContext;
    2927import javax.servlet.ServletException;
    3028import javax.servlet.http.HttpServlet;
     
    4038
    4139/**
    42   Servlet for starting the extension system when the web server starts.
    43   The servlet should be configured with the
    44   <code>&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;</code>
    45   option in the web.xml file. When the servlet is loaded it will initialise the
    46   {@link ExtensionsControl} class.
    47   <p>
    48  
    49   This servlet is also acting as a proxy for requests to extension defined
     40  This servlet is acting as a proxy for requests to extension defined
    5041  servlets. Such servlets are defined in <code>META-INF/servlets.xml</code>
    5142  in the extension JAR file. A request to a servlet must have the following
     
    6556  public ExtensionsServlet()
    6657  {}
    67  
    68   @Override
    69   public void init()
    70     throws ServletException
    71   {
    72     super.init();
    73     ServletConfig cfg = getServletConfig();
    74     ServletContext context = cfg.getServletContext();
    75     ExtensionsControl.init(context);
    76   }
    77 
    78   @Override
    79   public void destroy()
    80   {
    81     ExtensionsControl.close();
    82     super.destroy();
    83   }
    8458 
    8559  /**
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/StartStopServlet.java

    r4512 r6629  
    2121package net.sf.basedb.clients.web.servlet;
    2222
    23 import javax.servlet.ServletException;
    24 import javax.servlet.http.HttpServlet;
     23import javax.servlet.ServletContextEvent;
     24import javax.servlet.ServletContextListener;
     25
     26import net.sf.basedb.clients.web.extensions.ExtensionsControl;
    2527import net.sf.basedb.core.Application;
    2628
    2729/**
    28   Servlet for starting BASE when the web server is started and
     30  Servlet listener for starting BASE when the web server is started and
    2931  stopping BASE when the web server is stopped. This servlet is very simple.
    30   It will call {@link Application#start()} when it is loaded and
    31   {@link Application#stop()} when it is destroyed.
    32   <p>
    33  
    34   This servlet should be configured to load before any other servlet that
    35   use BASE classes.
     32  It will call {@link Application#start()} and {@link ExtensionsControl#init(javax.servlet.ServletContext)}
     33  when it is loaded and {@link Application#stop()} and {@link ExtensionsControl#close()}
     34  when it is destroyed.
     35
    3636 
    3737  @author nicklas
     
    4040*/
    4141public class StartStopServlet
    42   extends HttpServlet
     42  implements ServletContextListener
    4343{
    4444 
     
    4848  {}
    4949 
    50   /**
    51     Calls {@link Application#start()}.
    52   */
    5350  @Override
    54   public void init()
    55     throws ServletException
     51  public void contextInitialized(ServletContextEvent ctx)
    5652  {
    57     super.init();
    5853    Application.start();
     54    ExtensionsControl.init(ctx.getServletContext());
     55  }
     56 
     57  @Override
     58  public void contextDestroyed(ServletContextEvent ctx)
     59  {
     60    ExtensionsControl.close();
     61    Application.stop();   
    5962  }
    6063
    61   /**
    62     Calls {@link Application#stop()}.
    63   */
    64   @Override
    65   public void destroy()
    66   {
    67     Application.stop();
    68     super.destroy();
    69   }
    7064
    7165}
  • trunk/src/core/net/sf/basedb/core/Application.java

    r6520 r6629  
    672672    if (timer != null) timer.cancel();
    673673    if (internalJobQueue != null) internalJobQueue.close();
     674    internalJobQueue = null;
    674675    timer = null;
    675676    scheduler = null;
    676677    cleanSessionControlCache(true);
    677678    sessionCache = null;
    678    
    679679    Keyring.unload();
    680680    SystemItems.unload();
     
    690690    ExtendedProperties.unload();
    691691    Config.unload();
     692
     693    xtManager = null;
     694    secondaryStorageDriver = null;
     695    userFilesDirectory = null;
     696    pluginsDirectory = null;
     697    extendedPropertiesFile = null;
     698    rawDataTypesFile = null;
     699    dynamicCatalog = null;
     700    dynamicSchema = null;
     701    hostName = null;
     702    databaseVersionNumber = null;
     703   
    692704    schemaVersion = -2;
    693705    log.info("BASE has been stopped");
Note: See TracChangeset for help on using the changeset viewer.