コード例 #1
0
  public Object getFieldValue(final Field field, final Object fieldOwner) {
    if (supportsField(field)) {
      String beanName = getBeanName(field);

      if (beanName == null) {
        return null;
      }

      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;
  }
コード例 #2
0
  public SkillsRepository getSkillsRepository() {

    return (SkillsRepository)
        LazyInitProxyFactory.createProxy(SkillsRepository.class, bean("skillsRepository"));
  }