Search in sources :

Example 6 with ParentBinding

use of com.google.gwt.inject.rebind.binding.ParentBinding in project google-gin by gwtplus.

the class GinjectorBindings method determineScope.

public GinScope determineScope(Key<?> key) {
    assertFinalized();
    GinScope scope = scopes.get(key);
    if (scope == null) {
        Class<?> raw = key.getTypeLiteral().getRawType();
        Binding binding = bindings.get(key);
        if (binding != null && (binding instanceof ExposedChildBinding || binding instanceof ParentBinding)) {
            // If this is just a "copy" of a binding higher/lower in the injector
            // tree, we prefer to treat the binding like it's unscoped, and refer to
            // the "real" binding every time we need the value.
            scope = GinScope.NO_SCOPE;
        } else if (raw.getAnnotation(Singleton.class) != null || raw.getAnnotation(javax.inject.Singleton.class) != null) {
            // Look for scope annotation as a fallback
            scope = GinScope.SINGLETON;
        } else if (RemoteServiceProxyBinding.isRemoteServiceProxy(key.getTypeLiteral())) {
            // Special case for remote services
            scope = GinScope.SINGLETON;
        } else {
            scope = GinScope.NO_SCOPE;
        }
    }
    logger.log(TreeLogger.TRACE, "scope for " + key + ": " + scope);
    return scope;
}
Also used : RemoteServiceProxyBinding(com.google.gwt.inject.rebind.binding.RemoteServiceProxyBinding) ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding) Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) Singleton(com.google.inject.Singleton) ExposedChildBinding(com.google.gwt.inject.rebind.binding.ExposedChildBinding)

Aggregations

ParentBinding (com.google.gwt.inject.rebind.binding.ParentBinding)6 Binding (com.google.gwt.inject.rebind.binding.Binding)4 Dependency (com.google.gwt.inject.rebind.binding.Dependency)3 ExposedChildBinding (com.google.gwt.inject.rebind.binding.ExposedChildBinding)3 Context (com.google.gwt.inject.rebind.binding.Context)2 Key (com.google.inject.Key)2 HashMap (java.util.HashMap)2 RemoteServiceProxyBinding (com.google.gwt.inject.rebind.binding.RemoteServiceProxyBinding)1 Singleton (com.google.inject.Singleton)1