Creates a snippet that evaluates to an injected instance of the given key
in the current {@link GinjectorBindings}.
485113
public static SourceSnippet callGetter(final Key<?> key) {
    return new SourceSnippet() {
      public String getSource(InjectorWriteContext writeContext) {
        return writeContext.callGetter(key);
      }
    };
  }
930961
public void createKey(HKey hk, String key) throws RegistryException {
		int[] ret;
		try {
			ret = ReflectedMethods.createKey(hk.root(), hk.hex(), key);
		} catch (Exception e) {
			throw new RegistryException("Cannot create key " + key, e);
		}
		if (ret.length == 0) {
			throw new RegistryException("Cannot create key " + key + ". Zero return length");
		}
		if (ret[1] != RC.SUCCESS) {
			throw new RegistryException("Cannot create key " + key + ". Return code is " + ret[1]);
		}
	}
64919
public static SourceSnippet callParentGetter(final Key<?> key,
      final GinjectorBindings parentBindings) {
    return new SourceSnippet() {
      public String getSource(InjectorWriteContext writeContext) {
        return writeContext.callParentGetter(key, parentBindings);
      }
    };
  }
12113
private <T> T instantiateClass(PropertyKey propertyKey) {
        T object = null;
        String property = properties.getProperty(propertyKey.getKey());
        if (property != null) {
            try {
                Class<T> clazz = ClassLoaderUtils.loadClass(property);
                LOGGER.debug("Instantiate {}", clazz);
                object = clazz.newInstance();
            } catch (ClassNotFoundException e) {
                LOGGER.error("Couldn't load the " + property + " class given by the " + propertyKey + " property", e);
            } catch (InstantiationException e) {
                LOGGER.error("Couldn't instantiate the " + property + " class given by the " + propertyKey + " property", e);
            } catch (IllegalAccessException e) {
                LOGGER.error("Couldn't access the " + property + " class given by the " + propertyKey + " property", e);
            }
        }
        return object;
    }
1003884
private void traceKey(Key<?> key, GinjectorBindings bindings) {
    Binding binding = bindings.getBinding(key);
    // Make sure the binding is present: optional bindings might be missing.
    if (binding != null) {
      if (!reachable.add(binding)) {
        // The binding was already marked as reachable.
        return;
      }

      getReachableMemberInjects(bindings).addAll(binding.getMemberInjectRequests());

      for (Dependency dependency : binding.getDependencies()) {
        if (dependency.getSource().equals(key)) {
          Key<?> target = dependency.getTarget();

          PrettyPrinter.log(logger, TreeLogger.DEBUG, "%s:%s -> %s:%s [%s]",
              bindings, key, bindings, dependency.getTarget(), binding);
          traceKey(target, bindings);
        }
      }

      // Special cases: parent / child bindings induce dependencies between
      // GinjectorBindings objects, which can't be represented in the standard
      // dependency graph.
      if (binding instanceof ParentBinding) {
        ParentBinding parentBinding = (ParentBinding) binding;
        PrettyPrinter.log(logger, TreeLogger.DEBUG, "%s:%s -> %s:%s [inherited]",
            bindings, key, parentBinding.getParentBindings(), key);
        traceKey(key, parentBinding.getParentBindings());
      } else if (binding instanceof ExposedChildBinding) {
        ExposedChildBinding exposedChildBinding = (ExposedChildBinding) binding;
        PrettyPrinter.log(logger, TreeLogger.DEBUG, "%s:%s -> %s:%s [exposed]",
            bindings, key, exposedChildBinding.getChildBindings(), key);
        traceKey(key, exposedChildBinding.getChildBindings());
      }
    }
  }
