Tabnine Logo
ProviderMethodsModule
Code IndexAdd Tabnine to your IDE (free)

How to use
ProviderMethodsModule
in
com.google.inject.internal

Best Java code snippets using com.google.inject.internal.ProviderMethodsModule (Showing top 20 results out of 315)

origin: com.google.inject/guice

/**
 * Applies all scanners to the modules we've installed. We skip certain PrivateModules because
 * store them in more than one Modules map and only want to process them through one of the
 * maps. (They're stored in both maps to prevent a module from being installed more than once.)
 */
void scanForAnnotatedMethods() {
 for (ModuleAnnotatedMethodScanner scanner : scanners) {
  // Note: we must iterate over a copy of the modules because calling install(..)
  // will mutate modules, otherwise causing a ConcurrentModificationException.
  for (Map.Entry<Module, ModuleInfo> entry : Maps.newLinkedHashMap(modules).entrySet()) {
   Module module = entry.getKey();
   ModuleInfo info = entry.getValue();
   if (info.skipScanning) {
    continue;
   }
   moduleSource = entry.getValue().moduleSource;
   try {
    info.binder.install(ProviderMethodsModule.forModule(module, scanner));
   } catch (RuntimeException e) {
    Collection<Message> messages = Errors.getMessagesFromThrowable(e);
    if (!messages.isEmpty()) {
     elements.addAll(messages);
    } else {
     addError(e);
    }
   }
  }
 }
 moduleSource = null;
}
origin: com.google.inject/guice

/**
 * Returns a module which creates bindings for provider methods from the given object. This is
 * useful notably for <a href="http://code.google.com/p/google-gin/">GIN</a>
 *
 * <p>This will skip bytecode generation for provider methods, since it is assumed that callers
 * are only interested in Module metadata.
 */
public static Module forObject(Object object) {
 return forObject(object, true, ProvidesMethodScanner.INSTANCE);
}
origin: com.google.inject/guice

@Override
public void configure(Binder binder) {
 for (ProviderMethod<?> providerMethod : getProviderMethods(binder)) {
  providerMethod.configure(binder);
 }
}
origin: com.google.inject/guice

