Package org.qi4j.api.composite

Examples of org.qi4j.api.composite.CompositeInstance


                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );

            if (target == null)
                return null;

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return ((AssociationStateHolder)handler.state()).associationFor( accessor );
        } catch( IllegalArgumentException e )
        {
            throw e;
        } catch( Throwable e )
        {
View Full Code Here


            if (traversedAssociation != null)
                target = traversedAssociation.map( entity ).get();
            if (traversedManyAssociation != null)
                throw new IllegalArgumentException( "Cannot traverse ManyAssociations" );

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return ((AssociationStateHolder)handler.state()).manyAssociationFor( accessor );
        } catch( IllegalArgumentException e )
        {
            throw e;
        } catch( Throwable e )
        {
View Full Code Here

                throw new IllegalArgumentException( "Cannot evaluate a ManyAssociation" );

            if (target == null)
                return null;

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return handler.state().propertyFor( accessor );
        } catch( IllegalArgumentException e )
        {
            throw e;
        }catch( Throwable e )
        {
View Full Code Here

    }

    public Object newInstance( InjectionContext injectionContext )
    {
        Object mixin;
        CompositeInstance compositeInstance = injectionContext.compositeInstance();

        mixin = constructorsModel.newInstance( injectionContext );

        if( FragmentClassLoader.isGenerated( instantiationClass ) )
        {
            try
            {
                instantiationClass.getDeclaredField( "_instance" ).set( mixin,
                                                                        injectionContext.compositeInstance() );
            }
            catch( IllegalAccessException e )
            {
                e.printStackTrace();
            }
            catch( NoSuchFieldException e )
            {
                e.printStackTrace();
            }
        }

        injectedFieldsModel.inject( injectionContext, mixin );
        injectedMethodsModel.inject( injectionContext, mixin );
        if( mixin instanceof Initializable )
        {
            try
            {
                ( (Initializable) mixin ).initialize();
            }
            catch( InitializationException e )
            {
                Class<?> compositeType = compositeInstance.type();
                String message = "Unable to initialize " + mixinClass + " in composite " + compositeType;
                throw new ConstructionException( message, e );
            }
        }
        return mixin;
View Full Code Here

            ((PropertyInstance<Object>)state.propertyFor( propertyDescriptor.accessor() )).setPropertyInfo( (PropertyInfo) propertyDescriptor );
        }

        model.model().checkConstraints( state );

        CompositeInstance compositeInstance =
            model.model().newInstance( model.module(), uses, state );
        return compositeInstance.<T>proxy();
    }
View Full Code Here

    }

    public Object newInstance( InjectionContext injectionContext )
    {
        Object mixin;
        CompositeInstance compositeInstance = injectionContext.compositeInstance();

        mixin = constructorsModel.newInstance( injectionContext );

        if( FragmentClassLoader.isGenerated( instantiationClass ) )
        {
            try
            {
                instantiationClass.getDeclaredField( "_instance" ).set( mixin,
                                                                        injectionContext.compositeInstance() );
            }
            catch( IllegalAccessException e )
            {
                e.printStackTrace();
            }
            catch( NoSuchFieldException e )
            {
                e.printStackTrace();
            }
        }

        injectedFieldsModel.inject( injectionContext, mixin );
        injectedMethodsModel.inject( injectionContext, mixin );
        if( mixin instanceof Initializable )
        {
            try
            {
                ( (Initializable) mixin ).initialize();
            }
            catch( InitializationException e )
            {
                List<Class<?>> compositeType = toList( compositeInstance.types() );
                String message = "Unable to initialize " + mixinClass + " in composite " + compositeType;
                throw new ConstructionException( message, e );
            }
        }
        return mixin;
View Full Code Here

            ( (PropertyInstance<Object>) state.propertyFor( propertyDescriptor.accessor() ) ).setPropertyInfo( (PropertyInfo) propertyDescriptor );
        }

        model.model().checkConstraints( state );

        CompositeInstance compositeInstance =
            model.model().newInstance( model.module(), uses, state );
        return compositeInstance.<T>proxy();
    }
View Full Code Here

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

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return handler.state().propertyFor( accessor );
        }
        catch( IllegalArgumentException e )
        {
            throw e;
        }
View Full Code Here

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

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return ( (AssociationStateHolder) handler.state() ).associationFor( accessor );
        }
        catch( IllegalArgumentException e )
        {
            throw e;
        }
View Full Code Here

            if( traversedNamedAssociation != null )
            {
                throw new IllegalArgumentException( "Cannot traverse NamedAssociations" );
            }

            CompositeInstance handler = (CompositeInstance) Proxy.getInvocationHandler( target );
            return ( (AssociationStateHolder) handler.state() ).namedAssociationFor( accessor );
        }
        catch( IllegalArgumentException e )
        {
            throw e;
        }
View Full Code Here

TOP

Related Classes of org.qi4j.api.composite.CompositeInstance

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.