Package org.qi4j.runtime.composite

Examples of org.qi4j.runtime.composite.MixinModel


        super.bind( resolution );

        // Find what mixins implement Lifecycle
        for( int i = 0; i < mixinModels.size(); i++ )
        {
            MixinModel mixinModel = mixinModels.get( i );
            if( Lifecycle.class.isAssignableFrom( mixinModel.mixinClass() ) )
            {
                if( lifecycleMixins == null )
                {
                    lifecycleMixins = new ArrayList<Integer>();
                }
View Full Code Here


        }
    }

    public Object newMixin( EntityInstance entityInstance, StateHolder state, Object[] mixins, Method method )
    {
        MixinModel model = methodImplementation.get( method );
        InjectionContext injectionContext = new InjectionContext( entityInstance, UsesInstance.EMPTY_USES, state );
        Object mixin = model.newInstance( injectionContext );
        mixins[ methodIndex.get( method ) ] = mixin;
        return mixin;
    }
View Full Code Here

    Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>();
    Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>();

    public MixinModel getMixinModel( Class mixinClass )
    {
        return new MixinModel( mixinClass, instantiationClass( mixinClass ) );
    }
View Full Code Here

                if( !compositeMethodsModel.isImplemented( method )
                    && !Proxy.class.equals( method.getDeclaringClass().getSuperclass() )
                    && !Proxy.class.equals( method.getDeclaringClass() )
                    && !Modifier.isStatic( method.getModifiers() ) )
                {
                    MixinModel mixinModel = implementMethod( method, mixinClasses );
                    ConcernsModel concernsModel = concernsFor(
                        method,
                        mixinModel.mixinClass(),
                        Iterables.<Class<?>>flatten( concernDeclarations( mixinModel.mixinClass() ),
                                                     concernClasses )
                    );
                    SideEffectsModel sideEffectsModel = sideEffectsFor(
                        method,
                        mixinModel.mixinClass(),
                        Iterables.<Class<?>>flatten( sideEffectDeclarations( mixinModel.mixinClass() ),
                                                     sideEffectClasses )
                    );
                    method.setAccessible( true );
                    ConstraintsModel constraints = constraintsFor(
                        method,
                        Iterables.<Class<? extends Constraint<?, ?>>>flatten( constraintDeclarations( mixinModel.mixinClass() ),
                                                                              constraintClasses )
                    );
                    CompositeMethodModel methodComposite = new CompositeMethodModel(
                        method,
                        constraints,
                        concernsModel,
                        sideEffectsModel,
                        mixinsModel
                    );

                    // Implement @This references
                    Iterable<Class<?>> map = map( new DependencyModel.InjectionTypeFunction(),
                                                  filter( new DependencyModel.ScopeSpecification( This.class ),
                                                          methodComposite.dependencies() ) );
                    Iterable<Class<?>> map1 = map( new DependencyModel.InjectionTypeFunction(),
                                                   filter( new DependencyModel.ScopeSpecification( This.class ),
                                                           mixinModel.dependencies() ) );
                    @SuppressWarnings( "unchecked" )
                    Iterable<Class<?>> filter = filter(
                        not( in( Initializable.class, Lifecycle.class, InvocationHandler.class ) ),
                        map( Classes.RAW_CLASS, interfacesOf( mixinModel.mixinClass() ) )
                    );
                    Iterable<? extends Class<?>> flatten = flatten( map, map1, filter );
                    addAll( thisDependencies, flatten );

                    compositeMethodsModel.addMethod( methodComposite );
View Full Code Here

    }

    @SuppressWarnings( "raw" )
    protected MixinModel implementMethod( Method method, Iterable<Class<?>> mixinDeclarations )
    {
        MixinModel implementationModel = mixinsModel.mixinFor( method );
        if( implementationModel != null )
        {
            return implementationModel;
        }
        Class mixinClass = findTypedImplementation( method, mixinDeclarations );
View Full Code Here

        } ), mixins ) );
    }

    private MixinModel implementMethodWithClass( Method method, Class mixinClass )
    {
        MixinModel mixinModel = mixinsModel.getMixinModel( mixinClass );
        if( mixinModel == null )
        {
            mixinModel = helper.getMixinModel( mixinClass );
            mixinsModel.addMixinModel( mixinModel );
        }
View Full Code Here

            public boolean visitEnter( Object visited )
                throws RuntimeException
            {
                if( visited instanceof MixinModel )
                {
                    MixinModel model = (MixinModel) visited;
                    Visitor<Field, RuntimeException> addState = new Visitor<Field, RuntimeException>()
                    {
                        @Override
                        public boolean visit( Field visited )
                            throws RuntimeException
                        {
                            addStateFor( visited, constraintClasses );
                            return true;
                        }
                    };
                    ForEach.forEach( Fields.FIELDS_OF.map( model.mixinClass() ) ).
                        filter( Annotations.hasAnnotation( State.class ) ).
                        visit( addState );
                    return false;
                }
                return super.visitEnter( visited );
View Full Code Here

        super.bind( resolution );

        // Find what mixins implement Lifecycle
        for( int i = 0; i < mixinModels.size(); i++ )
        {
            MixinModel mixinModel = mixinModels.get( i );
            if( Lifecycle.class.isAssignableFrom( mixinModel.mixinClass() ) )
            {
                if( lifecycleMixins == null )
                {
                    lifecycleMixins = new ArrayList<Integer>();
                }
View Full Code Here

        }
    }

    public Object newMixin( EntityInstance entityInstance, StateHolder state, Object[] mixins, Method method )
    {
        MixinModel model = methodImplementation.get( method );
        InjectionContext injectionContext = new InjectionContext( entityInstance, UsesInstance.EMPTY_USES, state );
        Object mixin = model.newInstance( injectionContext );
        mixins[ methodIndex.get( method ) ] = mixin;
        return mixin;
    }
View Full Code Here

TOP

Related Classes of org.qi4j.runtime.composite.MixinModel

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.