View Javadoc
1   /*
2    * Copyright 2001-2008 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   */
17  
18  package org.apache.juddi.config;
19  
20  import java.util.ResourceBundle;
21  import java.util.Locale;
22  
23  /**
24   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
25   */
26  public class ResourceConfig {
27  	public static final String GLOBAL_MESSAGES_FILE = "messages";
28  
29  	private static final ResourceBundle globalMessages;
30  
31  	static {
32  		try {
33  			globalMessages = ResourceBundle.getBundle(GLOBAL_MESSAGES_FILE, Locale.getDefault());
34  		}
35  		catch (Throwable t) {
36  			System.err.println("Initial configuration failed:" + t);
37  			throw new ExceptionInInitializerError(t);
38  		}
39  	}
40  
41  	public static String getGlobalMessage(String key) {
42  		String msg = null;
43  		if (globalMessages != null) {
44  			if (key != null && key.length() > 0)
45  				msg = globalMessages.getString(key);
46  		}
47  		if (msg != null && msg.length() > 0)
48  			return msg;
49  		
50  		return key;
51  	}
52  }