Spring Framework BeanNotOfRequiredTypeException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework BeanNotOfRequiredTypeException class.

This code example shows how to use the following methods:
		} 
		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);
		} 
	} 
 
	@Override 
	public <T> T getBean(Class<T> requiredType) throws BeansException {
		return getBean(requiredType.getSimpleName(), requiredType);
	} 
 
	@Override 
	public Object getBean(String name, Object... args) throws BeansException {
		if (args != null) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	@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;
	} 
 
	@Override 
	public <T> T getBean(Class<T> requiredType) throws BeansException {
		String[] beanNames = getBeanNamesForType(requiredType);
		if (beanNames.length == 1) {
			return getBean(beanNames[0], requiredType);
		} 
		else if (beanNames.length > 1) {
			throw new NoUniqueBeanDefinitionException(requiredType, beanNames);
		} 
		else { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	public <T> T getBean(String name, Class<T> requiredType) throws BeansExceptionObject bean = getBean(name);
		if (!(requiredType.isAssignableFrom(bean.getClass())))
		{ 
			throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
		} 
		return (T)bean;
	} 
 
	/** 
	 * @see org.springframework.beans.factory.ListableBeanFactory#getBeansOfType(java.lang.Class) 
	 */ 
	@Override 
	@SuppressWarnings({ "unchecked" }) 
	public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException
	{ 
		final Map<String, T> found = new HashMap<>();
 
		for (Entry<String, Object> entry : beans.entrySet())
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            return (T) o;
        } 
        if (requiredType.isInstance(o)) {
            return requiredType.cast(o);
        } else { 
            throw new BeanNotOfRequiredTypeException(name, requiredType, o.getClass());
        } 
    } 
 
    @Override 
    public Object getBean(String name, Object... args) throws BeansException {
        // proxies never take arguments 
        return getBean(name);
    } 
 
    @Override 
    public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
        return definitions.get(beanName);
    } 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        } 
    } 
 
    @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 { 
            Mockito.verify(mockPjp, Mockito.never()).proceed();
        } 
    } 
 
 
    @Test
    public void testRetry() throws Throwable {
        org.springframework.retry.support.RetryTemplate template =
                new org.springframework.retry.support.RetryTemplate(); 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: