Examples of BeanNotOfRequiredTypeException


Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  {
    Object result = getBean(name);
    if (type.isInstance(result))
      return result;
    else
      throw new BeanNotOfRequiredTypeException(name, type, result.getClass());
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  public <T> T getBean(String name, Class<T> requiredType) throws BeansException
  {
    Object bean = getBean(name);
    if (!(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

  public <T> T getBean(String name, Class<T> requiredType) throws BeansException
  {
    Object bean = getBean(name);
    if (!(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

  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

        }
    }

    @Test(expected = BeanNotOfRequiredTypeException.class)
    public void testRetryWithWrongBeanType() throws Throwable {
        Mockito.doThrow(new BeanNotOfRequiredTypeException("", String.class, String.class)).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);
        try {
            aspect.retry(mockPjp, mockAnnotation);
        }
        finally {
View Full Code Here

Examples of org.springframework.beans.factory.BeanNotOfRequiredTypeException

  @Override
  @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 (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 (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

  @Test
  public void testLookupWhereBeanFactoryYieldsNonDataSourceType() throws Exception {
    final BeanFactory beanFactory = mock(BeanFactory.class);

    given(beanFactory.getBean(DATASOURCE_BEAN_NAME, DataSource.class)).willThrow(
        new BeanNotOfRequiredTypeException(DATASOURCE_BEAN_NAME,
            DataSource.class, String.class));

    try {
        BeanFactoryDataSourceLookup lookup = new BeanFactoryDataSourceLookup(beanFactory);
        lookup.getDataSource(DATASOURCE_BEAN_NAME);
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
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.