Package com.google.inject.name

Examples of com.google.inject.name.Named


    {
    }

    public void testJsrNamed()
    {
        final Named guiceNamed = Names.named( "TEST" );

        final Injector injector = Guice.createInjector( new AbstractModule()
        {
            @Override
            protected void configure()
View Full Code Here


        }
        else
        {
            binder.bind( providerType ).in( Scopes.SINGLETON );

            final Named bindingName = getBindingName( providerType );
            final Class<?>[] types = getBindingTypes( providerType );

            final Key key = getBindingKey( args[0], bindingName );
            final ScopedBindingBuilder sbb = binder.bind( key ).toProvider( providerType );
            if ( isEagerSingleton( providerType ) )
View Full Code Here

        if ( isEagerSingleton( qualifiedType ) )
        {
            sbb.asEagerSingleton();
        }

        final Named bindingName = getBindingName( qualifiedType );
        final Class<?>[] types = getBindingTypes( qualifiedType );

        if ( null != types )
        {
            final Key key = getBindingKey( OBJECT_TYPE_LITERAL, bindingName );
View Full Code Here

                // early prototypes of JSR330 @Named declared no default value
            }
        }
        else
        {
            final Named guice = qualifiedType.getAnnotation( Named.class );
            if ( null != guice )
            {
                final String name = guice.value();
                if ( name.length() > 0 )
                {
                    return "default".equals( name ) ? null : guice;
                }
            }
View Full Code Here

        // Bind ThriftClientConfig with random @Named annotation
        // We generate a random Named annotation for binding the ThriftClientConfig because we
        // need one of these for each clientType+annotationType pair.  Without this, the
        // ThriftClientConfig bindings collapse to a single instance which is shared by all
        // clients.
        Named thriftClientConfigKey = Names.named(UUID.randomUUID().toString());
        bindConfig(binder).annotatedWith(thriftClientConfigKey).prefixedWith(typeName).to(ThriftClientConfig.class);

        // Bind ThriftClient to a provider which knows how to find the ThriftClientConfig using
        // the random @Named annotation
        Multibinder<ThriftClientEventHandler> eventHandlersBinder = Multibinder.newSetBinder(binder,
View Full Code Here

        String typeName = getServiceName(clientInterface);
        String name = annotationType.getSimpleName();

        // Bind ThriftClientConfig with random @Named annotation
        // see comment on random Named annotation above
        Named thriftClientConfigKey = Names.named(UUID.randomUUID().toString());
        String prefix = String.format("%s.%s", typeName, name);
        bindConfig(binder).annotatedWith(thriftClientConfigKey).prefixedWith(prefix).to(ThriftClientConfig.class);

        // Bind ThriftClient to a provider which knows how to find the ThriftClientConfig using
        // the random @Named annotation
View Full Code Here

    }
   
    Injector injector = Guice.createInjector(new ProductionBindings(type, temp));
    NoSqlEntityManagerFactory factory = injector.getInstance(NoSqlEntityManagerFactory.class);

    Named named = Names.named("logger");
    Key<NoSqlRawSession> key = Key.get(NoSqlRawSession.class, named);
    NoSqlRawSession inst = injector.getInstance(key);
    inst.start(properties);
   
    //why not just add setInjector() and setup() in NoSqlEntityManagerFactory
View Full Code Here

    Map<String, Key<?>> nameMap = new HashMap<String, Key<?>>();
    Injector injector = Guice.createInjector(module);
    for (Key<?> key : injector.getBindings().keySet()) {
      Class<? extends Annotation> annotationType = key.getAnnotationType();
      if (annotationType != null && Named.class.isAssignableFrom(annotationType)) {
        Named named = (Named)key.getAnnotation();
        nameMap.put(named.value(), key);
      }
    }

    //
    this.injector = injector;
View Full Code Here

{
    @Test
    public void testSubclassing()
        throws Exception
    {
        final Named name1 = Names.named("bean1");
        final Named name2 = Names.named("bean2");

        final TestingMBeanServer tms = new TestingMBeanServer();

        final Module m1 = new MBeanModule() {
            @Override
View Full Code Here

TOP

Related Classes of com.google.inject.name.Named

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.