Examples of BeanNotOfRequiredTypeException


Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

      catch (TypeMismatchException ex) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failed to convert bean '" + name + "' to required type [" +
              ClassUtils.getQualifiedName(requiredType) + "]", ex);
        }
        throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
      }
    }
    return (T) bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

      }
    }

    // Check if required type matches the type of the actual bean instance.
    if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
      throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
    }
    return (T) bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  @SuppressWarnings("unchecked")
  public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
    Object bean = getBean(name);
    if (requiredType != null && !requiredType.isAssignableFrom(bean.getClass())) {
      throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
    }
    return (T) bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

      catch (TypeMismatchException ex) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failed to convert bean '" + name + "' to required type [" +
              ClassUtils.getQualifiedName(requiredType) + "]", ex);
        }
        throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
      }
    }
    return (T) bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

    }
    catch (NameNotFoundException ex) {
      throw new NoSuchBeanDefinitionException(name, "not found in JNDI environment");
    }
    catch (TypeMismatchNamingException ex) {
      throw new BeanNotOfRequiredTypeException(name, ex.getRequiredType(), ex.getActualType());
    }
    catch (NamingException ex) {
      throw new BeanDefinitionStoreException("JNDI environment", name, "JNDI lookup failed", ex);
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

    }
    catch (NameNotFoundException ex) {
      throw new NoSuchBeanDefinitionException(name, "not found in JNDI environment");
    }
    catch (TypeMismatchNamingException ex) {
      throw new BeanNotOfRequiredTypeException(name, ex.getRequiredType(), ex.getActualType());
    }
    catch (NamingException ex) {
      throw new BeanDefinitionStoreException("JNDI environment", name, "JNDI lookup failed", ex);
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

      }
    }

    // Check if required type matches the type of the actual bean instance.
    if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
      throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
    }
    return bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  }
 
  public Object getBean(String name, Class requiredType) throws BeansException {
    Object bean = getBean(name);
    if (requiredType != null && !requiredType.isAssignableFrom(bean.getClass())) {
      throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
    }
    return bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  public Object getBean(String name, Class requiredType) throws BeansException
  {
    Object bean = getBean(name);
    if (!(requiredType.isAssignableFrom(bean.getClass())))
    {
      throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
    }
    return bean;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  public void testLookupWhereBeanFactoryYieldsNonDataSourceType() throws Exception {
    MockControl mockBeanFactory = MockControl.createControl(BeanFactory.class);
    final BeanFactory beanFactory = (BeanFactory) mockBeanFactory.getMock();

    beanFactory.getBean(DATASOURCE_BEAN_NAME, DataSource.class);
    mockBeanFactory.setThrowable(new BeanNotOfRequiredTypeException(DATASOURCE_BEAN_NAME, DataSource.class, String.class));

    mockBeanFactory.replay();

    new AssertThrows(DataSourceLookupFailureException.class) {
      public void test() throws Exception {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.