Package org.qi4j.bootstrap

Examples of org.qi4j.bootstrap.InjectionException


            }
            method.invoke( instance, params );
        }
        catch( IllegalAccessException e )
        {
            throw new InjectionException( e );
        }
        catch( InvocationTargetException e )
        {
            throw new InjectionException( e.getTargetException() );
        }
    }
View Full Code Here


        {
            injectedField.set( instance, value );
        }
        catch( IllegalAccessException e )
        {
            throw new InjectionException( e );
        }
        catch( IllegalArgumentException e )
        {
            String fieldClassName = injectedField.getType().getName();
            String valueClassName = value.getClass().getName();
            String message = "Cannot inject field of type " + fieldClassName + " with value '" + value +
                             "' of type " + valueClassName;
            throw new InjectionException( message, e );
        }
    }
View Full Code Here

            }
            method.invoke( instance, params );
        }
        catch( IllegalAccessException e )
        {
            throw new InjectionException( e );
        }
        catch( InvocationTargetException e )
        {
            throw new InjectionException( e.getTargetException() );
        }
    }
View Full Code Here

        {
            injectedField.set( instance, value );
        }
        catch( IllegalAccessException e )
        {
            throw new InjectionException( e );
        }
        catch( IllegalArgumentException e )
        {
            String valueClassName;
            if( Proxy.isProxyClass( value.getClass() ) )
            {
                InvocationHandler invocationHandler = Proxy.getInvocationHandler( value );
                if( invocationHandler instanceof TransientInstance )
                {
                    TransientInstance handler = (TransientInstance) invocationHandler;
                    valueClassName = Classes.toString( handler.descriptor().types() )
                                     + " in [" + handler.module().name() + "] of [" + handler.module()
                        .layerInstance()
                        .name() + "]";
                }
                else
                {
                    valueClassName = invocationHandler.toString();
                }
            }
            else
            {
                valueClassName = value.getClass().getName();
            }
            StringBuilder annotBuilder = new StringBuilder();
            for( Annotation annot : injectedField.getAnnotations() )
            {
                String s = annot.toString();
                annotBuilder.append( "@" ).append( s.substring( s.lastIndexOf( '.' ) + 1, s.length() - 2 ) );
                annotBuilder.append( " " );
            }
            String annots = annotBuilder.toString();
            String message = "Can not inject the field\n    "
                             + injectedField.getDeclaringClass()
                             + "\n    {\n        " + annots + "\n        "
                             + injectedField.getType().getSimpleName() + " " + injectedField.getName()
                             + "\n    }\nwith value \n    " + value + "\nof type\n    "
                             + valueClassName;
            throw new InjectionException( message, e );
        }
    }
View Full Code Here

TOP

Related Classes of org.qi4j.bootstrap.InjectionException

Copyright © 2018 www.massapicom. 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.