Example usage for org.apache.wicket.spring SpringBeanLocator locateProxyTarget

List of usage examples for org.apache.wicket.spring SpringBeanLocator locateProxyTarget

Introduction

In this page you can find the example usage for org.apache.wicket.spring SpringBeanLocator locateProxyTarget.

Prototype

@Override
    public Object locateProxyTarget() 

Source Link

Usage

From source file:org.xaloon.wicket.component.inject.spring.CdiProxyFieldValueFactory.java

License:Apache License

public Object getFieldValue(Field field, Object fieldOwner) {
    if (supportsField(field)) {
        String beanName = getBeanName(field);
        if (StringUtils.isEmpty(beanName)) {
            return null;
        }/*w  ww . ja va2s  .com*/
        SpringBeanLocator locator = new SpringBeanLocator(beanName, field.getType(), contextLocator);

        // only check the cache if the bean is a singleton
        Object cachedValue = cache.get(locator);
        if (cachedValue != null) {
            return cachedValue;
        }

        final Object target;
        if (wrapInProxies) {
            target = LazyInitProxyFactory.createProxy(field.getType(), locator);
        } else {
            target = locator.locateProxyTarget();
        }

        // only put the proxy into the cache if the bean is a singleton
        if (locator.isSingletonBean()) {
            cache.put(locator, target);
        }
        return target;
    }
    return null;
}