Example usage for java.util MissingResourceException getClass

List of usage examples for java.util MissingResourceException getClass

Introduction

In this page you can find the example usage for java.util MissingResourceException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.displaytag.properties.TableProperties.java

/**
 * Returns the configured Locale Resolver. This method is called before the loading of localized properties.
 * @return LocaleResolver instance./*from  w w w. j a  v  a2 s . c  o m*/
 * @throws TablePropertiesLoadException if the default <code>TableTag.properties</code> file is not found.
 */
public static LocaleResolver getLocaleResolverInstance() throws TablePropertiesLoadException {
    // special handling, table properties is not yet instantiated
    String className = null;

    ResourceBundle defaultUserProperties = loadUserProperties(Locale.getDefault());

    // if available, user properties have higher precedence
    if (defaultUserProperties != null) {
        try {
            className = defaultUserProperties.getString(PROPERTY_CLASS_LOCALERESOLVER);
        } catch (MissingResourceException e) {
            // no problem
        }
    }

    // still null? load defaults
    if (className == null) {
        Properties defaults = loadBuiltInProperties();
        className = defaults.getProperty(PROPERTY_CLASS_LOCALERESOLVER);
    }

    if (localeResolver == null) {
        if (className != null) {
            try {
                Class classProperty = ReflectHelper.classForName(className);
                localeResolver = (LocaleResolver) classProperty.newInstance();

                log.info(Messages.getString("TableProperties.classinitializedto", //$NON-NLS-1$
                        new Object[] { ClassUtils.getShortClassName(LocaleResolver.class), className }));
            } catch (Throwable e) {
                log.warn(Messages.getString("TableProperties.errorloading", //$NON-NLS-1$
                        new Object[] { ClassUtils.getShortClassName(LocaleResolver.class),
                                e.getClass().getName(), e.getMessage() }));
            }
        } else {
            log.info(Messages.getString("TableProperties.noconfigured", //$NON-NLS-1$
                    new Object[] { ClassUtils.getShortClassName(LocaleResolver.class) }));
        }

        // still null?
        if (localeResolver == null) {
            // fallback locale resolver
            localeResolver = new LocaleResolver() {

                public Locale resolveLocale(HttpServletRequest request) {
                    return request.getLocale();
                }
            };
        }
    }

    return localeResolver;
}