1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
71 try {
72 bundle = ResourceBundle.getBundle(bundlename, _locale);
73 } catch (MissingResourceException e) {
74 // work around a bug in the com.sun.enterprise.deployment.WebBundleArchivist:
75 // all files with an extension different from .class (hence all the .properties files)
76 // get copied to the top level directory instead of being in the package where they
77 // are defined
78 // so, since we can't find the bundle under its proper name, we look for it under
79 // the top-level package
80
81 int i = bundlename.lastIndexOf('.');
82 if (i != -1) {
83 String alternateBundleName =
84 bundlename.substring(i + 1);
85 try {
86 bundle =
87 ResourceBundle.getBundle(
88 alternateBundleName,
89 _locale);
90 } catch (MissingResourceException e2) {
91 // give up
92 return getDefaultMessage(l);
93 }
94 }
95 }
96
97 _resourceBundles.put(bundlename, bundle);
98 }
99
100 if (bundle == null) {
101 return getDefaultMessage(l);
102 }
103
104 if (key == null)
105 key = "undefined";
106
107 String msg;
108 try {
109 msg = bundle.getString(key);
110 } catch (MissingResourceException e) {
111 // notice that this may throw a MissingResourceException of its own (caught below)
112 msg = bundle.getString("undefined");
|
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
71 try {
72 bundle = ResourceBundle.getBundle(bundlename, _locale);
73 } catch (MissingResourceException e) {
74 // work around a bug in the com.sun.enterprise.deployment.WebBundleArchivist:
75 // all files with an extension different from .class (hence all the .properties files)
76 // get copied to the top level directory instead of being in the package where they
77 // are defined
78 // so, since we can't find the bundle under its proper name, we look for it under
79 // the top-level package
80
81 int i = bundlename.lastIndexOf('.');
82 if (i != -1) {
83 String alternateBundleName =
84 bundlename.substring(i + 1);
85 try {
86 bundle =
87 ResourceBundle.getBundle(
88 alternateBundleName,
89 _locale);
90 } catch (MissingResourceException e2) {
91 //try context classloader
92 try {
93 bundle = ResourceBundle.getBundle(bundlename, _locale, Thread.currentThread().getContextClassLoader());
94 } catch (MissingResourceException e3) {
95 // give up
96 return getDefaultMessage(l);
97 }
98
99 }
100 }
101 }
102
103 _resourceBundles.put(bundlename, bundle);
104 }
105
106 if (bundle == null) {
107 return getDefaultMessage(l);
108 }
109
110 if (key == null)
111 key = "undefined";
112
113 String msg;
114 try {
115 msg = bundle.getString(key);
116 } catch (MissingResourceException e) {
117 // notice that this may throw a MissingResourceException of its own (caught below)
118 msg = bundle.getString("undefined");
|