View Javadoc

1   /*
2    * $Id: ReloadControl.java 22088 2011-06-03 10:07:47Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.config.i18n;
12  
13  import java.util.Locale;
14  import java.util.ResourceBundle;
15  
16  public class ReloadControl
17  {
18  
19      // since java 6 only
20      static class Always extends ResourceBundle.Control
21      {
22          boolean needsReload = true;
23  
24          @Override
25          public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
26          {
27              // don't cache, always reload
28              return true;
29          }
30  
31          @Override
32          public long getTimeToLive(String baseName, Locale locale)
33          {
34              if (needsReload)
35              {
36                  // must be zero, as other 'DONT_CACHE' constant doesn't work here, and is -1
37                  return 0;
38              }
39  
40              return ResourceBundle.Control.TTL_NO_EXPIRATION_CONTROL;
41          }
42      }
43  }