Java 类com.google.inject.spi.ScopeBinding 实例源码

项目:guice-old    文件:ScopeBindingProcessor.java   
@Override public Boolean visit(ScopeBinding command) {
  Scope scope = command.getScope();
  Class<? extends Annotation> annotationType = command.getAnnotationType();

  if (!Annotations.isScopeAnnotation(annotationType)) {
    errors.missingScopeAnnotation(annotationType);
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  if (!Annotations.isRetainedAtRuntime(annotationType)) {
    errors.missingRuntimeRetention(annotationType);
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  ScopeBinding existing = injector.state.getScopeBinding(checkNotNull(annotationType, "annotation type"));
  if (existing != null) {
    errors.duplicateScopes(existing, annotationType, scope);
  } else {
    checkNotNull(scope, "scope");
    injector.state.putScopeBinding(annotationType, command);
  }

  return true;
}
项目:google-guice    文件:ScopeBindingProcessor.java   
@Override public Boolean visit(ScopeBinding command) {
  Scope scope = command.getScope();
  Class<? extends Annotation> annotationType = command.getAnnotationType();

  if (!Annotations.isScopeAnnotation(annotationType)) {
    errors.withSource(annotationType).missingScopeAnnotation();
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  if (!Annotations.isRetainedAtRuntime(annotationType)) {
    errors.withSource(annotationType)
        .missingRuntimeRetention(command.getSource());
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  Scope existing = injector.state.getScope(checkNotNull(annotationType, "annotation type"));
  if (existing != null) {
    errors.duplicateScopes(existing, annotationType, scope);
  } else {
    injector.state.putAnnotation(annotationType, checkNotNull(scope, "scope"));
  }

  return true;
}
项目:guice    文件:ScopeBindingProcessor.java   
@Override
public Boolean visit(ScopeBinding command) {
  Scope scope = checkNotNull(command.getScope(), "scope");
  Class<? extends Annotation> annotationType =
      checkNotNull(command.getAnnotationType(), "annotation type");

  if (!Annotations.isScopeAnnotation(annotationType)) {
    errors.missingScopeAnnotation(annotationType);
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  if (!Annotations.isRetainedAtRuntime(annotationType)) {
    errors.missingRuntimeRetention(annotationType);
    // Go ahead and bind anyway so we don't get collateral errors.
  }

  ScopeBinding existing = injector.state.getScopeBinding(annotationType);
  if (existing != null) {
    if (!scope.equals(existing.getScope())) {
      errors.duplicateScopes(existing, annotationType, scope);
    }
  } else {
    injector.state.putScopeBinding(annotationType, command);
  }

  return true;
}
项目:guice    文件:InheritingState.java   
@Override
public Map<Class<? extends Annotation>, Scope> getScopes() {
  ImmutableMap.Builder<Class<? extends Annotation>, Scope> builder = ImmutableMap.builder();
  for (Map.Entry<Class<? extends Annotation>, ScopeBinding> entry : scopes.entrySet()) {
    builder.put(entry.getKey(), entry.getValue().getScope());
  }
  return builder.build();
}
项目:guice    文件:Scoping.java   
/**
 * Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance
 * map. If the scope annotation has no corresponding instance, an error will be added and unscoped
 * will be retuned.
 */
static Scoping makeInjectable(Scoping scoping, InjectorImpl injector, Errors errors) {
  Class<? extends Annotation> scopeAnnotation = scoping.getScopeAnnotation();
  if (scopeAnnotation == null) {
    return scoping;
  }

  ScopeBinding scope = injector.state.getScopeBinding(scopeAnnotation);
  if (scope != null) {
    return forInstance(scope.getScope());
  }

  errors.scopeNotFound(scopeAnnotation);
  return UNSCOPED;
}
项目:guice-old    文件:InheritingState.java   
public Map<Class<? extends Annotation>, Scope> getScopes() {
  ImmutableMap.Builder<Class<? extends Annotation>, Scope> builder = ImmutableMap.builder();
  for (Map.Entry<Class<? extends Annotation>, ScopeBinding> entry : scopes.entrySet()) {
    builder.put(entry.getKey(), entry.getValue().getScope());
  }
  return builder.build();
}
项目:guice-old    文件:Scoping.java   
/**
 * Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance
 * map. If the scope annotation has no corresponding instance, an error will be added and unscoped
 * will be retuned.
 */
static Scoping makeInjectable(Scoping scoping, InjectorImpl injector, Errors errors) {
  Class<? extends Annotation> scopeAnnotation = scoping.getScopeAnnotation();
  if (scopeAnnotation == null) {
    return scoping;
  }

  ScopeBinding scope = injector.state.getScopeBinding(scopeAnnotation);
  if (scope != null) {
    return forInstance(scope.getScope());
  }

  errors.scopeNotFound(scopeAnnotation);
  return UNSCOPED;
}
项目:ProjectAres    文件:ElementInspector.java   
@Override
public V visit(ScopeBinding binding) {
    return message(binding,
                   "Binding scope annotation " + binding.getAnnotationType() +
                   " to scope " + binding.getScope());
}
项目:guice    文件:InheritingState.java   
@Override
public ScopeBinding getScopeBinding(Class<? extends Annotation> annotationType) {
  ScopeBinding scopeBinding = scopes.get(annotationType);
  return scopeBinding != null ? scopeBinding : parent.getScopeBinding(annotationType);
}
项目:guice    文件:InheritingState.java   
@Override
public void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope) {
  scopes.put(annotationType, scope);
}
项目:guice    文件:State.java   
@Override
public ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation) {
  return null;
}
项目:guice    文件:State.java   
@Override
public void putScopeBinding(
    Class<? extends Annotation> annotationType, ScopeBinding scope) {
  throw new UnsupportedOperationException();
}
项目:guice    文件:Errors.java   
public Errors duplicateScopes(
    ScopeBinding existing, Class<? extends Annotation> annotationType, Scope scope) {
  return addMessage(
      "Scope %s is already bound to %s at %s.%n Cannot bind %s.",
      existing.getScope(), annotationType, existing.getSource(), scope);
}
项目:guice    文件:WeakKeySetTest.java   
@Override
public ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation) {
  return null;
}
项目:guice    文件:WeakKeySetTest.java   
@Override
public void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope) {
  throw new UnsupportedOperationException();
}
项目:guice-old    文件:InheritingState.java   
public ScopeBinding getScopeBinding(Class<? extends Annotation> annotationType) {
  ScopeBinding scopeBinding = scopes.get(annotationType);
  return scopeBinding != null ? scopeBinding : parent.getScopeBinding(annotationType);
}
项目:guice-old    文件:InheritingState.java   
public void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope) {
  scopes.put(annotationType, scope);
}
项目:guice-old    文件:State.java   
public ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation) {
  return null;
}
项目:guice-old    文件:State.java   
public void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope) {
  throw new UnsupportedOperationException();
}
项目:guice-old    文件:Errors.java   
public Errors duplicateScopes(ScopeBinding existing,
    Class<? extends Annotation> annotationType, Scope scope) {
  return addMessage("Scope %s is already bound to %s at %s.%n Cannot bind %s.",
      existing.getScope(), annotationType, existing.getSource(), scope);
}
项目:guice-old    文件:WeakKeySetTest.java   
public ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation) {
  return null;
}
项目:guice-old    文件:WeakKeySetTest.java   
public void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope) {
  throw new UnsupportedOperationException();
}
项目:guice    文件:State.java   
ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation);
项目:guice    文件:State.java   
void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope);
项目:guice-old    文件:State.java   
ScopeBinding getScopeBinding(Class<? extends Annotation> scopingAnnotation);
项目:guice-old    文件:State.java   
void putScopeBinding(Class<? extends Annotation> annotationType, ScopeBinding scope);