Examples of UsesInstance


Examples of org.qi4j.runtime.composite.UsesInstance

        @SuppressWarnings( "unchecked" )
        public Object provideInjection( InjectionContext context )
            throws InjectionProviderException
        {
            UsesInstance uses = context.uses();

            Class injectionType = dependency.rawInjectionType();
            Object usesObject = uses.useForType( injectionType );

            if( usesObject == null && !dependency.optional())
            {
                // No @Uses object provided
                // Try instantiating a Transient or Object for the given type
                ModuleInstance moduleInstance = context.module();

                try
                {
                    if (context.instance() != null)
                        uses = uses.use( context.instance() );
                    usesObject = moduleInstance.newTransient( injectionType, uses.toArray() );
                } catch( NoSuchCompositeException e )
                {
                    try
                    {
                        usesObject = moduleInstance.newObject( injectionType, uses.toArray() );
                    } catch( NoSuchObjectException e1 )
                    {
                        // Could not instantiate an instance - to try instantiate as plain class
                        try
                        {
View Full Code Here

Examples of org.qi4j.runtime.composite.UsesInstance

        TransientStateInstance state = new TransientStateInstance( properties );
        ServiceInstance compositeInstance = new ServiceInstance( this, module, mixins, state );

        // Instantiate all mixins
        int i = 0;
        UsesInstance uses = UsesInstance.EMPTY_USES.use( this );
        InjectionContext injectionContext = new InjectionContext( compositeInstance, uses, state );
        for( MixinModel mixinModel : mixinsModel.mixinModels() )
        {
            mixins[ i++ ] = mixinModel.newInstance( injectionContext );
        }
View Full Code Here

Examples of org.qi4j.runtime.composite.UsesInstance

        @SuppressWarnings( "unchecked" )
        @Override
        public Object provideInjection( InjectionContext context )
            throws InjectionProviderException
        {
            UsesInstance uses = context.uses();

            Class injectionType = dependency.rawInjectionType();
            Object usesObject = uses.useForType( injectionType );

            if( usesObject == null && !dependency.optional() )
            {
                // No @Uses object provided
                // Try instantiating a Transient or Object for the given type
                ModuleInstance moduleInstance = context.module();

                try
                {
                    if( context.instance() != null )
                    {
                        uses = uses.use( context.instance() );
                    }
                    usesObject = moduleInstance.newTransient( injectionType, uses.toArray() );
                }
                catch( NoSuchTransientException e )
                {
                    try
                    {
                        usesObject = moduleInstance.newObject( injectionType, uses.toArray() );
                    }
                    catch( NoSuchObjectException e1 )
                    {
                        // Could not instantiate an instance - to try instantiate as plain class
                        try
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.