Package com.google.inject

Examples of com.google.inject.Binding


        .andReturn(mockServlet);

    final Key<List<ServletDefinition>> servetDefsKey = Key
        .get(new TypeLiteral<List<ServletDefinition>>() {});

    Binding mockBinding = createMock(Binding.class);
    expect(mockBinding.getKey()).andReturn(servetDefsKey);
    expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral())))
        .andReturn(ImmutableList.<Binding<List<ServletDefinition>>>of(mockBinding));

    expect(injector.getInstance(servetDefsKey))
        .andReturn(ImmutableList.of(servletDefinition));
View Full Code Here



    final Key<List<ServletDefinition>> servetDefsKey = Key
        .get(new TypeLiteral<List<ServletDefinition>>() {});

    Binding mockBinding = createMock(Binding.class);
    expect(mockBinding.getKey()).andReturn(servetDefsKey);
    expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral())))
        .andReturn(ImmutableList.<Binding<List<ServletDefinition>>>of(mockBinding));

    expect(injector.getInstance(servetDefsKey))
        .andReturn(ImmutableList.of(servletDefinition));
View Full Code Here

        {
            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;
                    }
View Full Code Here

  void index()
  {
    Iterator localIterator = this.state.getExplicitBindingsThisLevel().values().iterator();
    while (localIterator.hasNext())
    {
      Binding localBinding = (Binding)localIterator.next();
      index(localBinding);
    }
  }
View Full Code Here

  void index()
  {
    Iterator localIterator = this.state.getExplicitBindingsThisLevel().values().iterator();
    while (localIterator.hasNext())
    {
      Binding localBinding = (Binding)localIterator.next();
      index(localBinding);
    }
  }
View Full Code Here

    return this.parent;
  }

  public BindingImpl getExplicitBinding(Key paramKey)
  {
    Binding localBinding = (Binding)this.explicitBindings.get(paramKey);
    return localBinding != null ? (BindingImpl)localBinding : this.parent.getExplicitBinding(paramKey);
  }
View Full Code Here

    return this.parent;
  }

  public BindingImpl getExplicitBinding(Key paramKey)
  {
    Binding localBinding = (Binding)this.explicitBindings.get(paramKey);
    return localBinding != null ? (BindingImpl)localBinding : this.parent.getExplicitBinding(paramKey);
  }
View Full Code Here

  private void servletPath(final String requestPath, String mapping,
      final String expectedServletPath) throws IOException, ServletException {

    Injector injector = createMock(Injector.class);
    Binding binding = createMock(Binding.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpServletResponse response = createMock(HttpServletResponse.class);

    expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject()))
        .andReturn(true);
    expect(injector.getBinding(Key.get(HttpServlet.class)))
        .andReturn(binding);

    final boolean[] run = new boolean[1];
View Full Code Here

  private void pathInfoWithServletStyleMatching(final String requestUri, final String contextPath,
      String mapping, final String expectedPathInfo, final String servletPath)
      throws IOException, ServletException {

    Injector injector = createMock(Injector.class);
    Binding binding = createMock(Binding.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpServletResponse response = createMock(HttpServletResponse.class);

    expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject()))
        .andReturn(true);
    expect(injector.getBinding(Key.get(HttpServlet.class)))
        .andReturn(binding);

    final boolean[] run = new boolean[1];
View Full Code Here

  public final void pathInfoWithRegexMatching(final String requestUri, final String contextPath,
      String mapping, final String expectedPathInfo, final String servletPath)
      throws IOException, ServletException {

    Injector injector = createMock(Injector.class);
    Binding binding = createMock(Binding.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpServletResponse response = createMock(HttpServletResponse.class);

    expect(binding.acceptScopingVisitor((BindingScopingVisitor) anyObject()))
        .andReturn(true);
    expect(injector.getBinding(Key.get(HttpServlet.class)))
        .andReturn(binding);

    final boolean[] run = new boolean[1];
View Full Code Here

TOP

Related Classes of com.google.inject.Binding

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.