Example usage for org.springframework.core.io.support ResourcePatternResolver getClass

List of usage examples for org.springframework.core.io.support ResourcePatternResolver getClass

Introduction

In this page you can find the example usage for org.springframework.core.io.support ResourcePatternResolver getClass.

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.red5.server.api.persistence.PersistenceUtils.java

/**
 * Returns persistence store object. Persistence store is a special object that stores persistence objects and provides methods to manipulate them (save, load, remove, list).
 * //  w ww.  j av a 2  s  . c  om
 * @param resolver
 *            Resolves connection pattern into Resource object
 * @param className
 *            Name of persistence class
 * @return IPersistence store object that provides methods for persistence object handling
 * @throws Exception
 *             if error
 */
public static IPersistenceStore getPersistenceStore(ResourcePatternResolver resolver, String className)
        throws Exception {
    Class<?> persistenceClass = Class.forName(className);
    Constructor<?> constructor = getPersistenceStoreConstructor(persistenceClass,
            resolver.getClass().getInterfaces());
    if (constructor == null) {
        // Search in superclasses of the object.
        Class<?> superClass = resolver.getClass().getSuperclass();
        while (superClass != null) {
            constructor = getPersistenceStoreConstructor(persistenceClass, superClass.getInterfaces());
            if (constructor != null) {
                break;
            }
            superClass = superClass.getSuperclass();
        }
    }
    if (constructor == null) {
        throw new NoSuchMethodException();
    }
    return (IPersistenceStore) constructor.newInstance(new Object[] { resolver });
}