public Binding get()

in org.eclipse.sisu.inject/src/org/eclipse/sisu/inject/ImplicitBindings.java [45:90]


    public <T> Binding<T> get( final TypeLiteral<T> type )
    {
        final Key implicitKey = TypeArguments.implicitKey( type.getRawType() );
        for ( final BindingPublisher p : publishers )
        {
            if ( p instanceof InjectorPublisher )
            {
                // first round: check for any re-written implicit bindings
                final Injector i = ( (InjectorPublisher) p ).getInjector();
                final Binding binding = i.getBindings().get( implicitKey );
                if ( null != binding )
                {
                    Logs.trace( "Using implicit binding: {} from: <>", binding, i );
                    return binding;
                }
            }
        }

        final Key justInTimeKey = Key.get( type );
        for ( final BindingPublisher p : publishers )
        {
            if ( p instanceof InjectorPublisher )
            {
                // second round: fall back to just-in-time binding lookup
                final Injector i = ( (InjectorPublisher) p ).getInjector();
                try
                {
                    final Binding binding = i.getBinding( justInTimeKey );
                    if ( InjectorPublisher.isVisible( binding ) )
                    {
                        Logs.trace( "Using just-in-time binding: {} from: <>", binding, i );
                        return binding;
                    }
                }
                catch ( final RuntimeException e ) // NOPMD
                {
                    Logs.trace( "Problem with just-in-time binding: {}", justInTimeKey, e );
                }
                catch ( final LinkageError e ) // NOPMD
                {
                    Logs.trace( "Problem with just-in-time binding: {}", justInTimeKey, e );
                }
            }
        }
        return null;
    }