Example usage for org.springframework.beans.factory ObjectFactory getClass

List of usage examples for org.springframework.beans.factory ObjectFactory getClass

Introduction

In this page you can find the example usage for org.springframework.beans.factory ObjectFactory getClass.

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.ehoffman.aopalliance.extensions.scope.SpringTestScope.java

@Override
public Object get(final String name, final ObjectFactory<?> objectFactory) {
    final Map<String, Object> scope = values.get();
    try {/*  w  ww  .  ja  v  a  2s  . c om*/
        final Field field = objectFactory.getClass().getDeclaredField("val$mbd");
        field.setAccessible(true);
        final RootBeanDefinition def = (RootBeanDefinition) field.get(objectFactory);
        if (def != null && def.getDependsOn() != null) {
            dependencies.get().put(name, Arrays.asList(def.getDependsOn()));
            LOGGER.warn("Adding dependencies for " + name + " which are" + Arrays.asList(def.getDependsOn()));
        }
    } catch (final Throwable t) {
        LOGGER.error("Spring has changed, time to update this method");
    }
    Object object = scope.get(name);
    if (object == null) {
        object = objectFactory.getObject();
        scope.put(name, object);
    }
    return object;
}