title: Release Java web application scoped static resources
body: <p>I have a application scoped static resource that I will initialize it at the time ServletContext initialized.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    public class StaticResource {
          private static Map&lt;Class, MyBean&gt; staticMap = new HashMap&lt;&gt;();
  
          public static void add(Class clazz, MyBean b) { ... }
          public static MyBean get(Class clazz) { ... }
      }
  </code></pre>
  
  <p>StaticResource will be packaged into a MyJar.jar and this jar is put into myWebApp/WEB-INF /lib.  I add this information to let us know StaticResource is ONLY for my application ( Not shared)</p>
  
  <p>The code I initialize like below:</p>
  
  <pre><code>    @WebListener
      public class AppListener implements ServletContextListener {
  
      @Override
      public void contextInitialized(ServletContextEvent sce) {
          StaticResource.put ( Bean1.class, myBean_instance1);
          StaticResource.put ( Bean2.class, myBean_instance2);
              // ...
      }
  
      @Override
      public void contextDestroyed(ServletContextEvent sce) {
          // --- Do I need to set NULL to StaticResource.staticMap?
      }
  </code></pre>
  
  <p>MyBean class is very simple, just contains some properties with types Class, Primitives, Method, ...</p>
  
  <p>MY QUESTION is in contextDestroyed function, do I have to set NULL to StaticResource.staticMap?</p>
  
  <p>As my understanding, staticMap will be destroyed when the StaticResource class unloaded (After the contextDestroyed executed), so setting NULL to staticMap is NOT NEEDED.</p>