Package org.eclipse.sisu.inject

Examples of org.eclipse.sisu.inject.BeanLocator


        latest = locator;
    }

    public static BeanLocator getBeanLocator()
    {
        final BeanLocator locator = LOCATOR.get();
        return null != locator ? locator : latest;
    }
View Full Code Here


        return null != locator ? locator : latest;
    }

    public static <T> T lookup( final Key<T> key )
    {
        final BeanLocator locator = getBeanLocator();
        if ( null != locator )
        {
            final Iterator<? extends Entry<?, T>> i = locator.locate( key ).iterator();
            if ( i.hasNext() )
            {
                return i.next().getValue();
            }
        }
View Full Code Here

        return null;
    }

    public static void inject( final Object that )
    {
        final BeanLocator locator = getBeanLocator();
        if ( null != locator )
        {
            Guice.createInjector( new WireModule()
            {
                @Override
View Full Code Here

        assertSame( y, ( (PlaceholderString) grandchild.getInstance( Key.get( X.class, Names.named( "PS" ) ) ) ).fuzzy );
    }

    public void testParametersLookup()
    {
        final BeanLocator locator = Guice.createInjector( new WireModule( new AbstractModule()
        {
            @Override
            protected void configure()
            {
                bind( ParameterKeys.PROPERTIES ).toInstance( Collections.singletonMap( "Hello", "world!" ) );
            }
        } ) ).getInstance( BeanLocator.class );

        @SuppressWarnings( { "rawtypes", "unchecked" } )
        final Iterator<Map<?, ?>> itr = new EntryListAdapter( locator.locate( ParameterKeys.PROPERTIES ) ).iterator();

        assertTrue( itr.hasNext() );

        final Map<?, ?> parameters = itr.next();
        assertEquals( 1, parameters.size() );
View Full Code Here

TOP

Related Classes of org.eclipse.sisu.inject.BeanLocator

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.