View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.jetspeed.services.customlocalization;
17  
18  import org.apache.turbine.services.TurbineServices;
19  import java.util.Locale;
20  import java.util.ResourceBundle;
21  import org.apache.turbine.util.RunData;
22  
23  /***
24   * Custom Localization allows for the localization properties to changed dynamically,
25   * without shutting down the application server. 
26   *
27   * @author <a href="mailto:massimiliano.dessi@gruppoatlantis.it">Dessė Massimiliano</a>
28   * @version $Id: CustomLocalization.java,v 1.4 2004/02/23 03:49:33 jford Exp $
29   */
30  public abstract class CustomLocalization 
31  {
32  
33      public CustomLocalization(){}
34  
35      public static String getString(String bundleName, Locale locale, String key)
36      {
37          return getService().getString(bundleName, locale, key);
38      }
39  
40      public static String getString(String key, RunData data)
41      {
42          return getService().getString(null, getLocale(data), key);
43      }
44  
45      public static ResourceBundle getBundle( RunData data )
46      {
47          return getService().getBundle(data);
48      }
49  
50      public static Locale getLocale(RunData data)
51      {
52          return getService().getLocale(data);
53      }
54  
55      public static String getDefaultBundleName()
56      {
57          return getService().getDefaultBundleName();
58      }
59  
60     protected static final CustomLocalizationService getService()
61      {
62          return (CustomLocalizationService) TurbineServices.getInstance().getService(CustomLocalizationService.SERVICE_NAME);
63      }
64  }