Package com.google.inject

Examples of com.google.inject.Key$SimpleKey


  @SuppressWarnings({"unchecked"})
  public <T> LinkedBindingBuilder<T> bind(Key<T> key) {
    TypeLiteral<T> typeLiteralToBind = key.getTypeLiteral();

    Key providerKey  = Key.get(
          Types.newParameterizedType(
              ScopeIdBasedProvider.class, typeLiteralToBind.getType()));
    Map<ScopeId, Key> bindingsForScope = bindingsPerType.get(providerKey);

    if (!existingKeys.contains(key)) {
View Full Code Here


    for (Method method : annotatedMethods) {
      CaptureInScope annotation = checkNotNull(
          method.getAnnotation(CaptureInScope.class));
      Class<? extends Annotation> bindingAnnotation = annotation.value();
      Key key = bindingAnnotation == DEFAULT_ANNOTATION_VALUE ?
                Key.get(method.getGenericReturnType()) :
                Key.get(method.getGenericReturnType(), bindingAnnotation);

      if (!seenKeys.add(key)) {
        logger.fine("Would have attempted to bind the same key twice: " + key);
View Full Code Here

          .checkNotNull(method.getAnnotation(CaptureInScope.class));
      Class<? extends Annotation> bindingAnnotation = annotation.value();
      // The construction of the key will fail if the annotation is not an
      // instance of BindingAnnotation. We could do a Preconditions check here,
      // but it'd be simply redundant.
      Key key = bindingAnnotation == DEFAULT_ANNOTATION_VALUE ?
                Key.get(method.getGenericReturnType()) :
                Key.get(method.getGenericReturnType(), bindingAnnotation);

      nestedScope.put(key, result);
    }
View Full Code Here

    private ParamDef buildParamDef(Method m, int idx, boolean withParamResolver) {

        Class paramType = m.getParameterTypes()[idx];
        Annotation[] paramAnnotations = m.getParameterAnnotations()[idx];

        Key key = null;

        WebParamResolverRef paramResolverRef = null;

        if (withParamResolver) {
            paramResolverRef = paramResolverRegistry.getWebParamResolverRef(m, idx);
View Full Code Here

        boolean calledDefault = false;
        boolean calledCustom = false;

        for (Element e : Elements.getElements(underTest)) {
            if (e instanceof Binding) {
                Key key = ((Binding) e).getKey();
                if (Named.class.isAssignableFrom(key.getAnnotation().annotationType())
                        && "configureInterceptors".equals(((Named) key.getAnnotation()).value())
                        && key.getTypeLiteral().getRawType().equals(Object.class)) {
                    calledCustom = true;
                }
                if (Named.class.isAssignableFrom(key.getAnnotation().annotationType())
                        && "configureDefaultInterceptors".equals(((Named) key.getAnnotation()).value())
                        && key.getTypeLiteral().getRawType().equals(Object.class)) {
                    calledDefault = true;
                }
            }
        }
    }
View Full Code Here

    assertEquals("A Bob", clone.getName());

    assertNotSame(bob, clone);
    assertSame(bob.getDaughter(), clone.getDaughter());

    Key soleBobKey = Key.get(Bob.class, Sole.class);
    assertSame(
        injector.getInstance(soleBobKey),
        injector.getInstance(soleBobKey)
    );
  }
View Full Code Here

        return result;
    }
   

    private Object guiceResolveParamDef(ParamDef paramDef){
        Key key = paramDef.getKey();
        if (key != null){
            return injector.getInstance(key);
        }else{
            return injector.getInstance(paramDef.getParamType());
        }
View Full Code Here

    private ParamDef buildParamDef(Method m,int idx,boolean withParamResolver){
       
        Class paramType = m.getParameterTypes()[idx];
        Annotation[] paramAnnotations = m.getParameterAnnotations()[idx];
       
        Key key = null;
       
        WebParamResolverRef paramResolverRef = null;
       
        if (withParamResolver){
            paramResolverRef = paramResolverRegistry.getWebParamResolverRef(m, idx);
View Full Code Here

                throws Throwable
            {
                final String methodName = method.getName();
                if ( "getInstance".equals( methodName ) )
                {
                    final Key key = args[0] instanceof Key ? (Key) args[0] : Key.get( (Class) args[0] );
                    final Iterator<Entry> i = injector.getInstance( BeanLocator.class ).locate( key ).iterator();
                    return i.hasNext() ? i.next().getValue() : null;
                }
                if ( "injectMembers".equals( methodName ) )
                {
View Full Code Here

        if ( 2 == args.length )
        {
            final Class qualifierType = args[0].getRawType();
            if ( qualifierType.isAnnotationPresent( Qualifier.class ) )
            {
                final Key beanKey = Key.get( args[1], qualifierType );
                final Provider beanEntries = beanProviders.beanEntriesOf( beanKey );
                return BeanEntry.class == entryType.getRawType() ? beanEntries
                                : org.eclipse.sisu.inject.Legacy.adapt( beanEntries );
            }
        }
View Full Code Here

TOP

Related Classes of com.google.inject.Key$SimpleKey

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.