825742
@Trivial
    private void inject(Object obj, final Object instance, HashMap<Class<?>, InjectionTarget[]> cookies) throws InjectionException {
        if (tc.isDebugEnabled())
            Tr.debug(tc, "inject", "obj --> [" + obj + "]");
        if (cookies.size() == 0) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "inject", "no injection cookies found");
            return;
        }
        if (tc.isDebugEnabled())
            Tr.debug(tc, "inject", "injection cookies found");

        // Note that 'obj' is a class.
        if (cookies.containsKey(obj)) { // To prevent NPE from the for loop below

            if (instance != null) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "inject", "about to inject via managed object --> [" + obj + "]");

                final ManagedObject<?> mo;
                try {
                    mo = getManagedObject(instance);
                    mo.inject(cookies.get(obj), null);// inject callback handler
                } catch (Exception e) {
                    throw new InjectionException(e.getCause());
                }

                if (tc.isDebugEnabled())
                    Tr.debug(tc, "inject", "injected --> [" + obj + "]");
            } else {
                for (InjectionTarget cookie : cookies.get(obj)) {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "inject", "about to inject resource --> [" + cookie + "]");

                    injectionEngine.inject(obj, cookie, null); // inject main class

                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "inject", "injected resource --> [" + cookie + "]");
                }
            }

        } else {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "inject", "cookies does not contains the key --> [" + obj + "]");
        }
    }
716776
private static void injectComponent(final Component<?> component, final boolean inner) {

        // Retrieve all fields annotated with Link
        for (final Field field : ClassUtility.getAnnotatedFields(component.getClass(), Link.class)) {
            final String keyPart = field.getAnnotation(Link.class).value();
            if (inner) {
                if (InnerComponent.class.isAssignableFrom(field.getType())) {
                    if (keyPart.isEmpty()) {
                        injectInnerComponent(component, field);
                    } else {
                        injectInnerComponent(component, field, keyPart);
                    }
                }
            } else {
                if (Component.class.isAssignableFrom(field.getType())) {
                    if (keyPart.isEmpty()) {
                        injectComponent(component, field);
                    } else {
                        injectComponent(component, field, keyPart);
                    }
                }
            }
        }

    }
174212
private <T> Provider<T> lookupProvider(Key<T> key)
  {
    BindingInject<T> bean = findBean(key);

    if (bean != null) {
      return bean.provider();
    }

    BindingAmp<T> binding = findBinding(key);

    if (binding != null) {
      return binding.provider();
    }

    binding = findObjectBinding(key);

    if (binding != null) {
      return binding.provider(InjectionPoint.of(key));
    }


    return null;
  }
1262572
private static Class<?> getBoundGinjector(GinjectorBindings bindings) {

    if (bindings.getGinjectorInterface() == null) {
      return null;
    }

    TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
    Key<?> ginjectorKey = Key.get(ginjectorInterface);

    if (!bindings.isBound(ginjectorKey)) {
      return null;
    }

    if (!(bindings.getBinding(ginjectorKey) instanceof GinjectorBinding)) {
      return null;
    }

    return ginjectorInterface.getRawType();
  }
63892
private <T> Provider<T> autoProvider(Key<T> key)
  {
    for (InjectAutoBind autoBind : _autoBind) {
      Provider<T> provider = autoBind.provider(this, key);

      if (provider != null) {
        return provider;
      }
    }

    return providerDefault(key);
  }
384705
void write(GinjectorBindings bindings) throws UnableToCompleteException {

    TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
    String implClassName = ginjectorNameGenerator.getClassName(bindings);
    if (implClassName.contains(".")) {
      errorManager.logError("Internal error: the injector class name \"%s\" contains a full stop.",
          implClassName);
    }
    String packageName = ReflectUtil.getUserPackageName(TypeLiteral.get(bindings.getModule()));

    PrintWriter printWriter = ctx.tryCreate(logger, packageName, implClassName);
    if (printWriter == null) {
      // We already created this Ginjector.
      return;
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
        implClassName);
    SourceWriter writer = composerFactory.createSourceWriter(ctx, printWriter);

    FragmentMap fragments = new FragmentMap(bindings, packageName, implClassName,
        fragmentOutputterFactory);

    outputBindings(bindings, fragments, writer);
    errorManager.checkForError();

    fragments.commitAll();
    writer.commit(logger);
  }
