Package com.google.inject

Examples of com.google.inject.PrivateBinder


        inspect(properties, null, new Module()
        {
            @Override
            public void configure(Binder binder)
            {
                PrivateBinder privateBinder = binder.newPrivateBinder();
                ConfigurationModule.bindConfig(privateBinder).to(AnnotatedSetter.class);
            }
        })
                .component("ConfigurationFactoryTest$AnnotatedSetter")
                .value("BooleanValue", "boolean-value", "false", "true", "")
View Full Code Here


        Module module = new Module()
        {
            @Override
            public void configure(Binder binder)
            {
                PrivateBinder privateBinder = binder.newPrivateBinder();
                privateBinder.install(createModule(Config1.class, null));
                privateBinder.bind(ExposeConfig.class).in(Scopes.SINGLETON);
                privateBinder.expose(ExposeConfig.class);
            }
        };
        Injector injector = createInjector(properties, module);
        verifyConfig(injector.getInstance(ExposeConfig.class).config1);
    }
View Full Code Here

        Module module = new Module()
        {
            @Override
            public void configure(Binder binder)
            {
                PrivateBinder privateBinder = binder.newPrivateBinder();
                privateBinder.install(createModule(Config1.class, null));
                privateBinder.bind(ExposeConfig.class).annotatedWith(named("no-prefix")).to(ExposeConfig.class).in(Scopes.SINGLETON);
                privateBinder.expose(Key.get(ExposeConfig.class, named("no-prefix")));

                privateBinder = binder.newPrivateBinder();
                privateBinder.install(createModule(Config1.class, "prefix"));
                privateBinder.bind(ExposeConfig.class).annotatedWith(named("prefix")).to(ExposeConfig.class).in(Scopes.SINGLETON);
                privateBinder.expose(Key.get(ExposeConfig.class, named("prefix")));
            }

        };
        properties = ImmutableMap.<String, String>builder()
                .putAll(properties)
View Full Code Here

                        {
                            @Override
                            public void configure(Binder binder)
                            {
                                newExporter(binder).export(ManagedClass.class);
                                PrivateBinder privateBinder = binder.newPrivateBinder();
                                HttpClientBinder.httpClientPrivateBinder(privateBinder, binder).bindHttpClient("foo", FooClient.class);
                                privateBinder.bind(ExposeHttpClient.class);
                                privateBinder.expose(ExposeHttpClient.class);
                            }
                        })
                .quiet()
                .initialize();
View Full Code Here

                        {
                            @Override
                            public void configure(Binder binder)
                            {
                                newExporter(binder).export(ManagedClass.class);
                                PrivateBinder privateBinder = binder.newPrivateBinder();
                                HttpClientBinder.httpClientPrivateBinder(privateBinder, binder).bindAsyncHttpClient("foo", FooClient.class);
                                privateBinder.bind(ExposeHttpClient.class);
                                privateBinder.expose(ExposeHttpClient.class);
                            }
                        })
                .quiet()
                .initialize();
View Full Code Here

                        {
                            @Override
                            public void configure(Binder binder)
                            {
                                newExporter(binder).export(ManagedClass.class);
                                PrivateBinder privateBinder = binder.newPrivateBinder();
                                HttpClientBinder.httpClientPrivateBinder(privateBinder, binder).bindAsyncHttpClient("foo", FooClient.class);
                                privateBinder.bind(ExposeHttpClient.class);
                                privateBinder.expose(ExposeHttpClient.class);
                                HttpClientBinder.httpClientBinder(binder).bindAsyncHttpClient("bar", BarClient.class);
                            }
                        })
                .quiet()
                .initialize();
View Full Code Here

            {
                // Follows example set by Guice Modules when applying private elements:
                final PrivateElements privateElements = (PrivateElements) e;

                // 1. create new private binder, using the elements source token
                final PrivateBinder privateBinder = binder.withSource( e.getSource() ).newPrivateBinder();

                // 2. for all elements, apply each element to the private binder
                replayRecordedElements( privateBinder, privateElements.getElements() );

                // 3. re-expose any exposed keys using their exposed source token
                for ( final Key<?> k : privateElements.getExposedKeys() )
                {
                    privateBinder.withSource( privateElements.getExposedSource( k ) ).expose( k );
                }
            }
            else
            {
                e.applyTo( binder );
View Full Code Here

        //
        // 1. create new private binder, using the elements source token
        // 2. for all elements, apply each element to the private binder
        // 3. re-expose any exposed keys using their exposed source token

        final PrivateBinder privateBinder = binder.withSource( elements.getSource() ).newPrivateBinder();
        final ElementAnalyzer privateAnalyzer = new ElementAnalyzer( privateBinder );

        privateAnalyzers.add( privateAnalyzer );

        // ignore bindings already in the parent
        privateAnalyzer.ignoreKeys( localKeys );
        for ( final Element e : elements.getElements() )
        {
            e.acceptVisitor( privateAnalyzer );
        }

        for ( final Key<?> k : elements.getExposedKeys() )
        {
            // only expose valid bindings that won't conflict with existing ones
            if ( privateAnalyzer.localKeys.contains( k ) && localKeys.add( k ) )
            {
                privateBinder.withSource( elements.getExposedSource( k ) ).expose( k );
            }
        }

        return null;
    }
View Full Code Here

    this.exposureBuilders.add(paramExposureBuilder);
  }

  public void applyTo(Binder paramBinder)
  {
    PrivateBinder localPrivateBinder = paramBinder.withSource(this.source).newPrivateBinder();
    Iterator localIterator = getElements().iterator();
    Object localObject;
    while (localIterator.hasNext())
    {
      localObject = (Element)localIterator.next();
      ((Element)localObject).applyTo(localPrivateBinder);
    }
    getExposedKeys();
    localIterator = this.exposedKeysToSources.entrySet().iterator();
    while (localIterator.hasNext())
    {
      localObject = (Map.Entry)localIterator.next();
      localPrivateBinder.withSource(((Map.Entry)localObject).getValue()).expose((Key)((Map.Entry)localObject).getKey());
    }
  }
View Full Code Here

    this.exposureBuilders.add(paramExposureBuilder);
  }

  public void applyTo(Binder paramBinder)
  {
    PrivateBinder localPrivateBinder = paramBinder.withSource(this.source).newPrivateBinder();
    Iterator localIterator = getElements().iterator();
    Object localObject;
    while (localIterator.hasNext())
    {
      localObject = (Element)localIterator.next();
      ((Element)localObject).applyTo(localPrivateBinder);
    }
    getExposedKeys();
    localIterator = this.exposedKeysToSources.entrySet().iterator();
    while (localIterator.hasNext())
    {
      localObject = (Map.Entry)localIterator.next();
      localPrivateBinder.withSource(((Map.Entry)localObject).getValue()).expose((Key)((Map.Entry)localObject).getKey());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.inject.PrivateBinder

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.