for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
 for (Method method : c.getDeclaredMethods()) {
  Annotation annotation = getAnnotation(binder, method);
  if (annotation != null) {
   if (result == null) {
    result = Lists.newArrayList();
   result.add(createProviderMethod(binder, method, annotation));
   superMostClass = c;
   if (overrides(matchingSignature, method)) {
    String annotationString =
      provider.getAnnotation().annotationType() == Provides.class
origin: com.google.inject/guice

 Object delegate = ((ProviderMethodsModule) module).getDelegateModule();
 if (moduleSource == null
   || !moduleSource.getModuleClassName().equals(delegate.getClass().getName())) {
binder.install(ProviderMethodsModule.forModule(module));
origin: ArcBees/Jukito

    ProviderMethodsModule.forModule(this);
List<ProviderMethod<?>> providerMethodList = providerMethodsModule.getProviderMethods(binder());
for (ProviderMethod<?> providerMethod : providerMethodList) {
  keysObserved.add(providerMethod.getKey());
origin: com.google.inject/guice

private static Module forObject(
  Object object, boolean skipFastClassGeneration, ModuleAnnotatedMethodScanner scanner) {
 // avoid infinite recursion, since installing a module always installs itself
 if (object instanceof ProviderMethodsModule) {
  return Modules.EMPTY_MODULE;
 }
 return new ProviderMethodsModule(object, skipFastClassGeneration, scanner);
}
origin: com.google.inject/guice

private <T> ProviderMethod<T> createProviderMethod(
  Binder binder, Method method, Annotation annotation) {
 binder = binder.withSource(method);
 Errors errors = new Errors(method);
 // prepare the parameter providers
 InjectionPoint point = InjectionPoint.forMethod(method, typeLiteral);
 @SuppressWarnings("unchecked") // Define T as the method's return type.
 TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method);
 Key<T> key = getKey(errors, returnType, method, method.getAnnotations());
 try {
  key = scanner.prepareMethod(binder, annotation, key, point);
 } catch (Throwable t) {
  binder.addError(t);
 }
 Class<? extends Annotation> scopeAnnotation =
   Annotations.findScopeAnnotation(errors, method.getAnnotations());
 for (Message message : errors.getMessages()) {
  binder.addError(message);
 }
 return ProviderMethod.create(
   key,
   method,
   delegate,
   ImmutableSet.copyOf(point.getDependencies()),
   scopeAnnotation,
   skipFastClassGeneration,
   annotation);
}
origin: org.xbib/guice

  methodsBySignature.put(new Signature(method), method);
Optional<Annotation> annotation = isProvider(binder, method);
if (annotation.isPresent()) {
  result.add(createProviderMethod(binder, method, annotation.get()));
if (overrides(matchingSignature, method)) {
  String annotationString = provider.getAnnotation().annotationType() == Provides.class
      ? "@Provides" : "@" + provider.getAnnotation().annotationType().getCanonicalName();
origin: com.google/inject

public List<ProviderMethod<?>> getProviderMethods(Binder binder) {
 List<ProviderMethod<?>> result = Lists.newArrayList();
 for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
  for (Method method : c.getDeclaredMethods()) {
   if (method.isAnnotationPresent(Provides.class)) {
    result.add(createProviderMethod(binder, method));
   }
  }
 }
 return result;
}
origin: org.sonatype.sisu/sisu-guice

 Object delegate = ((ProviderMethodsModule) module).getDelegateModule();
 if (moduleSource == null
   || !moduleSource.getModuleClassName().equals(delegate.getClass().getName())) {
binder.install(ProviderMethodsModule.forModule(module));
origin: com.jwebmp.inject/guice

for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
 for (Method method : c.getDeclaredMethods()) {
  Annotation annotation = getAnnotation(binder, method);
  if (annotation != null) {
   if (result == null) {
    result = Lists.newArrayList();
   result.add(createProviderMethod(binder, method, annotation));
   superMostClass = c;
   if (overrides(matchingSignature, method)) {
    String annotationString =
      provider.getAnnotation().annotationType() == Provides.class
origin: org.jukito/jukito

    ProviderMethodsModule.forModule(this);
List<ProviderMethod<?>> providerMethodList = providerMethodsModule.getProviderMethods(binder());
for (ProviderMethod<?> providerMethod : providerMethodList) {
  keysObserved.add(providerMethod.getKey());
origin: org.xbib/guice

private static Module forObject(Object object, boolean skipFastClassGeneration,
                ModuleAnnotatedMethodScanner scanner) {
  // avoid infinite recursion, since installing a module always installs itself
  if (object instanceof ProviderMethodsModule) {
    return Modules.EMPTY_MODULE;
  }
  return new ProviderMethodsModule(object, skipFastClassGeneration, scanner);
}
origin: at.bestsolution.efxclipse.eclipse/com.google.inject

Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 0; i < parameterTypes.size(); i++) {
 Key<?> key = getKey(errors, parameterTypes.get(i), method, parameterAnnotations[i]);
 if(key.equals(Key.get(Logger.class))) {
TypeLiteral<T> returnType = (TypeLiteral<T>) typeLiteral.getReturnType(method);
Key<T> key = getKey(errors, returnType, method, method.getAnnotations());
Class<? extends Annotation> scopeAnnotation
  = Annotations.findScopeAnnotation(errors, method.getAnnotations());
origin: at.bestsolution.efxclipse.eclipse/com.google.inject

public List<ProviderMethod<?>> getProviderMethods(Binder binder) {
 List<ProviderMethod<?>> result = Lists.newArrayList();
 for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
  for (Method method : c.getDeclaredMethods()) {
   if (method.isAnnotationPresent(Provides.class)) {
    result.add(createProviderMethod(binder, method));
   }
  }
 }
 return result;
}
origin: com.google.inject/guice

/** Returns a module which creates bindings for provider methods from the given module. */
public static Module forModule(Module module) {
 return forObject(module, false, ProvidesMethodScanner.INSTANCE);
}
origin: org.atteo.moonshine/container

  @Override
  public void configure(Binder binder) {
    if (modules.add(module)) {
      module.configure(createForwardingBinder(binder));
      binder.install(ProviderMethodsModule.forModule(module));
    }
  }
};
origin: org.xbib/guice

  Object delegate = ((ProviderMethodsModule) module).getDelegateModule();
  if (moduleSource == null
      || !moduleSource.getModuleClassName().equals(delegate.getClass().getName())) {
binder.install(ProviderMethodsModule.forModule(module));
origin: org.sonatype.sisu/sisu-guice

for (Class<?> c = delegate.getClass(); c != Object.class; c = c.getSuperclass()) {
 for (Method method : c.getDeclaredMethods()) {
  Annotation annotation = getAnnotation(binder, method);
  if (annotation != null) {
   if (result == null) {
    result = Lists.newArrayList();
   result.add(createProviderMethod(binder, method, annotation));
   superMostClass = c;
   if (overrides(matchingSignature, method)) {
    String annotationString =
      provider.getAnnotation().annotationType() == Provides.class
com.google.inject.internalProviderMethodsModule

Javadoc

Creates bindings to methods annotated with @Provides. Use the scope and binding annotations on the provider method to configure the binding.

Most used methods

  • forModule
    Returns a module which creates bindings methods in the module that match the scanner.
  • forObject
  • getProviderMethods
  • <init>
  • createProviderMethod
  • getKey
  • getDelegateModule
  • overrides
    Returns true if a overrides b, assumes that the signatures match
  • getAnnotation
    Returns the annotation that is claimed by the scanner, or null if there is none.
  • isProvider
    Returns true if the method is a provider. Synthetic bridge methods are excluded. Starting with JDK 8

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • JTable (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now