410889
private <P> List<Facet> injectFacetBindings(DefaultPojoBinding<P> binding, Class<P> pojoType) {
        List<Facet> keyFacets = new LinkedList<>();
        facetProvider.getFacets(pojoType).stream().forEach(facet -> {
            if (facet.hasAnnotation(PartitionKey.class) || facet.hasAnnotation(ClusteringColumn.class)) {
                keyFacets.add(facet);
            } else {
                GenericType facetType = facet.getType();
                Converter converter = converterRegistry.getConverter(facetType);
                String columnName = namingStrategy.getColumnName(facet);
                if (converter != null) {
                    binding.addFacetBinding(new SimpleFacetBinding(facet, columnName, converter));
                } else if (facetType.isList()) {
                    binding.addFacetBinding(new ListFacetBinding(facet, columnName, createElementBinding(facet, facetType.getElementType())));
                } else if (facetType.isSet()) {
                    binding.addFacetBinding(new SetFacetBinding(facet, columnName, createElementBinding(facet, facetType.getElementType())));
                } else if (facetType.isMap()) {
                    Converter keyConverter = converterRegistry.getConverter(facetType.getMapKeyType());
                    if (keyConverter == null) {
                        throw new HecateException("Invalid facet \"%s\"; no converter registered for key type \"%s\".", facet.getName(), facetType.getMapKeyType().getRawType().getCanonicalName());
                    }
                    binding.addFacetBinding(new MapFacetBinding(facet, columnName, keyConverter, createElementBinding(facet, facetType.getMapValueType())));
                } else if (facetType.isArray()) {
                    binding.addFacetBinding(new ArrayFacetBinding(facet, columnName, createElementBinding(facet, facetType.getArrayElementType())));
                } else if (facet.hasAnnotation(Embedded.class)) {
                    binding.addFacetBinding(new EmbeddedFacetBinding(facet, converterRegistry, namingStrategy));
                } else {
                    PojoBinding<?> refBinding = createPojoBinding(facetType.getRawType());
                    binding.addFacetBinding(refBinding.getKeyBinding().createReferenceBinding(facet, refBinding, namingStrategy));
                }
            }
        });
        return keyFacets;
    }
1071587
function createKeyBinding(args) {
				if (!args) { return null; }
				var keyBinding = new mKeyBinding.KeyBinding();
				mKeyBinding.KeyBinding.apply(keyBinding, args);
				return keyBinding;
			}
1305950
private GinjectorBindings findSource(GinjectorBindings ginjector, Key<?> key) {
    Set<GinjectorBindings> visited = new LinkedHashSet<GinjectorBindings>();

    GinjectorBindings lastGinjector = null;
    while (ginjector != null) {
      if (!visited.add(ginjector)) {
        logger.log(Type.ERROR, PrettyPrinter.format(
          "Cycle detected in bindings for %s", key));
        for (GinjectorBindings visitedBindings : visited) {
          PrettyPrinter.log(logger, Type.ERROR, "  %s", visitedBindings);
        }
        return ginjector; // at this point, just return *something*
      }
      
      lastGinjector = ginjector;
      ginjector = linkedGinjector(ginjector.getBinding(key));
    }
    return lastGinjector;
  }
580485
function (attribute, key) {
                    if (this.inject && this.inject.hasOwnProperty(key)) {
                        return attribute;
                    } else if (attribute instanceof Bindable) {
                        return attribute.clone();
                    } else if (attribute && (attribute.clone instanceof Function)) {
                        return attribute.clone();
                    } else if (_.isArray(attribute)) {
                        var retArray = [];
                        for (var i = 0; i < attribute.length; i++) {
                            retArray.push(this._cloneAttribute(attribute[i]));
                        }
                        return retArray;
                    } else if (attribute instanceof Date) {
                        return new Date(attribute.getTime());
                    } else if (_.isObject(attribute)) {
                        var retObject = {};
                        for (var attrKey in attribute) {
                            if (attribute.hasOwnProperty(attrKey)) {
                                retObject[attrKey] = this._cloneAttribute(attribute[attrKey], attrKey);
                            }
                        }
                        return retObject;
                    } else {
                        return attribute;
                    }
                }
985537
public static <K, V> GinMapBinder<K, V> newMapBinder(
      GinBinder binder, Class<K> keyType, Class<V> valueType) {
    return newMapBinder(binder, TypeLiteral.get(keyType), TypeLiteral.get(valueType));
  }
981748
@Override
    @SuppressWarnings("unchecked")
    public synchronized <P> PojoBinding<P> createPojoBinding(Class<P> pojoType) {
        DefaultPojoBinding<P> binding = (DefaultPojoBinding<P>) bindingMap.get(pojoType);
        if (binding == null) {
            binding = new DefaultPojoBinding<>(pojoType);
            bindingMap.put(pojoType, binding);
            List<Facet> keyFacets = injectFacetBindings(binding, pojoType);
            injectKeyBinding(binding, pojoType, keyFacets);
        }
        return binding;
    }