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

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

Introduction

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

Prototype

public boolean isSingletonBean() 

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;
        }/*from   w  w  w. j  ava 2  s.  c  o m*/
        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;
}